gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: thread safe usage of multiple phones


From: Pawel Kot
Subject: Re: thread safe usage of multiple phones
Date: Sun, 14 May 2017 20:53:09 +0200

Well, it looks like the solution I have implemented was quite dumb.
This static variable was really not necessary (however it made
solution simpler). Can you please try the attached patch and say
whether it works for you? It is against git version.

take care,
Pawel

On Sun, May 14, 2017 at 1:29 PM, Pawel Kot <address@hidden> wrote:
> Hi Peter,
>
> On Sun, May 14, 2017 at 9:31 AM, Peter Koch <address@hidden> wrote:
>> Have a look at routine verify_max_message_len() in
>> common/links/fbus-phonet.c, starting at line 64
>
> Yeah, that makes sense. I have reviewed just statemachine and sms
> code. And they seem thread safe. I have forgotten the link code. It
> indeed assumes communication with one device.
>
>> Of course this only happens when the phonet-driver is used, so my
>> serial nokia 6310 works fine.
>
> I will have a closer look.
>
>> static int verify_max_message_len(int len, char **message_buffer)
>> {
>>         static int max_message_len = 0;
>>
>>         if(len<PHONET_FRAME_MAX_LENGTH) len=PHONET_FRAME_MAX_LENGTH;
>>         if(len>PHONET_FRAME_MAX_LENGTH || !*message_buffer){
>>                 dprintf("reallocating message_buffer to %d bytes\n", len+1);
>>                 *message_buffer = realloc(*message_buffer, len+1);
>>         }
>>         return *message_buffer ? len+1 : 0;
>
> Quite frankly at the moment I'm not sure why would it work.
>
>>         if (len > max_message_len) {
>>                 dprintf("overrun: %d %d\n", len, max_message_len);
>>                 *message_buffer = realloc(*message_buffer, len + 1);
>>                 max_message_len = len + 1;
>>         }
>>         if (*message_buffer)
>>                 return max_message_len;
>>         else
>>                 return 0;
>> }
>
> Take care,
> Pawel



-- 
Pawel Kot

Attachment: fbusphonet.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]