gpsd-dev
[Top][All Lists]
Advanced

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

Re: [gpsd-dev] stuck in consume_packets/multipoll loop


From: Bernd Ocklin
Subject: Re: [gpsd-dev] stuck in consume_packets/multipoll loop
Date: Wed, 20 Nov 2013 17:43:39 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2

On 11/20/2013 03:36 PM, Eric S. Raymond wrote:
This is way too intrusive a change to even think about just before
release.  Please do this, though.  Ship me a patch with three features:

1. Inserts the "give other devices a chance" code at what you think is
    the right spot.

2. Includes a detailed comment explaining why the code is a good idea.

3. Important! The hole patch is wrapped with #ifdef __future__/#endif

That way I can apply it and we can study it in situ without committing
to use it in production code.
Hope this looks okay.


diff --git a/libgpsd_core.c b/libgpsd_core.c
index a8687df..68f36c1 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -1548,6 +1548,18 @@ int gpsd_multipoll(const bool data_ready,
            /* handle data contained in this packet */
            if (device->packet.type != BAD_PACKET)
                /address@hidden@*/handler(device, changed);
+
+#ifdef __future__
+           /* Exit when a full packet was received and parsed.
+            * This allows other devices to be serviced even if
+            * this device delivers a full packet at every single
+            * read.
+            * Otherwise we can sit here for a long time without
+            * any for-loop exit condition being met.
+            */
+           if (changed & PACKET_SET)
+               break;
+#endif // __future__
        }
     }
     else if (device->reawake>0 && timestamp()>device->reawake) {


I think its better to exit the poll loop after each fully read and parsed package. Allowing to poll devices in a more fair round-robin fashion.

Thanks for looking at it,
Bernd




reply via email to

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