Re: [PATCH] fixes an issue when main thread is sleeping when receiving data.

Alexander Malysh <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
hi Vincent,

please try attached patch. The mtbatch freeze because in main we try  
to join all threads (gwthread_join_all) but
in read_messages_from_bearerbox we blocked infinite waiting for acks  
from bearerbox.

Thanks,
Alex



Am 17.04.2009 um 11:35 schrieb Vincent CHAVANIS:

>
> I've experiences somes troubles when sending 3500 msg/sec
> Sometimes, the main thread_id is freezed.
>
>
> # On the code executed below:
>
>    sended = run_batch();
>
>    info(0," mark#1 ");
>
>    /* avoid exiting before sending all msgs */
>    while(sended > counter_value(counter)) {
>        info(0," mark#2 ");
>        gwthread_sleep(0.1);
>    }
>
>
> # i got this:
>
> 2009-04-17 11:31:55.0720 [22720] [0] DEBUG: message length 130,  
> sending 1 messages
> 2009-04-17 11:31:55.0720 [22720] [0] DEBUG: message length 130,  
> sending 1 messages
> 2009-04-17 11:31:55.0720 [22720] [0] DEBUG: message length 130,  
> sending 1 messages
> 2009-04-17 11:31:55.0721 [22720] [0] DEBUG: message length 130,  
> sending 1 messages
> 2009-04-17 11:31:55.0721 [22720] [0] INFO: mtbatch has processed 999  
> messages with 0 errors
> 2009-04-17 11:31:55.0721 [22720] [0] INFO:  mark#1
> 2009-04-17 11:31:55.0721 [22720] [0] INFO:  mark#2
> (freezed)
> ^C
>
>
>
>
> Alexander Malysh a écrit :
>> Hi,
>> I don't get it, why this patch is needed? Could you please describe  
>> in detail?
>> Thanks,
>> Alex
>> Am 16.04.2009 um 12:36 schrieb Vincent CHAVANIS:
>>>
>>> - When main thread is sleeping and receiving data by bearerbox,
>>> we will be into an infinite loop.
>>>
>>> This patch fix this by waking-up the main thread.
>>>
>>> Vincent.
>>>
>>>
>
>
mtbatch-freeze.diff (application/octet-stream, 530 B)
diff --git a/utils/mtbatch.c b/utils/mtbatch.c
index 761f2a0..5779e56 100644
--- a/utils/mtbatch.c
+++ b/utils/mtbatch.c
@@ -146,8 +146,9 @@ static void read_messages_from_bearerbox(void *arg)
     start = t = time(NULL);
     while (program_status != shutting_down) {
         int ret;
+
         /* block infinite for reading messages */
-        ret = read_from_bearerbox(&msg, INFINITE_TIME);
+        ret = read_from_bearerbox(&msg, 0.5);
         if (ret == -1)
             break;
         else if (ret == 1) /* timeout */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.