On Wed, 2002-12-04 at 01:48, Alan DeKok wrote:
> Malcolm Caldwell <[EMAIL PROTECTED]> wrote:
> > At the moment the server crashes multiple times a day.
> >
> > I *think* I have tracked down the problem.
> >
> > If a user logs in with a username > 32 characters we have problems. The
> > column is VARCHAR2 32, and so the insert/update fails (fair enough).
>
> So increase the size of the column in the SQL table. That should
> help in the short term.
Of course that was the first thing we did!
>
> > First bug:
> > rlm_sql_oracle.c returns SQL_DOWN.
> >
> > I believe it should return -1. SQL_DOWN should be for when the
> > connection fails.
>
> It should return "failed to do SQL query", which is semantically not
> that different from "unable to contact SQL server"
Whose semantics? A database login would seem to be quite an expensive
operation - why do them unnecessarily?
Particularly as the code as it stands is *designed* to do queries on
start and stop that can fail and then to do alternative queries.
What this means with the current code with this second bug that every
time freeradius receives a stop it did not get a start for it will:
* Try the stop_query which fails due to no matching start
* Do a re-connect:
* Leak a database login
* Spend time logging in
* Try the stop_query_alt
In our case with a too long username it was worse: we would leak two
oracle logins per accounting packet.
> Alan DeKok.
You did not mention the second bug! (The reconnect code leaking database
logins) Here is my attempt at a fix - one patch for sql.c and one for
oracle.c (the other drivers can be similarly fixed by placing a free in
the sql_close function)
Index: src/modules/rlm_sql/sql.c
===================================================================
RCS file: /source/radiusd/src/modules/rlm_sql/sql.c,v
retrieving revision 1.58
diff -u -r1.58 sql.c
--- src/modules/rlm_sql/sql.c 2002/11/08 20:45:10 1.58
+++ src/modules/rlm_sql/sql.c 2002/12/04 00:15:33
@@ -65,6 +65,9 @@
radlog(L_DBG, "rlm_sql (%s): Attempting to connect %s #%d",
inst->config->xlat_name, inst->module->name, sqlsocket->id);
+ if (sqlsocket->conn!=NULL) {
+ (inst->module->sql_close)(sqlsocket, inst->config);
+ }
if ((inst->module->sql_init_socket)(sqlsocket, inst->config) < 0) {
radlog(L_CONS | L_ERR, "rlm_sql (%s): Failed to connect DB handl
e #%d", inst->config->xlat_name, sqlsocket->id);
inst->connect_after = time(NULL) + inst->config->connect_failure
_retry_delay;
Index: src/modules/rlm_sql/drivers/rlm_sql_oracle/sql_oracle.c
===================================================================
RCS file: /source/radiusd/src/modules/rlm_sql/drivers/rlm_sql_oracle/sql_oracle.
c,v
retrieving revision 1.25
diff -u -r1.25 sql_oracle.c
--- src/modules/rlm_sql/drivers/rlm_sql_oracle/sql_oracle.c 2002/12/02 16:51:15
1.25
+++ src/modules/rlm_sql/drivers/rlm_sql_oracle/sql_oracle.c 2002/12/04 00:15:33
@@ -492,6 +492,8 @@
OCIHandleFree((dvoid *)oracle_sock->env, (ub4) OCI_HTYPE_ENV);
}
+ free(oracle_sock->conn);
+
oracle_sock->conn = NULL;
return 0;
>
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
>
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html