X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlibmemory%2Fsocket_api.c;h=f0c7f1feeb1c68f81c059129c997444492a89edd;hb=bff9f2f2e7a288886cd843bc90446ef1d26615dd;hp=a8423d11ccb30d8dd4f00a459ae16919180b08ab;hpb=3c1cf2c1716f436e5da4a106dd2b9a3df5d3a4a3;p=vpp.git diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index a8423d11ccb..f0c7f1feeb1 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -591,7 +591,7 @@ vl_api_sock_init_shm_t_handler (vl_api_sock_init_shm_t * mp) clib_file_t *cf; vl_api_shm_elem_config_t *config = 0; vl_shmem_hdr_t *shmem_hdr; - int rv; + int rv, tries = 1000; regp = vl_api_client_index_to_registration (mp->client_index); if (regp == 0) @@ -671,6 +671,22 @@ reply: /* Send the magic "here's your sign (aka fd)" socket message */ cf = vl_api_registration_file (regp); + + /* Wait for reply to be consumed before sending the fd */ + while (tries-- > 0) + { + int bytes; + rv = ioctl (cf->file_descriptor, TIOCOUTQ, &bytes); + if (rv < 0) + { + clib_unix_warning ("ioctl returned"); + break; + } + if (bytes == 0) + break; + usleep (1e3); + } + vl_sock_api_send_fd_msg (cf->file_descriptor, &memfd->fd, 1); } @@ -722,8 +738,7 @@ vl_sock_api_init (vlib_main_t * vm) vec_free (tmp); } - sock->flags = CLIB_SOCKET_F_IS_SERVER | CLIB_SOCKET_F_SEQPACKET | - CLIB_SOCKET_F_ALLOW_GROUP_WRITE; + sock->flags = CLIB_SOCKET_F_IS_SERVER | CLIB_SOCKET_F_ALLOW_GROUP_WRITE; error = clib_socket_init (sock); if (error) return error;