[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gpsd-commit-watch
Subject:    [Gpsd-commit-watch] Project gpsd at BerliOS branch, master,
From:       gpsd-dev () lists ! berlios ! de
Date:       2010-04-26 21:58:10
Message-ID: 201004262158.o3QLwAHV024976 () sheep ! berlios ! de
[Download RAW message or body]

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Project gpsd at BerliOS".

The branch, master has been updated
       via  89d07e0c1c1b2dc5016f9943ca2e11168c7b9e04 (commit)
       via  6605fa3b7fac3012ca0b93fd7db776f72b0edcc0 (commit)
      from  fe7a28383534654b3c2a0dfa323db4e4c5732c75 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 89d07e0c1c1b2dc5016f9943ca2e11168c7b9e04
Author: Eric S. Raymond <esr@thyrsus.com>
Date:   Mon Apr 26 17:57:23 2010 -0400

    Rearrange some code for clarity. All regression tests pass.

diff --git a/gpsd.c b/gpsd.c
index c2e2766..87dbc4e 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1595,6 +1595,7 @@ int main(int argc, char *argv[])
 		context.dsock = -1;
 	    }
 	}
+
 	/* read any commands that came in over control sockets */
 	for (cfd = 0; cfd < FD_SETSIZE; cfd++)
 	    if (FD_ISSET(cfd, &control_fds)) {
@@ -1646,7 +1647,7 @@ int main(int argc, char *argv[])
 		if ((changed & PACKET_IS) == 0)
 		    continue;
 
-		/* add any just-idebtifuied device to watcher lists */
+		/* add any just-identified device to watcher lists */
 		if ((changed & DRIVER_IS) != 0) {
 		    bool listeners = false;
 		    for (sub = subscribers;
@@ -1669,6 +1670,25 @@ int main(int argc, char *argv[])
 		    }
 		}
 
+		if (device->gpsdata.fix.mode == MODE_3D)
+		    netgnss_report(device);
+
+		/* *INDENT-OFF* */
+		/* copy each RTCM-104 correction to all GPSes */
+		if ((changed & RTCM2_IS) != 0 || (changed & RTCM3_IS) != 0) {
+		    struct gps_device_t *gps;
+		    for (gps = devices; gps < devices + MAXDEVICES; gps++)
+			if (gps->device_type != NULL
+			    && gps->device_type->rtcm_writer != NULL)
+			    (void)gps->device_type->rtcm_writer(gps,
+								(char *)gps->
+								packet.
+								outbuffer,
+								gps->packet.
+								outbuflen);
+		}
+		/* *INDENT-ON* */
+
 		/* raw hook and relaying functions */
 		for (sub = subscribers; sub < subscribers + MAXSUBSCRIBERS;
 		     sub++) {
@@ -1718,26 +1738,8 @@ int main(int argc, char *argv[])
 		    }
 #endif /* BINARY_ENABLE */
 		    /* *INDENT-ON* */
-		}
-
-		if (device->gpsdata.fix.mode == MODE_3D)
-		    netgnss_report(device);
-		/* *INDENT-OFF* */
-		/* copy each RTCM-104 correction to all GPSes */
-		if ((changed & RTCM2_IS) != 0 || (changed & RTCM3_IS) != 0) {
-		    struct gps_device_t *gps;
-		    for (gps = devices; gps < devices + MAXDEVICES; gps++)
-			if (gps->device_type != NULL
-			    && gps->device_type->rtcm_writer != NULL)
-			    (void)gps->device_type->rtcm_writer(gps,
-								(char *)gps->
-								packet.
-								outbuffer,
-								gps->packet.
-								outbuflen);
-		}
-		/* *INDENT-ON* */
-	    }
+		} /* subscribers */
+	    } /* devices */
 
 	    /* watch all channels associated with this device */
 	    for (sub = subscribers; sub < subscribers + MAXSUBSCRIBERS; sub++) {

commit 6605fa3b7fac3012ca0b93fd7db776f72b0edcc0
Author: Eric S. Raymond <esr@thyrsus.com>
Date:   Mon Apr 26 17:36:59 2010 -0400

    Simplify some dispatcher code, and possibly fix a bug.
    
    The awaken() function doesn't need a subscriber argument.  Move the
    coe for device awakening on identification out from behind a suspcious-
    looking guard.
    
    All regression tests pass.

diff --git a/gpsd.c b/gpsd.c
index d4d7e10..c2e2766 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -710,14 +710,14 @@ static bool add_device(char *device_name)
 /*@ +statictrans @*/
 /*@ +globstate @*/
 
-static bool awaken(struct subscriber_t *user, struct gps_device_t *device)
+static bool awaken(struct gps_device_t *device)
 /* awaken a device and notify all watchers*/
 {
     /* open that device */
     if (!initialized_device(device)) {
 	if (!open_device(device->gpsdata.dev.path)) {
-	    gpsd_report(LOG_PROG, "client(%d): open failed\n",
-			sub_index(user));
+	    gpsd_report(LOG_PROG, "%s: open failed\n", 
+			device->gpsdata.dev.path);
 	    free_device(device);
 	    return false;
 	}
@@ -725,14 +725,15 @@ static bool awaken(struct subscriber_t *user, struct gps_device_t *device)
 
     if (device->gpsdata.gps_fd != -1) {
 	gpsd_report(LOG_PROG,
-		    "client(%d): device %d (fd=%d, path %s) already active.\n",
-		    sub_index(user), (int)(device - devices),
-		    device->gpsdata.gps_fd, device->gpsdata.dev.path);
+		    "device %d (fd=%d, path %s) already active.\n",
+		    (int)(device - devices),
+		    device->gpsdata.gps_fd, 
+		    device->gpsdata.dev.path);
 	return true;
     } else {
 	if (gpsd_activate(device) < 0) {
-	    gpsd_report(LOG_ERROR, "client(%d): device activation failed.\n",
-			sub_index(user));
+	    gpsd_report(LOG_ERROR, "%s: device activation failed.\n",
+		    device->gpsdata.dev.path);
 	    return false;
 	} else {
 	    gpsd_report(LOG_RAW,
@@ -1005,7 +1006,7 @@ static void handle_request(struct subscriber_t *sub,
 		    /* awaken all devices */
 		    for (devp = devices; devp < devices + MAXDEVICES; devp++)
 			if (allocated_device(devp))
-			    (void)awaken(sub, devp);
+			    (void)awaken(devp);
 		} else {
 		    devp = find_device(sub->policy.devpath);
 		    if (devp == NULL) {
@@ -1014,7 +1015,7 @@ static void handle_request(struct subscriber_t *sub,
 				       sub->policy.devpath);
 			gpsd_report(LOG_ERROR, "ERROR response: %s", reply);
 			goto bailout;
-		    } else if (!awaken(sub, devp))
+		    } else if (!awaken(devp))
 			(void)snprintf(reply, replylen,
 				       "{\"class\":\"ERROR\",\"message\":\"Can't assign %s\"}\r\n",
 				       sub->policy.devpath);
@@ -1057,7 +1058,7 @@ static void handle_request(struct subscriber_t *sub,
 	    } else {
 		if (devconf.path[0] != '\0') {
 		    /* user specified a path, try to assign it */
-		    if (!awaken(sub, find_device(devconf.path))) {
+		    if (!awaken(find_device(devconf.path))) {
 			(void)snprintf(reply, replylen,
 				       "{\"class\":\"ERROR\",\"message\":\"Can't open %s.\"}\r\n",
 				       devconf.path);
@@ -1645,6 +1646,29 @@ int main(int argc, char *argv[])
 		if ((changed & PACKET_IS) == 0)
 		    continue;
 
+		/* add any just-idebtifuied device to watcher lists */
+		if ((changed & DRIVER_IS) != 0) {
+		    bool listeners = false;
+		    for (sub = subscribers;
+			 sub < subscribers + MAXSUBSCRIBERS; sub++)
+			if (sub->active != 0
+			    && sub->policy.watcher
+			    && (sub->policy.devpath[0] == '\0' || strcmp(sub->policy.devpath, device->gpsdata.dev.path)==0))
+			    listeners = true;
+		    if (listeners)
+			(void)awaken(device);
+		}
+
+		/* handle laggy response to a firmware version query */
+		if ((changed & (DEVICEID_IS | DRIVER_IS)) != 0) {
+		    assert(device->device_type != NULL);
+		    {
+			char id2[GPS_JSON_RESPONSE_MAX];
+			json_device_dump(device, id2, sizeof(id2));
+			notify_watchers(device, id2);
+		    }
+		}
+
 		/* raw hook and relaying functions */
 		for (sub = subscribers; sub < subscribers + MAXSUBSCRIBERS;
 		     sub++) {
@@ -1698,26 +1722,6 @@ int main(int argc, char *argv[])
 
 		if (device->gpsdata.fix.mode == MODE_3D)
 		    netgnss_report(device);
-
-		else {
-		    /* we may need to add device to new-style watcher lists */
-		    if ((changed & DEVICE_IS) != 0) {
-			for (sub = subscribers;
-			     sub < subscribers + MAXSUBSCRIBERS; sub++)
-			    if (sub->policy.watcher
-				&& sub->policy.devpath[0] == '\0')
-				(void)awaken(sub, device);
-		    }
-		    /* handle laggy response to a firmware version query */
-		    if ((changed & (DEVICEID_IS | DEVICE_IS)) != 0) {
-			assert(device->device_type != NULL);
-			{
-			    char id2[GPS_JSON_RESPONSE_MAX];
-			    json_device_dump(device, id2, sizeof(id2));
-			    notify_watchers(device, id2);
-			}
-		    }
-		}
 		/* *INDENT-OFF* */
 		/* copy each RTCM-104 correction to all GPSes */
 		if ((changed & RTCM2_IS) != 0 || (changed & RTCM3_IS) != 0) {
diff --git a/gpsd.h-tail b/gpsd.h-tail
index fb0c9d9..a750130 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -229,7 +229,7 @@ typedef enum {
 #define RAW_IS  	0x00008000u
 #define USED_IS 	0x00010000u
 #define SPEEDERR_IS	0x00020000u
-#define DEVICE_IS	0x00040000u
+#define DRIVER_IS	0x00040000u
 #define DEVICEID_IS	0x00100000u
 #define ERROR_IS	0x00200000u
 #define RTCM2_IS	0x00400000u
diff --git a/libgpsd_core.c b/libgpsd_core.c
index d45601a..286d369 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -688,13 +688,11 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
 	 * If this is the first time we've achieved sync on this
 	 * device, or the the driver type has changed for any other
 	 * reason, that's a significant event that the caller needs to
-	 * know about.  Using DEVICE_IS this way is a bit shaky but
-	 * we're short of bits in the flag mask (client library uses
-	 * it differently).
+	 * know about.
 	 */
 	if (first_sync || session->notify_clients) {
 	    session->notify_clients = false;
-	    received |= DEVICE_IS;
+	    received |= DRIVER_IS;
 	}
 
 	/* Get data from current packet into the fix structure */

-----------------------------------------------------------------------

Summary of changes:
 gpsd.c         |  108 +++++++++++++++++++++++++++++--------------------------
 gpsd.h-tail    |    2 +-
 libgpsd_core.c |    6 +--
 3 files changed, 60 insertions(+), 56 deletions(-)


hooks/post-receive
-- 
Project gpsd at BerliOS
_______________________________________________
Gpsd-commit-watch mailing list
Gpsd-commit-watch@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/gpsd-commit-watch
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic