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/gerrit-log@lists.osmocom.org/.
Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/7649
socket.c: osmo_sock_init: Several logic fixes and log improvements
See explanations in previous commit.
Change-Id: I4889e777d8627fdfb52c97ab3ab353b6ed34aab2
---
M src/socket.c
1 file changed, 16 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/49/7649/1
diff --git a/src/socket.c b/src/socket.c
index 0e0aa24..d96f664 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -339,8 +339,10 @@
if (flags & OSMO_SOCK_F_CONNECT) {
rc = connect(sfd, rp->ai_addr, rp->ai_addrlen);
- if (rc != -1 || (rc == -1 && errno == EINPROGRESS))
- break;
+ if (rc != 0 && errno != EINPROGRESS) {
+ close(sfd);
+ continue;
+ }
} else {
rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR,
&on, sizeof(on));
@@ -349,18 +351,24 @@
"cannot setsockopt socket:"
" %s:%u: %s\n",
host, port, strerror(errno));
- break;
+ close(sfd);
+ continue;
}
- if (bind(sfd, rp->ai_addr, rp->ai_addrlen) != -1)
- break;
+ if (bind(sfd, rp->ai_addr, rp->ai_addrlen) == -1) {
+ LOGP(DLGLOBAL, LOGL_ERROR, "unable to bind socket:"
+ "%s:%u: %s\n",
+ host, port, strerror(errno));
+ close(sfd);
+ continue;
+ }
}
- close(sfd);
+ break;
}
freeaddrinfo(result);
if (rp == NULL) {
- LOGP(DLGLOBAL, LOGL_ERROR, "unable to connect/bind socket: %s:%u: %s\n",
- host, port, strerror(errno));
+ LOGP(DLGLOBAL, LOGL_ERROR, "no suitable addr found for: %s:%u\n",
+ host, port);
return -ENODEV;
}
--
To view, visit https://gerrit.osmocom.org/7649
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4889e777d8627fdfb52c97ab3ab353b6ed34aab2
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>