>The one imediate problem I can think off is if you are running several
 >instances of pppd and pppoa for multiple modems. Does anyone actually do
 >that? It will mean people with that configuration may have to mess 
with scripts instead.

We can create a range of semaphores like that :
#define SEM_KEY_MAKER(modem) \
((unsigned long)(('M'<<24)|('D'<<16)|('M'<<8)|(modem)))

and then when trying to grab the semaphore, you call this macro with 
modem_id argument.

We have just to document the semaphores we use to prevent some 
incompatibilities between our driver and other software which uses 
semaphores. (0xcafedeca in pppoa2, none in pppoa3 yet)

We limit the pppoa3 usage up to 256 modems, i think we will never have 
256 USB modems on the same machine :-)

 > My solution description :
 >
 >
 > 1 - start
 >
 > 2 - creates an IPC semaphore with  semget (and PC_CREAT|IPC_EXCL)
 >     if the semaphore already exists, the semget returns -1 and
 >     sets errno to EAGAIN so we know another instance has not cleanly
 >     exited (or is still running).
 >
 >    21 - if "--clean|-c" option has been specified then :
 >
 >       210 - open the pidfile and read the previous instance pid
 >       211 - kill the process group (the process and all threads)


A kill(-pid, SIGTERM); does the job well on GNU/Liinux systems (we 
simulate the pppd SIGTERM signal).


 >       212 - grab the semaphore so this process is sleeping untill
 >             the previous instance releases the semaphore


I forgot this step
         212 and half - release the semaphore


 >       213 - destroy the semaphore (since we can't know the old
 >             instance has already destroyed it)
 >       213 - repeat the semaphore creation, but this time we are
 >             sure to be able to create it because :
 >                - the old instance tried to delete it
 >                - this instance tried to delete it too
 >
 > 3 - Grab the semaphore
 > 4 - create the pid file...(O_CREAT|O_TRUNC), writes the pid in it
 > 5 - do normal job (threads read/write/pipe ...)
 > 6 - unlink pid file
 > 7 - release the semaphore
 > 8 - destroy the semaphore
 > 9 - exit
 >


 >
 > NB : we can use the smallsem lib included in the driver package to
 > implement this solution.
 >


Obviously, the pppoa3 file size will grow...

Edouard Gomez



Liste de diffusion modem ALCATEL SpeedTouch USB
Pour se d�sinscrire : mailto:[EMAIL PROTECTED]?subject=unsubscribe

        

Reply via email to