gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] gpsd doesn't terminate but crash with a SIGINT.


From: Nuno Gonçalves
Subject: Re: [gpsd-dev] gpsd doesn't terminate but crash with a SIGINT.
Date: Thu, 16 Jun 2016 20:42:47 +0100

I think it should exit.

I have another case where I believe it must exit, and it doesn't.

I start gpsd with a single TCP device and if the connection eventually
fails GPSD complains but never recovers:

gpsd:DATA: tcp://127.0.0.1:8999 returned zero bytes
gpsd:DATA: tcp://127.0.0.1:8999 will be repolled in 0.010000 seconds

The exact same thing with some catrastrofic error, like unplugging a
USB-serial adapter:

gpsd:DATA: /dev/ttyUSB0 returned zero bytes
gpsd:DATA: /dev/ttyUSB0 will be repolled in 0.010000 seconds

I'm not sure how to (1) check the device is no longer available, (2)
decide if we can still continue without that device (3) exit
otherwise.

If you can give me some light I can try to make a patch.

Thanks,
Nuno

On Wed, Jun 15, 2016 at 3:01 AM, Gary E. Miller <address@hidden> wrote:
> Yo Nuno!
>
> Patch applied.  In git head now.  I suspect this might solve some
> unexplained error reports.
>
> Basically it prevets gpsd daemonizing when a bad device is given on the
> command line:  gpsd -n /dev/ttyXXX
>
> Here would be an intersting case to think about:
>         # gpsd -n /dev/ttyXX /dev/ttyS0
>
> where /dev/ttyXX oes not exist but /dev/ttyS0 does.  Right now it
> silently daemonizes with just /dev/ttyS0.  Maybe it should also exit?
>
> On Mon, 13 Jun 2016 01:31:04 +0100
> Nuno Gonçalves <address@hidden> wrote:
>
>> And sorry but it had a mistake. Please check this. (diff also in
>> attach).
>>
>> diff --git a/gpsd.c b/gpsd.c
>> index d98d446..a70b31c 100644
>> --- a/gpsd.c
>> +++ b/gpsd.c
>> @@ -1839,6 +1839,7 @@ int main(int argc, char *argv[])
>>      struct gps_device_t *device;
>>      int i, option;
>>      int msocks[2] = {-1, -1};
>> +    bool device_opened = false;
>>      bool go_background = true;
>>      volatile bool in_restart;
>>
>> @@ -2057,9 +2058,25 @@ int main(int argc, char *argv[])
>>             gpsd_log(&context.errout, LOG_ERROR,
>>                      "initial GPS device %s open failed\n",
>>                      argv[i]);
>> +       } else {
>> +            device_opened = true;
>>         }
>>      }
>>
>> +    if (
>> +#ifdef CONTROL_SOCKET_ENABLE
>> +       control_socket == NULL &&
>> +#endif
>> +#ifdef SYSTEMD_ENABLE
>> +       sd_socket_count <= 0 &&
>> +#endif
>> +       !device_opened) {
>> +       gpsd_log(&context.errout, LOG_ERROR,
>> +                "can't run with neither control socket nor devices
>> open\n");
>> +       exit(EXIT_FAILURE);
>> +    }
>> +
>> +
>>      /* drop privileges */
>>      if (0 == getuid()) {
>>         struct passwd *pw;
>>
>> Thanks,
>> Nuno
>>
>> On Sun, Jun 12, 2016 at 11:18 PM, Nuno Gonçalves <address@hidden>
>> wrote:
>> > Any chance to give a look at this?
>> >
>> > I refreshed the patch:
>> >
>> > diff --git a/gpsd.c b/gpsd.c
>> > index d98d446..1521045 100644
>> > --- a/gpsd.c
>> > +++ b/gpsd.c
>> > @@ -1839,6 +1839,7 @@ int main(int argc, char *argv[])
>> >      struct gps_device_t *device;
>> >      int i, option;
>> >      int msocks[2] = {-1, -1};
>> > +    bool device_opened = false;
>> >      bool go_background = true;
>> >      volatile bool in_restart;
>> >
>> > @@ -2057,9 +2058,28 @@ int main(int argc, char *argv[])
>> >             gpsd_log(&context.errout, LOG_ERROR,
>> >                      "initial GPS device %s open failed\n",
>> >                      argv[i]);
>> > +       } else {
>> > +            device_opened = true;
>> >         }
>> >      }
>> >
>> > +    if (
>> > +#ifdef CONTROL_SOCKET_ENABLE
>> > +       control_socket == NULL
>> > +#endif
>> > +#if defined(CONTROL_SOCKET_ENABLE) && defined(SYSTEMD_ENABLE)
>> > +       &&
>> > +#endif
>> > +#ifdef SYSTEMD_ENABLE
>> > +       sd_socket_count <= 0
>> > +#endif
>> > +       && !device_opened) {
>> > +       gpsd_log(&context.errout, LOG_ERROR,
>> > +                "can't run with neither control socket nor devices
>> > open\n");
>> > +       exit(EXIT_FAILURE);
>> > +    }
>> > +
>> > +
>> >      /* drop privileges */
>> >      if (0 == getuid()) {
>> >         struct passwd *pw;
>> >
>> > Thanks,
>> > Nuno
>> >
>> > On Thu, Apr 14, 2016 at 2:14 AM, Nuno Gonçalves <address@hidden>
>> > wrote:
>> >> On Thu, Apr 14, 2016 at 1:53 AM, Gary E. Miller <address@hidden>
>> >> wrote:
>> >>> Yo Nuno!
>> >>>
>> >>> You say:
>> >>>
>> >>>> +                "can't run with no devices open\n");
>> >>>
>> >>> But, gpsd can run with no devices opened, if started with the -F
>> >>> control-socket option.  Does your patch allow for that?
>> >>
>> >> I believe this would:
>> >>
>> >> --- a/gpsd.c
>> >> +++ b/gpsd.c
>> >> @@ -1835,6 +1835,7 @@ int main(int argc, char *argv[])
>> >>      struct gps_device_t *device;
>> >>      int i, option;
>> >>      int msocks[2] = {-1, -1};
>> >> +    bool device_opened = false;
>> >>      bool go_background = true;
>> >>      volatile bool in_restart;
>> >>
>> >> @@ -2053,9 +2054,27 @@ int main(int argc, char *argv[])
>> >>             gpsd_log(&context.errout, LOG_ERROR,
>> >>                      "initial GPS device %s open failed\n",
>> >>                      argv[i]);
>> >> +       } else {
>> >> +           device_opened = true;
>> >>         }
>> >>      }
>> >>
>> >> +    if (
>> >> +#ifdef CONTROL_SOCKET_ENABLE
>> >> +       control_socket == NULL
>> >> +#endif
>> >> +#if defined(CONTROL_SOCKET_ENABLE) && defined(SYSTEMD_ENABLE)
>> >> +       &&
>> >> +#endif
>> >> +#ifdef SYSTEMD_ENABLE
>> >> +       sd_socket_count <= 0
>> >> +#endif
>> >> +       && !device_opened) {
>> >> +       gpsd_log(&context.errout, LOG_ERROR,
>> >> +                "can't run with neither control socket nor
>> >> devices open\n");
>> >> +       exit(EXIT_FAILURE);
>> >> +    }
>> >> +
>> >>      /* drop privileges */
>> >>      if (0 == getuid()) {
>> >>         struct passwd *pw;
>
>
>
>
> RGDS
> GARY
> ---------------------------------------------------------------------------
> Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
>         address@hidden  Tel:+1 541 382 8588



reply via email to

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