pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/41666?usp=email )


Change subject: stream_srv: srv_link: Set OSMO_SOCK_F_NONBLOCK during socket 
creation
......................................................................

stream_srv: srv_link: Set OSMO_SOCK_F_NONBLOCK during socket creation

This should be needed to potentially avoid blocking during accept()
call.

In practice right now is not needed because osmo_fd/osmo_iofd takes care
of setting to non-blocking during registering:
* osmo_fd: osmo_fd_register() sets the fd to non-bloking.
* osmo_iofd:
** osmo_io_poll: it uses osmo_fd_register() internally, see above
** osmo_io_uring: only set to non-blocking as a side-effect of calling
   osmo_fd_register() if IOFD_FLAG_NOTIFY_CONNECTED was passed.

Since for the srv_link so far always uses an osmo_fd regardless of
whether OSMO_STREAM_MODE_* is used, in practice we are safed by
osmo_fd_register().

In any case, better pass the flag at socket creation time so it's
already applied then, instead of relying on osmo_fd_register() as a
side-effect, specially if in the future we switch the listen socket to
be operated over osmo_io_uring.

Change-Id: I98a6ef55a0a7289b9eeb7e8062e9afa4d87f51eb
---
M src/stream_srv.c
1 file changed, 4 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/66/41666/1

diff --git a/src/stream_srv.c b/src/stream_srv.c
index 6f86cfd..95ddb1b 100644
--- a/src/stream_srv.c
+++ b/src/stream_srv.c
@@ -584,7 +584,7 @@

        switch (link->sk_domain) {
        case AF_UNIX:
-               ret = osmo_sock_unix_init(link->sk_type, 0, link->addr[0], 
OSMO_SOCK_F_BIND);
+               ret = osmo_sock_unix_init(link->sk_type, 0, link->addr[0], 
OSMO_SOCK_F_BIND | OSMO_SOCK_F_NONBLOCK);
                break;
        case AF_UNSPEC:
        case AF_INET:
@@ -594,12 +594,13 @@
                case IPPROTO_SCTP:
                        ret = osmo_sock_init2_multiaddr2(link->sk_domain, 
link->sk_type, link->proto,
                                                         (const char 
**)link->addr, link->addrcnt, link->port,
-                                                        NULL, 0, 0, 
OSMO_SOCK_F_BIND, &link->ma_pars);
+                                                        NULL, 0, 0, 
OSMO_SOCK_F_BIND | OSMO_SOCK_F_NONBLOCK,
+                                                        &link->ma_pars);
                        break;
 #endif
                default:
                        ret = osmo_sock_init(link->sk_domain, link->sk_type, 
link->proto,
-                                            link->addr[0], link->port, 
OSMO_SOCK_F_BIND);
+                                            link->addr[0], link->port, 
OSMO_SOCK_F_BIND | OSMO_SOCK_F_NONBLOCK);
                }
                break;
        default:

--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/41666?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I98a6ef55a0a7289b9eeb7e8062e9afa4d87f51eb
Gerrit-Change-Number: 41666
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to