From 5fe9457fa2ac49ca7134b09c6886192c7001335c Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Mon, 24 May 2021 08:58:15 -0700 Subject: api: socket client connect set to blocking Binary api client must otherwise check the returned error and if it was EAGAIN/EINPROGRESS poll for connect completion. Type: improvement Signed-off-by: Florin Coras Change-Id: I89845b1a59b9fa2ab0968029435ceb203bfa8f6c --- src/vppinfra/socket.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/vppinfra/socket.c') diff --git a/src/vppinfra/socket.c b/src/vppinfra/socket.c index 3271393529d..1d8b2ca2e45 100644 --- a/src/vppinfra/socket.c +++ b/src/vppinfra/socket.c @@ -518,6 +518,14 @@ clib_socket_init (clib_socket_t * s) s->fd, s->config); goto done; } + /* Connect was blocking so set fd to non-blocking now */ + if (!(s->flags & CLIB_SOCKET_F_NON_BLOCKING_CONNECT) && + fcntl (s->fd, F_SETFL, O_NONBLOCK) < 0) + { + error = clib_error_return_unix (0, "fcntl NONBLOCK2 (fd %d, '%s')", + s->fd, s->config); + goto done; + } } return error; -- cgit 1.2.3-korg