From 292e73a08c3445b4aa96057e559dbcec44b0d8f7 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 27 Sep 2013 22:48:56 +0200 Subject: make gsmd fail if the serial device disappears If the serial device disappears (e.g. because of a USB bus reset), there's no point continuing. We simply exit() gsmd and wait for somebody else (init?) to re-spawn us. --- src/gsmd/atcmd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gsmd/atcmd.c b/src/gsmd/atcmd.c index faa91f3..3d4fe4b 100644 --- a/src/gsmd/atcmd.c +++ b/src/gsmd/atcmd.c @@ -492,9 +492,10 @@ static int atcmd_select_cb(int fd, unsigned int what, void *data) if (len < 0) { if (errno == EAGAIN) return 0; - gsmd_log(GSMD_NOTICE, "ERROR reading from fd %u: %d (%s)\n", fd, len, + gsmd_log(GSMD_FATAL, "ERROR reading from fd %u: %d (%s)\n", fd, len, strerror(errno)); return len; + exit(3); } rc = llparse_string(&g->llp, rxbuf, len); if (rc < 0) { @@ -518,8 +519,9 @@ static int atcmd_select_cb(int fd, unsigned int what, void *data) gsmd_log(GSMD_ERROR, "write returns 0, aborting\n"); break; } else if (rc < 0) { - gsmd_log(GSMD_ERROR, "error during write to fd %d: %d\n", + gsmd_log(GSMD_FATAL, "error during write to fd %d: %d\n", fd, rc); + exit(3); return rc; } if (!cr || rc == len) -- cgit v1.2.3