Hi,

I've tried doing a tweak on rlm_sql.c to bypass reserving a socket for
sessions with "0" duration on the stop packets. This is to minimize
active sockets which may be used for the non-zero calls. Hoping that the
server would scale up with rapid accounting (stop-only) data that is
pouring in.

I have attached here the diff from the cvs version.

Is there another way of doing this? Have I overlooked something? The
tweak seems to run good overnight (500k+ stop records at the moment).

Thanks,

roy
--- rlm_sql.c   2004-08-18 15:36:25.000000000 +0800
+++ rlm_sql.cvs.c       2004-08-18 15:07:17.000000000 +0800
@@ -932,7 +932,7 @@
                                }
                                (inst->module->sql_finish_query)(sqlsocket, 
inst->config);
                        }
-                       sql_release_socket(inst, sqlsocket);
+
                        break;
 
                        /*
@@ -983,7 +983,6 @@
                                }
                                (inst->module->sql_finish_query)(sqlsocket, 
inst->config);
                        }
-                       sql_release_socket(inst, sqlsocket);
                        break;
 
                        /*
@@ -1028,7 +1027,6 @@
                                }
                                (inst->module->sql_finish_query)(sqlsocket, 
inst->config);
                        }
-                       sql_release_socket(inst, sqlsocket);
                        break;
 
                        /*
@@ -1044,13 +1042,10 @@
                        radius_xlat(querystr, sizeof(querystr), 
inst->config->accounting_stop_query, request, sql_escape_func);
                        query_log(request, inst, querystr);
 
-                       pair = pairfind(request->packet->vps, PW_ACCT_SESSION_TIME);
-                       acctsessiontime = pair->lvalue;
-
-                       if ((*querystr) && (acctsessiontime > 0)) { /* non-empty query 
*/
-                               sqlsocket = sql_get_socket(inst);
-                               if (sqlsocket == NULL)
-                                       return(RLM_MODULE_FAIL);
+                       sqlsocket = sql_get_socket(inst);
+                       if (sqlsocket == NULL)
+                               return(RLM_MODULE_FAIL);
+                       if (*querystr) { /* non-empty query */
                                if (rlm_sql_query(sqlsocket, inst, querystr)) {
                                        radlog(L_ERR, "rlm_sql (%s): Couldn't update 
SQL accounting STOP record - %s",
                                               inst->config->xlat_name,
@@ -1099,7 +1094,6 @@
                                        }
                                }
                                (inst->module->sql_finish_query)(sqlsocket, 
inst->config);
-                               sql_release_socket(inst, sqlsocket);
                        }
                        break;
 
@@ -1109,11 +1103,11 @@
                default:
                        radlog(L_INFO, "rlm_sql (%s): Unsupported Acct-Status-Type = 
%d", inst->config->xlat_name, acctstatustype);
                        return RLM_MODULE_NOOP;
-                       sql_release_socket(inst, sqlsocket);
                        break;
 
        }
 
+       sql_release_socket(inst, sqlsocket);
 
        return ret;
 }

Reply via email to