Menu

#7 modem_run reports error only by first run

open
nobody
None
5
2004-08-20
2004-08-20
Lukasz Mach
No

If there is some error, for example bad path to
firmware, modem_run reports error to syslog only once.

reproduce:
1. launch linux (be sure that modem_run isn't called in
boot time)
2. run
modem_run -v 1 -f /some/fake/path

modem run will report that /some/fake/path doesn't
exists in /var/log/syslog

3. now, every launch of modem_run will only do such
line in syslog

Aug 20 10:23:22 tereska modem_run[3687]: modem_run
version 1.3 started by root uid 0

and nothing more, no matter if is proper path or not.

I have PLD with glibc 2.3.4 snapshot 20040707, kernel
2.6.7, ppp 2.4.2
speedtouch 1.3. I tried yesterdays cvs snapshot, but
the same result.

Discussion

  • RichB

    RichB - 2004-08-31

    Logged In: YES
    user_id=1114158

    This problem seems to be due to the semaphore stuff used to
    prevent more than one simultaneous instance of modem_run. If
    an instance ends prematurely it leaves the semaphore behind
    so that any subsequent instance thinks that there's already
    a copy running.

    I would try and fix it myself, but I don't know enough about
    Linux semaphores...

     
  • RichB

    RichB - 2004-08-31

    Logged In: YES
    user_id=1114158

    Put the following program in the 'src' directory and compile
    it - I called it "deshag.c".

    try: gcc -o deshag deshag.c

    Run it as root with no command line:
    ./deshag
    and it will tell you if the semaphore exists

    Run it again with -d to delete it:
    ./deshag -d

    This should remove the rogue semaphore so that you can try
    running modem_run again without rebooting.

    #include "mutex.h"
    union semun {
    int val; /* value for SETVAL */
    struct semid_ds *buf; /* buffer for IPC_STAT,
    IPC_SET */
    unsigned short int *array; /* array for GETALL, SETALL */
    struct seminfo *__buf; /* buffer for IPC_INFO */
    };

    int main(int argc, char *argv[]) {
    int semid;
    union semun un;

    semid=semget\(0xdeadbeef, 2, 0666\);
    if \(semid < 0\) \{
        printf\("No modem\_run semaphore found\n"\);
    \} else \{
        if\(argc>1 && \!strcmp\(argv\[1\], "-d"\)\) \{
        printf\("Here goes: %d\n", semctl\(semid, 0, IPC\_RMID, un\)\);
        \} else \{
        printf\("Semaphore seems to exist. Rerun with '-d' to fix.\n"\);
        \}
    \}
    return 0;
    

    }

     
  • Lukasz Mach

    Lukasz Mach - 2004-08-31

    Logged In: YES
    user_id=617333

    smart solution. I'll try it.

    I think better will be if modem_run clean it's semaphores
    when retrning with error.

    anyway do you mind if I add this package to speedtouch rpm
    in PLD Linux Distribution?. if yes, what license, GPL?

     
  • RichB

    RichB - 2004-09-01

    Logged In: YES
    user_id=1114158

    If you're referring to my code snippet, I have no objection
    to you adding it to anything. I hereby renounce any
    copyright in the code. Do with it as you will under whatever
    licence terms suit you.

     
  • Paweł Gl

    Paweł Gl - 2004-09-13

    Logged In: YES
    user_id=1121185

    the problem is that modem_run allocates system-wide
    semaphore and when it crashes it does not free this
    resource. I had same problem and I solved this adding option
    to force reload of firmware. Diff for modem_run.c from
    release 1.3 and my changed file is:
    $diff -b modem_run.c modem_run.c.new
    150a151
    > int reload = 0;
    202a204,205
    > } else if (strcmp(argv[i], "-g") == 0) {
    > reload = 1;
    277a281,283
    > if (reload)
    > do_exit = 0; // force reload of microcode
    > else

    option to force reload as you see is: -g it is very usefull
    for testing purpose.

    Or as root:
    #ipcs
    look for semaphore with key: 0xdeadbeef
    and remove it with:
    ipcrm -s id_of_semaphore

    then restart modem_run.

     
  • Lukasz Mach

    Lukasz Mach - 2004-09-14

    Logged In: YES
    user_id=617333

    great.

    could you sent this patch as unified diff?

    have you sent this patch to developers?

     
  • Paweł Gl

    Paweł Gl - 2004-09-14

    Logged In: YES
    user_id=1121185

    As you wish:

    --- modem_run.c 2004-06-10 18:36:35.000000000 +0200
    +++ modem_run.c.new 2004-09-14 01:32:05.000000000 +0200
    @@ -148,6 +148,7 @@
    char *devicename = NULL;
    const char *user;
    int timeout = 120; /* Wait for 120s before giving up */
    + int reload = 0;
    int polling_interval = 10; /* Polling device state
    interval in seconds */
    int upload_tries = 10;
    stusb_firmware_t *firmware = NULL;
    @@ -200,6 +201,8 @@
    revision = atoi(argv[++i]);
    } else if (strcmp(argv[i], "-s") == 0) {
    dl_512_first = 0;
    + } else if (strcmp(argv[i], "-g") == 0) {
    + reload = 1;
    } else if (strcmp(argv[i], "-t") == 0 &&
    i+1<argc) {
    timeout = atoi(argv[++i]);
    } else if (strcmp(argv[i], "-v") == 0 &&
    i+1<argc) {
    @@ -275,6 +278,9 @@
    break;

    case S_LINE_OK:
    + if (reload)
    + do_exit = 0; /* force reload of microcode */
    + else
    do_exit = 1;
    do_exit_code = 0;
    break;

    I'm quite new on sourceforge so I leave developers for you. :-)

     

Log in to post a comment.