]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix rlm_sql noop for accounting start
authorDmitry Borodaenko <angdraug@debian.org>
Sat, 6 Aug 2011 17:15:59 +0000 (20:15 +0300)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 18 Sep 2011 11:56:48 +0000 (13:56 +0200)
When 6ed9727 was merged, else{} in the START case got placed against the
wrong if(). Unlike STOP and ALIVE cases, in START insert comes first,
and we only care if that affects 0 rows. If insert fails and we have to
go for an update, we don't have to check for NOOP because we can assume
the insert failed due to a conflicting row already in the database.

src/modules/rlm_sql/rlm_sql.c

index 09823638010dab1ecf3ce96d0c3fd16a8b93afba..1154fab73c07f96abd4d39e8290bd596ec15a690 100644 (file)
@@ -1327,13 +1327,13 @@ static int rlm_sql_accounting(void *instance, REQUEST * request) {
                                                        radlog_request(L_ERR, 0, request, "Couldn't update SQL accounting START record - %s",
                                                               (inst->module->sql_error)(sqlsocket, inst->config));
                                                        ret = RLM_MODULE_FAIL;
-                                               } else {
-                                                       numaffected = (inst->module->sql_affected_rows)(sqlsocket, inst->config);
-                                                       if (numaffected < 1) {
-                                                               ret = RLM_MODULE_NOOP;
-                                                       }
                                                }
                                        }
+                               } else {
+                                       numaffected = (inst->module->sql_affected_rows)(sqlsocket, inst->config);
+                                       if (numaffected < 1) {
+                                               ret = RLM_MODULE_NOOP;
+                                       }
                                }
                                (inst->module->sql_finish_query)(sqlsocket, inst->config);
                        }