summaryrefslogtreecommitdiffstats
path: root/extras/libmemif/src/socket.c
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2019-07-01 14:24:48 +0200
committerDamjan Marion <dmarion@me.com>2019-07-02 14:06:46 +0000
commit12df497bb6b7f60513f48c0dacca9ad99d717192 (patch)
tree71b219bc3a369a54fe119a65b1597c2d03337b86 /extras/libmemif/src/socket.c
parent312758f9af526d3d498219cf84e58887d6740687 (diff)
libmemif: version 3.0
Add support for multi-thread connection establishment. - control_fd_update() callback now passes private context associated with updated file descriptor. File descriptor can belong to memif socket, memif connection or timerfd. In case of timerfd the context is NULL. - memif_create_socket() new API. Creates memif socket handle to be passed to memif_create() in memif_conn_args_t. This API allows to pass private context whenever the file descriptor is updated. - memif_delete_socket() new API. Deletes memif socket. Socket must not be in use by any interface. Type: feature Change-Id: I7ca4e4349595d4477195f1c32403d3e3a6eb5361 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'extras/libmemif/src/socket.c')
-rw-r--r--extras/libmemif/src/socket.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/extras/libmemif/src/socket.c b/extras/libmemif/src/socket.c
index 495cef9ad43..6efcfb5b5f7 100644
--- a/extras/libmemif/src/socket.c
+++ b/extras/libmemif/src/socket.c
@@ -471,7 +471,7 @@ memif_msg_receive_init (memif_socket_t * ms, int fd, memif_msg_t * msg)
error:
memif_msg_send_disconnect (fd, err_string, 0);
- lm->control_fd_update (fd, MEMIF_FD_EVENT_DEL);
+ lm->control_fd_update (fd, MEMIF_FD_EVENT_DEL, c->private_ctx);
free_list_elt (lm->pending_list, lm->pending_list_len, fd);
close (fd);
fd = -1;
@@ -600,7 +600,8 @@ memif_msg_receive_connect (memif_connection_t * c, memif_msg_t * msg)
elt.data_struct = c;
add_list_elt (&elt, &lm->interrupt_list, &lm->interrupt_list_len);
- lm->control_fd_update (c->rx_queues[i].int_fd, MEMIF_FD_EVENT_READ);
+ lm->control_fd_update (c->rx_queues[i].int_fd, MEMIF_FD_EVENT_READ,
+ c->private_ctx);
}
}
@@ -630,7 +631,8 @@ memif_msg_receive_connected (memif_connection_t * c, memif_msg_t * msg)
{
for (i = 0; i < c->run_args.num_s2m_rings; i++)
{
- lm->control_fd_update (c->rx_queues[i].int_fd, MEMIF_FD_EVENT_READ);
+ lm->control_fd_update (c->rx_queues[i].int_fd, MEMIF_FD_EVENT_READ,
+ c->private_ctx);
}
}
@@ -808,8 +810,7 @@ memif_msg_receive (int ifd)
if (c != NULL)
c->flags |= MEMIF_CONNECTION_FLAG_WRITE;
-/* libmemif_main_t *lm = &libmemif_main;
- lm->control_fd_update (c->fd, MEMIF_FD_EVENT_READ | MEMIF_FD_EVENT_MOD); */
+
return MEMIF_ERR_SUCCESS; /* 0 */
}
@@ -853,12 +854,7 @@ memif_conn_fd_write_ready (memif_connection_t * c)
c->msg_queue = c->msg_queue->next;
c->flags &= ~MEMIF_CONNECTION_FLAG_WRITE;
-/*
- libmemif_main_t *lm = &libmemif_main;
- lm->control_fd_update (c->fd,
- MEMIF_FD_EVENT_READ | MEMIF_FD_EVENT_WRITE | MEMIF_FD_EVENT_MOD);
-*/
err = memif_msg_send (c->fd, &e->msg, e->fd);
lm->free (e);
goto done;
@@ -893,7 +889,8 @@ memif_conn_fd_accept_ready (memif_socket_t * ms)
elt.data_struct = ms;
add_list_elt (&elt, &lm->pending_list, &lm->pending_list_len);
- lm->control_fd_update (conn_fd, MEMIF_FD_EVENT_READ | MEMIF_FD_EVENT_WRITE);
+ lm->control_fd_update (conn_fd, MEMIF_FD_EVENT_READ | MEMIF_FD_EVENT_WRITE,
+ ms->private_ctx);
return memif_msg_send_hello (conn_fd);
}