Hi Folks,

I wanted to test the 2.6c version on a testsystem of ours but I ran into 
trouble. Every time 1 request was handled I got this error:

MONITOR: worker exited on signal 11, restarting...

After some research I found out it was the memcopy in do_http() which causes 
the error:

from_host = ((thr_arg *)arg)->from_host;
memcpy(&from_host_addr, from_host.ai_addr, from_host.ai_addrlen);
from_host.ai_addr = (struct sockaddr *)&from_host_addr;

The value from_host.ai_addrlen was equal to 5394258 and after some debugging it 
seems the whole struct contained bogus.

Ok, let's find out why?

The do_http() function is called from thr_http() which has some strange while 
loop in it. It fetches work from a queue with the call get_thr_arg() but this 
call is allowed to return a NULL value sometimes. If this happens than ask 
again...
Well, this wasn't a NULL value so there must be something else going on. Maybe 
the queue?

The code contained some errors (as far as my concurrent and queue knowledge 
go's). I reimplemented them to the following code. It solved my errors and I 
think the strange while-loop in the thr_http function is not needed anymore.

Can you please comment on my changes?

int
put_thr_arg(thr_arg *arg)
{
    thr_arg *res;

    if((res = malloc(sizeof(thr_arg))) == NULL) {
        logmsg(LOG_WARNING, "thr_arg malloc");
        return -1;
    }
    memcpy(res, arg, sizeof(thr_arg));
    (void)pthread_mutex_lock(&arg_mut);

    res->next = NULL;

    if (last == NULL) {
        first = last = res;
    } else {
        last->next = res;
        last = res;
    }

    pthread_cond_broadcast(&arg_cond);
    (void)pthread_mutex_unlock(&arg_mut);
    return 0;
}

/*
 * get a request from the queue
 */
thr_arg *
get_thr_arg(void)
{
    thr_arg *res = NULL;

    (void)pthread_mutex_lock(&arg_mut);
    while (first == NULL)
        (void)pthread_cond_wait(&arg_cond, &arg_mut);

    res = first;
    if((first = res->next) == NULL)
        last = NULL;
    else
        pthread_cond_signal(&arg_cond);

    (void)pthread_mutex_unlock(&arg_mut);

    return res;
}

Thanks!

Kind regards,

Steven van der Vegt

--
To unsubscribe send an email with subject unsubscribe to pound@apsis.ch.
Please contact ro...@apsis.ch for questions.

Reply via email to