pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/38985?usp=email )
Change subject: osmo_io: Improve osmo_iofd_notify_connected() documentation ......................................................................
osmo_io: Improve osmo_iofd_notify_connected() documentation
The mentioned scenario happens when using osmo_stream_cli inside libosmo-abis BTS code connecting to an osmo-bsc in the loopback interface. The client sends SYN and the server sends SYN+ACK and then quickly sends an IPA ID GET.
Change-Id: Ica20a050b98d117995a5b625b23ab9faa61aabee --- M src/core/osmo_io.c 1 file changed, 12 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/85/38985/1
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c index 98d8ef3..9c93e25 100644 --- a/src/core/osmo_io.c +++ b/src/core/osmo_io.c @@ -994,12 +994,22 @@
/*! Request notification of the user if/when a client socket is connected. * Calling this function will request osmo_io to notify the user (via - * write call-back) once a non-blocking outbound connect() of the - * socket completes. + * write call-back with res=0 and msgb=NULL) once a non-blocking outbound + * connect() of the socket completes. * * This only works for connection oriented sockets in either * OSMO_IO_FD_MODE_READ_WRITE or OSMO_IO_FD_MODE_RECVMSG_SENDMSG mode. * + * The fact that the write call-back is called with msgb=NULL can be used to + * distinguish before this "connected" notification and a socket write failure. + * + * If the server transmits data quick enough after accepting the connection, + * it may happen that a read call-back is triggered towards the user before this + * special write-callback, since both events may come together from the kernel. + * Hence under those scenarios where server starts the communication, it is + * important not to assume or require that the write-callback(res=0, msgb=NULL) + * will be the first one triggered. + * * \param[in] iofd the file descriptor */ void osmo_iofd_notify_connected(struct osmo_io_fd *iofd) {