Anything close to this?
If not, any pointers?
Index: sql.c
===================================================================
RCS file: /source/radiusd/src/modules/rlm_sql/sql.c,v
retrieving revision 1.49
diff -u -r1.49 sql.c
--- sql.c 2002/06/10 10:19:49 1.49
+++ sql.c 2002/06/18 19:41:48
@@ -52,7 +52,10 @@
#include "conffile.h"
#include "rlm_sql.h"
+pthread_mutex_t socknr_mutex;
+int socknr = 0;
+
/*
* Connect to a server. If error, set this socket's state to be "sockunconnected"
* and set a grace period, during which we won't try connecting again (to prevent
unduly
@@ -89,6 +92,8 @@
inst->used = 0;
inst->sqlpool = NULL;
+ pthread_mutex_init(&socknr_mutex);
+
for (i = 0; i < inst->config->num_sql_socks; i++) {
sqlsocket = rad_malloc(sizeof(SQLSOCK));
@@ -157,7 +162,6 @@
return 1;
}
-
/*************************************************************************
*
* Function: sql_get_socket
@@ -174,7 +178,23 @@
return NULL;
}
- for (cur = inst->sqlpool; cur; cur = cur->next) {
+ /*
+ * Rotating the socket so that they all get used and no sockets get closed due
+ * to inactivity from the SQL server (MySQL).
+ * - Jacob
+ */
+ pthread_mutex_lock(&socknr_mutex);
+ if (socknr == 0){
+ socknr = inst->config->num_sql_socks;
+ }
+ socknr--;
+ cur2 = inst->sqlpool;
+ while (socknr != cur2->id) {
+ cur2 = cur2->next;
+ }
+ pthread_mutex_unlock(&socknr_mutex);
+
+ for (cur = cur2; cur; cur = cur->next) {
/* if we happen upon an unconnected socket, and this instance's grace
* period on (re)connecting has expired, then try to connect it. This
--
Todd Fries .. [EMAIL PROTECTED]
(last updated $ToddFries: signature.p,v 1.2 2002/03/19 15:10:18 todd Exp $)
Penned by Alan DeKok on Tue, Jun 18, 2002 at 11:01:53AM -0400, we have:
| "Todd T. Fries" <[EMAIL PROTECTED]> wrote:
| > I've been referred to a patch that rotates sockets, but can not find that it
| > is in current cvs.
|
| It's sitting in my 'patches to edit' queue.
|
| > This diff applies to current cvs. Is there a reason this should not go in?
|
| It's not thread-safe. There are only minor changes required, but
| there are changes required.
|
| Alan DeKok.
|
| -
| List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html