bapi/vat: fix socket transport for vat

Change-Id: I8e39df129f80c8d3d73181fc5d3ac60ae382a6b6
Signed-off-by: Florin Coras <fcoras@cisco.com>
This commit is contained in:
Florin Coras
2018-12-21 16:23:09 -08:00
committed by Damjan Marion
parent 844a36d1a6
commit 66a1003f17
2 changed files with 17 additions and 4 deletions

View File

@ -91,9 +91,15 @@ vl (void *p)
int
vat_socket_connect (vat_main_t * vam)
{
int rv;
vam->socket_client_main = &socket_client_main;
return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test",
0 /* default socket rx, tx buffer */ );
if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
"vpp_api_test",
0 /* default socket rx, tx buffer */ )))
return rv;
/* vpp expects the client index in network order */
vam->my_client_index = htonl (socket_client_main.client_index);
return 0;
}
#else /* vpp built-in case, we don't do sockets... */
int

View File

@ -79,6 +79,9 @@ vl_socket_client_read (int wait)
scm->socket_buffer_size);
if (n < 0)
{
if (errno == EAGAIN)
continue;
clib_unix_warning ("socket_read");
return -1;
}
@ -103,8 +106,11 @@ vl_socket_client_read (int wait)
n = read (scm->socket_fd,
scm->socket_rx_buffer + vec_len (scm->socket_rx_buffer),
msg_size - vec_len (scm->socket_rx_buffer));
if (n < 0 && errno != EAGAIN)
if (n < 0)
{
if (errno == EAGAIN)
continue;
clib_unix_warning ("socket_read");
return -1;
}
@ -358,7 +364,8 @@ vl_socket_client_connect (char *socket_path, char *client_name,
sock = &scm->client_socket;
sock->config = socket_path;
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_NON_BLOCKING_CONNECT;
if ((error = clib_socket_init (sock)))
{