Hi,

I was investigating an issue I had on my customized Kannel where only the first 
Http SMSC, of many http smsc, would be able to receive MO. The other sockets 
would simply hang (or so it appeared).

I discovered that basically the http server thread was getting blocked on the 
thread poll, and until I send a message through to a port that is already in 
the list, it ill never pickup any of those requests.
Basically, in http.c, the function server_thread() picks up the first http 
SMSC, adds it to struct pollfd tab[MAX_SERVERS];
Then         if ((ret = gwthread_poll(tab, n, -1.0)) == -1)   will block 
waiting for data on the socket.

But if there is another server to be added afterwards, this gets called from 
http.c: int http_open_port_if(int port, int ssl, Octstr *interface);
Now it looks like this should wake up that polling thread, and add the new port 
to "tab" data structure above, and go back to waiting state again. but waiting 
on more sockets now..

The doc says:
/* If the other thread is currently in gwthread_pollfd or gwthread_sleep,
 * make it return immediately.  Otherwise, make it return immediately, the
 * next time it calls one of those functions. */
void gwthread_wakeup(long thread);

But I see many calls to gwthread_pollfd and its never unblocking.

I've done a really dirty hack to make it work temporarily. I removed the call 
to start_server_thread from http_open_port_if, so its not called after creating 
each SMSC.
Now I just call it manualy after loading all over the SMSC from CFG. Then I 
changed the server_thread to instead of adding 1 socket per itteration, it 
loops (in server_thread()):
            while (n < MAX_SERVERS && gwlist_len(new_server_sockets) > 0)
            

It seems to be working fine for now, but it is really not a clean solution at 
all.
Has anyone bumped into this before, or knows a good solution?

Thanks,
Brian

Reply via email to