[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 13:29:53 +0200 |
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