summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-03-25 15:01:49 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-03-25 15:01:49 -0400
commita2c2a595f2588a53b7c804e688f459e8a1c5efaf (patch)
tree687479fc101d84a38a52736bcc3e8ba3df3c4752 /gpsd.c
parent398195bc3ec704e1deb6281418bb5ed97ef7c0fe (diff)
downloadgpsd-a2c2a595f2588a53b7c804e688f459e8a1c5efaf.tar.gz
First cut at shared-memory export. Daemon-side only.
Not configured in by default yet because it produces a strange regression failure.
Diffstat (limited to 'gpsd.c')
-rw-r--r--gpsd.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gpsd.c b/gpsd.c
index f494dee9..c9cb79b6 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1507,6 +1507,12 @@ static void consume_packets(struct gps_device_t *device)
#endif /* DBUS_EXPORT_ENABLE */
}
+#ifdef SHM_EXPORT_ENABLE
+ if ((changed & (REPORT_IS|NOISE_IS|SATELLITE_IS|SUBFRAME_IS|
+ ATT_IS|RTCM2_IS|RTCM3_IS|AIS_IS)) != 0)
+ shm_update(&context, &device->gpsdata);
+#endif /* DBUS_EXPORT_ENABLE */
+
#ifdef SOCKET_EXPORT_ENABLE
/* update all subscribers associated with this device */
for (sub = subscribers; sub < subscribers + MAXSUBSCRIBERS; sub++) {
@@ -1854,6 +1860,14 @@ int main(int argc, char *argv[])
"successfully connected to the DBUS system bus\n");
#endif /* DBUS_EXPORT_ENABLE */
+#ifdef SHM_EXPORT_ENABLE
+ /* create the shared segment as root so readers can't mess with it */
+ if (!shm_acquire(&context)) {
+ gpsd_report(LOG_ERROR, "shared-segment creation failed,\n");
+ } else
+ gpsd_report(LOG_PROG, "shared-segment creation succeeded,\n");
+#endif /* DBUS_EXPORT_ENABLE */
+
if (getuid() == 0 && go_background) {
struct passwd *pw;
struct stat stb;
@@ -2223,6 +2237,10 @@ int main(int argc, char *argv[])
}
#endif /* SOCKET_EXPORT_ENABLE */
+#ifdef SHM_EXPORT_ENABLE
+ shm_release(&context);
+#endif /* DBUS_EXPORT_ENABLE */
+
if (control_socket)
(void)unlink(control_socket);
if (pid_file)