From c22e4adc07305d0ff39756843015be6b092cbcb6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 28 Jan 2015 22:08:49 -0500 Subject: Using SIOCOUTQ to flush output on client socket close caused a hard hang. To replicate the problem: (1) Check out the parent of this revision. (2) Run "gpsd -n -N -D 3 /dev/ttyUSB0" substituting the device as needed. (3) Run the following script in another window: while true do date ./gpspipe -n 3 -R -o /dev/null # hang if gpsd is sick ./gpspipe -d -R -o /dev/null sleep 2 DELAY=$RANDOM # 0-32K #usleep ${DELAY}00 # 0-3 seconds sleep `echo "scale=6; $DELAY / 1000000" | bc` killall gpspipe #ps ax | grep gpspipe done (4) Run gpsmon in a third window. gpsd will hang in 3-5 minutes, requiring kill -9, in the kernal hrtime function. --- gpsd.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/gpsd.c b/gpsd.c index eba0ecea..888dcc16 100644 --- a/gpsd.c +++ b/gpsd.c @@ -41,10 +41,6 @@ #ifndef S_SPLINT_S #include #endif /* S_SPLINT_S */ -#ifdef __linux__ -#include /* needed for ioctl(SIOCOUTQ) */ -#include /* needed for ioctl(SIOCOUTQ) */ -#endif /* __linux__ */ #include "gpsd_config.h" @@ -553,19 +549,6 @@ static void detach_client(struct subscriber_t *sub) } c_ip = netlib_sock2ip(sub->fd); (void)shutdown(sub->fd, SHUT_RDWR); -#ifdef __linux__ - /* - * Delay the socket close that breaks the connection until - * all pending data has shipped. - */ - for(;;) { - int outstanding; - ioctl(sub->fd, SIOCOUTQ, &outstanding); - if (!outstanding) - break; - usleep(1000); - } -#endif gpsd_report(&context.errout, LOG_SPIN, "close(%d) in detach_client()\n", sub->fd); -- cgit v1.2.1