Hi

We run into this all the time with out SMPP server. Threads are spawned for new ESME connections and terminated on disconnect. Some of our users connect and disconnect very regularily and the thread-id often goes over 1024. This however means quite a few changes to the way the log stuff currently works. We may have to use a list instead of an array.

Nisan

At 03:51 PM 6/19/03 +0100, Michael Mulcahy wrote:
Hi Stipe,

There does not need to be more 1024 concurrent threads to
reproduce this problem. The problem is associated with
the internal thread number assigned to each thread. the
log output displays this number in brackets.

The new logging of threads to a different log file
expects this number to be between 0 and 1024 which
may not be the case.

The thread implementation contains an integer value that
is assigned to a new thread and is then incremented.

If you create a thread and destroy it many times then the
number can get larger than 1024.

For example:

Start the bearerbox
Write a script that connects to smsbox port and then disconnects.
put this is a loop for 2000 times.

2 threads will get created and then destroyed for each connection
establishment and for each disconnection. As the threads get created the
number grows.

2003-06-19 15:46:55 [6] DEBUG: Started thread 23 (gw\bb_boxc.c:function)
2003-06-19 15:46:55 [23] INFO: Client connected from <192.168.0.97>
2003-06-19 15:46:55 [23] DEBUG: Started thread 24 (gw\bb_boxc.c:boxc_sender)
2003-06-19 15:46:55 [23] INFO: Connection closed by the box <192.168.0.97>
2003-06-19 15:46:55 [24] DEBUG: Thread 24 (gw\bb_boxc.c:boxc_sender)
terminates.
2003-06-19 15:46:55 [23] DEBUG: Thread 23 (gw\bb_boxc.c:function)
terminates.
2003-06-19 15:46:56 [6] DEBUG: Started thread 25 (gw\bb_boxc.c:function)
2003-06-19 15:46:56 [25] INFO: Client connected from <192.168.0.97>
2003-06-19 15:46:56 [25] DEBUG: Started thread 26 (gw\bb_boxc.c:boxc_sender)
2003-06-19 15:46:56 [25] INFO: Connection closed by the box <192.168.0.97>
2003-06-19 15:46:56 [26] DEBUG: Thread 26 (gw\bb_boxc.c:boxc_sender)
terminates.
2003-06-19 15:46:56 [25] DEBUG: Thread 25 (gw\bb_boxc.c:function)
terminates.
2003-06-19 15:46:57 [6] DEBUG: Started thread 27 (gw\bb_boxc.c:function)
2003-06-19 15:46:57 [27] INFO: Client connected from <192.168.0.97>
2003-06-19 15:46:57 [27] DEBUG: Started thread 28 (gw\bb_boxc.c:boxc_sender)
2003-06-19 15:46:57 [27] INFO: Connection closed by the box <192.168.0.97>
2003-06-19 15:46:57 [28] DEBUG: Thread 28 (gw\bb_boxc.c:boxc_sender)
terminates.

here is a ruby script I wrote to reproduce this:


require 'socket'


count = 0
while (count < 3000)
        t = TCPSocket.new('127.0.0.1', 13001)
        t.close
        count += 1
end

Hope that helps explain it a bit better,

Warmest Regards,
Michael.


> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > Stipe Tolj > Sent: 19 June 2003 14:58 > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: Bug in log.c > > > Hi Michael, > > Michael Mulcahy wrote: > > > > Hi All, > > > > There is a bug in the logging functions debug, info, > warning, error and > > panic > > which cause a crash when called from a thread that has a > thread id larger > > than 1024, i.e. gwthread_self returns value > 1024 > > > > In the log module there is an array for mapping threads to logfiles: > > > > #define THREADTABLE_SIZE 1024 > > static unsigned int thread_to [ (long) THREADTABLE_SIZE ]; > > > > The log functions use this to identify which log file to > write the data to, > > as in following: > > > > void error(int e, const char *fmt, ...) > > { > > if ((e = thread_to[gwthread_self()])) { /**** > Relevent line ***/ > > FUNCTION_GUTS_EXCL(GW_ERROR, ""); > > } else { > > FUNCTION_GUTS(GW_ERROR, ""); > > } > > } > > > > Unfortunately if gwthread_self returns a value greater than > 1024 then > > problems > > occur. > > > > Comments or suggestions appreciated! > > you are right. But how to reproduce this? > > Have you ceriously running bearerbox with more than 1024 threads > inside? > > Stipe > > [EMAIL PROTECTED] > ------------------------------------------------------------------- > Wapme Systems AG > > Vogelsanger Weg 80 > 40470 D�sseldorf > > Tel: +49-211-74845-0 > Fax: +49-211-74845-299 > > E-Mail: [EMAIL PROTECTED] > Internet: http://www.wapme-systems.de > ------------------------------------------------------------------- > wapme.net - wherever you are >




Reply via email to