"Todd T. Fries" <[EMAIL PROTECTED]> wrote:
> Anything close to this?

  The mutex and the 'current socket number' should be allocated in the
'instance' data structure.

  If you have 3 SQL instances, to 3 SQL servers, you do NOT want them
inter-acting in bad ways.

> +     pthread_mutex_init(&socknr_mutex);
> +
>       for (i = 0; i < inst->config->num_sql_socks; i++) {

  You should instead do:

  pthread_mutex_init(&inst->mutex, NULL);

  for (i = 0; i < inst->config->num_sql_socks; i++) {
    ...


  And remember to destroy the mutex in sql_poolfree() !!

> +     pthread_mutex_lock(&socknr_mutex);
> +     if (socknr == 0){
> +             socknr = inst->config->num_sql_socks;

  Should be:

    pthread_mutex_lock(&inst->mutex);
    if (inst->socknr == 0) {
        inst->socknr = inst->config->num_sql_socks;
    }

....  find the socket, and unlock the mutex.


  You'll have to patch 'rlm_sql.h', data structure 'sql_inst', too, to
add the 'mutex' and 'socknr' elements.

  Alan DeKok.

- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to