[Top][All Lists]

[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: Tue, 18 Apr 2017 14:56:43 +0200

Hi Peter,

On Sat, Apr 15, 2017 at 12:45 PM, Peter Koch <address@hidden> wrote:
> I'm using libgnokii for a very long time to sent certain log messages via SMS
> to our administrators. A multithreaded application receives log messages
> from different sources and stores them into our database. Urgent messages
> will also be sent via SMS to our administrators.

Well, for me personally it is quite nice surprise that in the age of
smartphones and API to everything gnokii is still being used :)

> Unfortunately the single Nokia 6310 phone (connected via serial cable)
> has become a perfomance bottleneck and we are planning to use 5 Nokia 6230i
> (connected via USB) instead.
> Right now the daemon has one thread that sends out SMS and I would
> like to start 4 more threads that will do the SMS-sending in parallel.

I do not know how it would behave right now but years ago USB link was
much less reliable than serial one. To translate it to actions: it
required restarting gnokii or even phone sometimes.

> I'm afraight not all libgnokii routines are thread-safe. gn_cfg_info and
> gn_gsm_info are two global variables that prevent concurrent usage of
> at least gn_lib_phoneprofile_load_from_file(). But that's not a problem
> since initialization of the phones can be done non-concurrent.

I think these are deprecated so that should be no problem - there is a
way to deal without them.

> But what about gn_sms_send()? The whole idea is to call this routine
> concurrently with 5 phones.

I have looked quickly into the code. In gsm-sms.c just
sms_timestamp_print() seems to be thread non-safe (just in DEBUG mode)

> Can I call gn_sms_send(data1, state1) and gn_sms_send(data2, state2)
> in two threads?

If you do the preparation by yourself, I think that would work fine.
But it would be the best just to try it out. Looks like 1-day

> Here's a short summary of what I'm planning to do:
> In main thread:
> ----------------------------------------------------------------------
> for(i=0; i<max; ++i){
>   gn_lib_phoneprofile_load_from_file("gnokiirc", configname[i], &state[i]);
>   gn_lib_phone_open(state[i]);
> }
> for(i=0; i<max; ++i){
>   start_separate_thread(&state[i]);
> }
> In separate threads:
> ----------------------------------------------------------------------
> for(;;){
>   wait_for_sms();

To you know how to dinstinguish between phones? One queue or multiple queues?

>   get_sms_from_queue(&data);
>   gn_sms_send(data, &state);
> }
> Any ideas or suggestions?

The easiest way (that is using gnokii in non-modified form) would be
to run multiple gnokii (or smsd) instances. And then feed them with
round-robin or so.

take care,

reply via email to

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