[Top][All Lists]

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

Re: [gpsd-users] Shared memory interface with gpsd restart results in no

From: Gary E. Miller
Subject: Re: [gpsd-users] Shared memory interface with gpsd restart results in no data for client
Date: Fri, 15 Jun 2018 15:31:02 -0700

Yo Michael!

On Fri, 15 Jun 2018 15:09:31 -0700
Michael Lum <address@hidden> wrote:

> For anyone interested I verified the following problems:
> (I'm using C++)
> 1.  the static tick in shmexport.c does not work if gpsd is restarted
> (at least with a client attached to the shared memory)

NONE of the gpsd clients survive a gpsd restart.  Been working on that.

> I fixed this in my code by removing the static int tick and adding it
> to the shared memory segment and having shm_update() using the value
> to set the bookends.
> struct shmexport_t
> {
>     int tick;
>     int bookend1;
>     struct gps_data_t gpsdata;
>     int bookend2;
> };
> shared->bookend2 = shared->tick++;

Interesting idea.  Send us a patch whhen you are happy with it.

> 2.  wrap around does not work (needs some more conditions in
> gps_shm_waiting())

What is the symptom?  Does it stop updateing on roll over?

> This was my fix in gps_shm_waiting():
>         if ((bookend1 == bookend2) &&
>             ((bookend1 > PRIVATE(gpsdata)->tick) ||
>                 ((bookend1 < 0) && (PRIVATE(gpsdata)->tick >= 0))))
>             newdata = true;
> It assumes that if bookend1 is negative and the (private/client) tick
> is non-negative then a wrap must have occurred.

I wonder why they are not just unsigned?  That might be a better patch.

> 3.  the 'tick' member needs to be zeroed after the malloc() call

Which malloc() call?  Sounds like bad init on the part of gpsd.

> Occasionally after a gps_read() error the 'tick' value would be
> non-zero after the malloc().

Zero guarantees with malloc().

> In addition, I believe the memory malloc() for the privdata should be
> free'd in gps_shm_close().  (Also for Dbus?)

Only 3 malloc()s in all of the gpsd code.  And 2 fail to free().  Grrr...

> I hope this helps someone else.

Certainly helped me.  Patches would help more.

Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        address@hidden  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can’t measure it, you can’t improve it." - Lord Kelvin

Attachment: pgp1Ua7tcUqZy.pgp
Description: OpenPGP digital signature

reply via email to

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