diff --git a/gpsd/libgpsd_core.c b/gpsd/libgpsd_core.c index 37fdc928a..38a51b18d 100644 --- a/gpsd/libgpsd_core.c +++ b/gpsd/libgpsd_core.c @@ -487,6 +487,8 @@ int parse_uri_dest(char *s, char **host, char **service, char **device) return 0; } +extern bool __attribute__ ((weak)) gpsd_add_device(const char *device_name, + bool flag_nowait); /* open a device for access to its data * * return: the opened file descriptor * PLACEHOLDING_FD - for /dev/ppsX @@ -524,6 +526,12 @@ int gpsd_open(struct gps_device_t *session) GPSD_LOG(LOG_ERROR, &session->context->errout, "TCP device open error %s.\n", netlib_errstr(dsock)); + /* this connection will be freed, to retry we need to add back a cloned device */ + if (gpsd_add_device != NULL) { + GPSD_LOG(LOG_INF, &session->context->errout, + "retry TCP feed at %s, port %s.\n", host, port); + (void) gpsd_add_device(session->gpsdata.dev.path, false); + } return -1; } else GPSD_LOG(LOG_SPIN, &session->context->errout,