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/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/23985 ) Change subject: osmo_sock_*_ofd(): Mark OSMO_FD_WRITE on non-blocking connect() ...................................................................... osmo_sock_*_ofd(): Mark OSMO_FD_WRITE on non-blocking connect() When we perform a non-blocking Change-Id: I22964c5d5da849abcd97a900bd86ab5b4ada05da --- M src/socket.c 1 file changed, 14 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/85/23985/1 diff --git a/src/socket.c b/src/socket.c index 59d0876..34972b8 100644 --- a/src/socket.c +++ b/src/socket.c @@ -972,11 +972,12 @@ /*! fill \ref osmo_fd for a give sfd * \param[out] ofd file descriptor (will be filled in) * \param[in] sfd socket file descriptor + * \param[in] flags flags like \ref OSMO_SOCK_F_CONNECT * \returns socket fd on success; negative on error * * This function fills the \a ofd structure. */ -static inline int osmo_fd_init_ofd(struct osmo_fd *ofd, int sfd) +static inline int osmo_fd_init_ofd(struct osmo_fd *ofd, int sfd, unsigned int flags) { int rc; @@ -986,6 +987,14 @@ ofd->fd = sfd; ofd->when = OSMO_FD_READ; + /* if we're doing a non-blocking connect, the completion will be signaled + * by marking the fd as WRITE-able. So in this exceptional case, we're + * also interested in when the socket becomes write-able */ + if ((flags & (OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_NONBLOCK)) == + (OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_NONBLOCK)) { + ofd->when |= OSMO_FD_WRITE; + } + rc = osmo_fd_register(ofd); if (rc < 0) { close(sfd); @@ -1011,7 +1020,7 @@ int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto, const char *host, uint16_t port, unsigned int flags) { - return osmo_fd_init_ofd(ofd, osmo_sock_init(family, type, proto, host, port, flags)); + return osmo_fd_init_ofd(ofd, osmo_sock_init(family, type, proto, host, port, flags), flags); } /*! Initialize a socket and fill \ref osmo_fd @@ -1034,14 +1043,14 @@ const char *remote_host, uint16_t remote_port, unsigned int flags) { return osmo_fd_init_ofd(ofd, osmo_sock_init2(family, type, proto, local_host, - local_port, remote_host, remote_port, flags)); + local_port, remote_host, remote_port, flags), flags); } int osmo_sock_init_osa_ofd(struct osmo_fd *ofd, int type, int proto, const struct osmo_sockaddr *local, const struct osmo_sockaddr *remote, unsigned int flags) { - return osmo_fd_init_ofd(ofd, osmo_sock_init_osa(type, proto, local, remote, flags)); + return osmo_fd_init_ofd(ofd, osmo_sock_init_osa(type, proto, local, remote, flags), flags); } /*! Initialize a socket and fill \ref sockaddr @@ -1313,7 +1322,7 @@ int osmo_sock_unix_init_ofd(struct osmo_fd *ofd, uint16_t type, uint8_t proto, const char *socket_path, unsigned int flags) { - return osmo_fd_init_ofd(ofd, osmo_sock_unix_init(type, proto, socket_path, flags)); + return osmo_fd_init_ofd(ofd, osmo_sock_unix_init(type, proto, socket_path, flags), flags); } /*! Get the IP and/or port number on socket in separate string buffers. -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/23985 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I22964c5d5da849abcd97a900bd86ab5b4ada05da Gerrit-Change-Number: 23985 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210429/bf5f311e/attachment.htm>