[PATCH 05/11] ipaccess: more robust error handling in the accept patch

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

pablo at gnumonks.org pablo at gnumonks.org
Wed Aug 22 15:04:47 UTC 2012


From: Pablo Neira Ayuso <pablo at gnumonks.org>

Better close the newly established TCP connection to force a
re-establishment.
---
 src/input/ipaccess.c |   28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 31b8f04..c69ae24 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -601,15 +601,22 @@ static int ipaccess_bsc_oml_cb(struct ipa_server_link *link, int fd)
 	ret = osmo_fd_register(bfd);
 	if (ret < 0) {
 		LOGP(DLINP, LOGL_ERROR, "could not register FD\n");
-		close(bfd->fd);
-		e1inp_line_put(line);
-		return ret;
+		goto err;
 	}
 
 	/* Request ID. FIXME: request LOCATION, HW/SW VErsion, Unit Name, Serno */
 	ret = ipaccess_send_id_req(bfd->fd);
+	if (ret < 0) {
+		LOGP(DLINP, LOGL_ERROR, "could not send ID REQ. Reason: %s\n",
+			strerror(errno));
+		goto err;
+	}
 
-        return ret;
+	return ret;
+err:
+	close(bfd->fd);
+	e1inp_line_put(line);
+	return ret;
 }
 
 static int ipaccess_bsc_rsl_cb(struct ipa_server_link *link, int fd)
@@ -645,14 +652,21 @@ static int ipaccess_bsc_rsl_cb(struct ipa_server_link *link, int fd)
 	ret = osmo_fd_register(bfd);
 	if (ret < 0) {
 		LOGP(DLINP, LOGL_ERROR, "could not register FD\n");
-		close(bfd->fd);
-		e1inp_line_put(line);
-		return ret;
+		goto err;
 	}
 	/* Request ID. FIXME: request LOCATION, HW/SW VErsion, Unit Name, Serno */
 	ret = ipaccess_send_id_req(bfd->fd);
+	if (ret < 0) {
+		LOGP(DLINP, LOGL_ERROR, "could not send ID REQ. Reason: %s\n",
+			strerror(errno));
+		goto err;
+	}
 
 	return 0;
+err:
+	close(bfd->fd);
+	e1inp_line_put(line);
+	return ret;
 }
 
 static struct msgb *
-- 
1.7.10.4





More information about the OpenBSC mailing list