summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-10-18 15:29:06 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-10-18 15:29:06 -0400
commit7b7ed90176e8ab19b039285398cde2f04ac076df (patch)
tree480a7cbe7882b2083086f5f867689d282d710a2f /gpsd.c
parentbcd1084e6efdb66d5d3d9144c9384a329e7a9fd1 (diff)
downloadgpsd-7b7ed90176e8ab19b039285398cde2f04ac076df.tar.gz
Thread-lock the code for writing JSON to clients...
...which means it can be called safely from both the main and PPS-handling threads. All regression testts pass.
Diffstat (limited to 'gpsd.c')
-rw-r--r--gpsd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gpsd.c b/gpsd.c
index e6ce089a..d086d23d 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -601,7 +601,14 @@ static ssize_t throttled_write(struct subscriber_t *sub, char *buf,
}
}
+#if defined(PPS_ENABLE)
+ gpsd_acquire_reporting_lock();
+#endif /* PPS_ENABLE */
status = send(sub->fd, buf, len, 0);
+#if defined(PPS_ENABLE)
+ gpsd_release_reporting_lock();
+
+#endif /* PPS_ENABLE */
if (status == (ssize_t) len)
return status;
else if (status > -1) {