diff options
author | Andreas Ludviksen <andreas.e.ludviksen@stericsson.com> | 2011-05-24 02:08:56 -0700 |
---|---|---|
committer | Sverre Vegge <sverre.vegge@stericsson.com> | 2011-08-02 22:04:53 +0200 |
commit | f2d38a91471103da2ff67ff85525c6f8b6b5e406 (patch) | |
tree | 08ebf7c57c017d55c511d91c9f130a2f8e9a5a67 | |
parent | 0d5d3c3e55e201a5bcb29d4612494637c754e77a (diff) | |
download | u300-f2d38a91471103da2ff67ff85525c6f8b6b5e406.tar.gz |
Generic: Restart modem and try again if connecting to socket fails
Check return value from the connect() call on CAIF and UNIX sockets
and restart modem and start init process over again if the connect
fails.
Signed-off-by: Sverre Vegge <sverre.vegge@stericsson.com>
-rw-r--r-- | u300-ril.c | 41 |
1 files changed, 25 insertions, 16 deletions
@@ -1755,8 +1755,7 @@ void *queueRunner(void *param) while (fd < 0) { if (queueArgs->type == NULL) { LOGE("%s(): Unsupported channel type. Bailing out!", __func__); - free(queueArgs); - return NULL; + goto error; } if (!strncmp(queueArgs->type, "CAIF", 4)) { @@ -1780,14 +1779,15 @@ void *queueRunner(void *param) __func__, errno, strerror(-errno)); ret = connect(fd, (struct sockaddr *) &addr, sizeof(addr)); - if (ret != 0) + if (ret != 0) { LOGE("%s(): Failed to connect. errno: %d(%s).", __func__, errno, strerror(-errno)); + goto error; + } #else LOGE("%s(): Unsupported channel type CAIF. Bailing out!", __func__); - free(queueArgs); - return NULL; + goto error; #endif } else if (!strncmp(queueArgs->type, "UNIX", 4)) { struct sockaddr_un addr; @@ -1795,8 +1795,7 @@ void *queueRunner(void *param) if (queueArgs->arg == NULL) { LOGE("%s(): No path specified for UNIX socket!" " Bailing out!", __func__); - free(queueArgs); - return NULL; + goto error; } bzero((char *) &addr, sizeof(addr)); addr.sun_family = AF_UNIX; @@ -1805,14 +1804,18 @@ void *queueRunner(void *param) sizeof(addr.sun_path)); len = strlen(addr.sun_path) + sizeof(addr.sun_family); fd = socket(AF_UNIX, SOCK_STREAM, 0); - (void)connect(fd, (struct sockaddr *) &addr, len); + ret = connect(fd, (struct sockaddr *) &addr, len); + if (ret != 0) { + LOGE("%s(): Failed to connect. errno: %d(%s).", __func__, + errno, strerror(-errno)); + goto error; + } } else if (!strncmp(queueArgs->type, "IP", 2)) { int port; if (!queueArgs->arg) { LOGE("%s(): No port specified for IP socket! " "Bailing out!", __func__); - free(queueArgs); - return NULL; + goto error; } port = atoi(queueArgs->arg); if (queueArgs->xarg) { @@ -1848,7 +1851,7 @@ void *queueRunner(void *param) if (ret < 0) { LOGE("%s(): AT error %d on at_open!", __func__, ret); - goto exit; + goto error; } at_set_on_reader_closed(onATReaderClosed); @@ -1856,7 +1859,7 @@ void *queueRunner(void *param) if (!initializeCommon()) { LOGE("%s(): initializeCommon() failed!", __func__); - goto exit; + goto error; } q = queueArgs->group->requestQueue; @@ -1866,7 +1869,7 @@ void *queueRunner(void *param) if (!initializeDefault()) { LOGE("%s() failed to initialize default AT channel!", __func__); - goto exit; + goto error; } at_make_default_channel(); } @@ -1888,7 +1891,7 @@ void *queueRunner(void *param) LOGE("%s() failed to take queue mutex: %s!", __func__, strerror(err)); /* Need to restart all threads and restart modem.*/ - break; + goto error; } if (q->closed != 0) { @@ -1957,6 +1960,13 @@ void *queueRunner(void *param) } } + goto exit; + +error: + signalCloseQueues(); + +exit: + /* Final cleanup of queues. Radio state must be unavailable at this point */ assert(s_state == RADIO_STATE_UNAVAILABLE); @@ -1988,8 +1998,7 @@ void *queueRunner(void *param) LOGI("%s() index %d finished flushing, queues emptied", __func__, queueArgs->index); -exit: - /* Make sure A channel is closed in case queueRunner triggered the exit */ + /* Make sure AT channel is closed in case queueRunner triggered the exit */ at_close(); /* * Finally signal RIL Manager that this queueRunner and |