Re: thread safe usage of multiple phones
Pawel Kot <[email protected]> Sun, 14 May 2017 13:29:53 +0200
| Newsgroups | gmane.linux.drivers.gnokii |
|---|---|
| Message-ID | <CAHytCw7Ds8yCD+QGvn3G+iz6px7w=ws+YOwhx=mgbOqhgVkw=A@mail.gmail.com> |
Hi Peter, On Sun, May 14, 2017 at 9:31 AM, Peter Koch <[email protected]> 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