diff options
author | Florin Coras <fcoras@cisco.com> | 2021-05-26 10:21:10 -0700 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2021-05-26 18:47:41 +0000 |
commit | 57e0af924b8b48cf39b1020bf11f10e3c227f22c (patch) | |
tree | 0f18adca9384fe9f8bf759bd795442baef2b4c17 /src | |
parent | 46cb4c40941e06d726c116975c321603766d24bd (diff) |
vppinfra: explicit blocking mode for sock connects
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I3a33230de13fef613dc9523cf24a9968d200c2e5
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/memif/memif.c | 5 | ||||
-rw-r--r-- | src/vcl/vcl_sapi.c | 3 | ||||
-rw-r--r-- | src/vppinfra/socket.c | 4 | ||||
-rw-r--r-- | src/vppinfra/socket.h | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c index e83864b1a11..9bbbe7f9d89 100644 --- a/src/plugins/memif/memif.c +++ b/src/plugins/memif/memif.c @@ -583,9 +583,10 @@ memif_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) { clib_memset (sock, 0, sizeof(clib_socket_t)); sock->config = (char *) msf->filename; - sock->flags = CLIB_SOCKET_F_IS_CLIENT| CLIB_SOCKET_F_SEQPACKET; + sock->flags = CLIB_SOCKET_F_IS_CLIENT | CLIB_SOCKET_F_SEQPACKET | + CLIB_SOCKET_F_BLOCKING; - if ((err = clib_socket_init (sock))) + if ((err = clib_socket_init (sock))) { clib_error_free (err); } diff --git a/src/vcl/vcl_sapi.c b/src/vcl/vcl_sapi.c index 14401da9d57..84d56af576b 100644 --- a/src/vcl/vcl_sapi.c +++ b/src/vcl/vcl_sapi.c @@ -23,7 +23,8 @@ vcl_api_connect_app_socket (vcl_worker_t * wrk) int rv = 0; cs->config = (char *) vcm->cfg.vpp_app_socket_api; - cs->flags = CLIB_SOCKET_F_IS_CLIENT | CLIB_SOCKET_F_SEQPACKET; + cs->flags = + CLIB_SOCKET_F_IS_CLIENT | CLIB_SOCKET_F_SEQPACKET | CLIB_SOCKET_F_BLOCKING; wrk->vcl_needs_real_epoll = 1; diff --git a/src/vppinfra/socket.c b/src/vppinfra/socket.c index 1d8b2ca2e45..d8427852400 100644 --- a/src/vppinfra/socket.c +++ b/src/vppinfra/socket.c @@ -518,8 +518,10 @@ clib_socket_init (clib_socket_t * s) s->fd, s->config); goto done; } - /* Connect was blocking so set fd to non-blocking now */ + /* Connect was blocking so set fd to non-blocking now unless + * blocking mode explicitly requested. */ if (!(s->flags & CLIB_SOCKET_F_NON_BLOCKING_CONNECT) && + !(s->flags & CLIB_SOCKET_F_BLOCKING) && fcntl (s->fd, F_SETFL, O_NONBLOCK) < 0) { error = clib_error_return_unix (0, "fcntl NONBLOCK2 (fd %d, '%s')", diff --git a/src/vppinfra/socket.h b/src/vppinfra/socket.h index b5f005839e4..78a56fee53e 100644 --- a/src/vppinfra/socket.h +++ b/src/vppinfra/socket.h @@ -62,7 +62,7 @@ typedef struct _socket_t #define CLIB_SOCKET_F_ALLOW_GROUP_WRITE (1 << 4) #define CLIB_SOCKET_F_SEQPACKET (1 << 5) #define CLIB_SOCKET_F_PASSCRED (1 << 6) - +#define CLIB_SOCKET_F_BLOCKING (1 << 7) /* Transmit buffer. Holds data waiting to be written. */ u8 *tx_buffer; |