--- gpsd-2.25/gpsd.c-orig 2005-05-30 00:00:33.405661560 -0700 +++ gpsd-2.25/gpsd.c 2005-05-29 23:58:20.778823904 -0700 @@ -1031,6 +1031,21 @@ FD_CLR(msock, &rfds); } + /* read any commands that came in over control sockets */ + for (cfd = 0; cfd < FD_SETSIZE; cfd++) + if (FD_ISSET(cfd, &control_fds)) { + char buf[BUFSIZ]; + + while (read(cfd, buf, sizeof(buf)-1) > 0) { + gpsd_report(1, "<= control(%d): %s\n", cfd, buf); + handle_control(cfd, buf); + } + close(cfd); + FD_CLR(cfd, &all_fds); + FD_CLR(cfd, &control_fds); + } + + /* also be open to new control-socket connections */ if (csock > -1 && FD_ISSET(csock, &rfds)) { socklen_t alen = sizeof(fsin); @@ -1050,20 +1065,6 @@ FD_CLR(csock, &rfds); } - /* read any commands that came in over control sockets */ - for (cfd = 0; cfd < FD_SETSIZE; cfd++) - if (FD_ISSET(cfd, &control_fds)) { - char buf[BUFSIZ]; - - while (read(cfd, buf, sizeof(buf)-1) > 0) { - gpsd_report(1, "<= control(%d): %s\n", cfd, buf); - handle_control(cfd, buf); - } - close(cfd); - FD_CLR(cfd, &all_fds); - FD_CLR(cfd, &control_fds); - } - /* poll all active devices */ for (channel = channels; channel < channels + MAXDEVICES; channel++) { struct gps_device_t *device = *channel;