libmemif: introduce 'memif_per_thread_' namespace
APIs in 'memif_per_thread_' namespace are used to split the global database into separate databases, to improve multi-thread use cases. Using 'memif_per_thread_init' client can create separate libmemif databases (libmemif_main_t). Client will reference these databases using memif_per_thread_handle_t. Each database requires unique socket. Created interface will be stored in the same database as the socket passed in connection arguments. Example code: extras/libmemif/examples/icmp_responder_3-1/main.c Type: feature Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: I261563ecc34761a76e94f20c20015394398ddfd7 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> (cherry picked from commit 17f2a7bbf25f54dbd71aa8f377875828b7b88e35)
This commit is contained in:

committed by
Damjan Marion

parent
17b7a067a2
commit
2736fc7fcf
@ -22,6 +22,7 @@ list(APPEND EXAMPLES_LIST
|
||||
icmp_responder/main.c
|
||||
icmp_responder-epoll/main.c
|
||||
icmp_responder-mt/main.c
|
||||
icmp_responder-mt_3-1/main.c
|
||||
icmp_responder-eb/main.c
|
||||
icmp_responder-zero-copy-slave/main.c
|
||||
)
|
||||
@ -33,4 +34,3 @@ foreach (EXAMPLE_SRC ${EXAMPLES_LIST})
|
||||
target_include_directories(${EXECUTABLE} PRIVATE $<BUILD_INTERFACE:${HEADERS_DIR}>)
|
||||
target_link_libraries(${EXECUTABLE} ${LIBMEMIF} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endforeach()
|
||||
|
||||
|
549
extras/libmemif/examples/icmp_responder-mt_3-1/main.c
Normal file
549
extras/libmemif/examples/icmp_responder-mt_3-1/main.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,7 @@
|
||||
#define _LIBMEMIF_H_
|
||||
|
||||
/** Libmemif version. */
|
||||
#define LIBMEMIF_VERSION "3.0"
|
||||
#define LIBMEMIF_VERSION "3.1"
|
||||
/** Default name of application using libmemif. */
|
||||
#define MEMIF_DEFAULT_APP_NAME "libmemif-app"
|
||||
|
||||
@ -96,6 +96,12 @@ typedef enum
|
||||
#define MEMIF_FD_EVENT_MOD (1 << 4)
|
||||
/** @} */
|
||||
|
||||
/** \brief Memif per thread main handle
|
||||
Pointer of type void, pointing to internal structure.
|
||||
Used to identify internal per thread database.
|
||||
*/
|
||||
typedef void *memif_per_thread_main_handle_t;
|
||||
|
||||
/** \brief Memif connection handle
|
||||
pointer of type void, pointing to internal structure
|
||||
*/
|
||||
@ -227,6 +233,24 @@ void memif_register_external_region (memif_add_external_region_t * ar,
|
||||
memif_del_external_region_t * dr,
|
||||
memif_get_external_buffer_offset_t * go);
|
||||
|
||||
/** \brief Register external region
|
||||
@param pt_main - per thread main handle
|
||||
@param ar - add external region callback
|
||||
@param gr - get external region addr callback
|
||||
@param dr - delete external region callback
|
||||
@param go - get external buffer offset callback (optional)
|
||||
*/
|
||||
void memif_per_thread_register_external_region (memif_per_thread_main_handle_t
|
||||
pt_main,
|
||||
memif_add_external_region_t *
|
||||
ar,
|
||||
memif_get_external_region_addr_t
|
||||
* gr,
|
||||
memif_del_external_region_t *
|
||||
dr,
|
||||
memif_get_external_buffer_offset_t
|
||||
* go);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
@ -246,7 +270,11 @@ typedef enum
|
||||
#endif /* _MEMIF_H_ */
|
||||
|
||||
/** \brief Memif connection arguments
|
||||
@param socket - memif socket handle, if NULL default socket will be used
|
||||
@param socket - Memif socket handle, if NULL default socket will be used.
|
||||
Default socket is only supported in global database (see memif_init).
|
||||
Custom database does not create a default socket
|
||||
(see memif_per_thread_init).
|
||||
Memif connection is stored in the same database as the socket.
|
||||
@param secret - otional parameter used as interface autenthication
|
||||
@param num_s2m_rings - number of slave to master rings
|
||||
@param num_m2s_rings - number of master to slave rings
|
||||
@ -465,6 +493,28 @@ int memif_init (memif_control_fd_update_t * on_control_fd_update,
|
||||
char *app_name, memif_alloc_t * memif_alloc,
|
||||
memif_realloc_t * memif_realloc, memif_free_t * memif_free);
|
||||
|
||||
/** \brief Memif per thread initialization
|
||||
@param pt_main - per thread main handle
|
||||
@param private_ctx - private context
|
||||
@param on_control_fd_update - if control fd updates inform user to watch new fd
|
||||
@param app_name - application name (will be truncated to 32 chars)
|
||||
@param memif_alloc - cutom memory allocator, NULL = default
|
||||
@param memif_realloc - custom memory reallocation, NULL = default
|
||||
@param memif_free - custom memory free, NULL = default
|
||||
|
||||
Per thread version of memif_init ().
|
||||
Instead of using global database, creates and initializes unique database,
|
||||
identified by 'memif_per_thread_main_handle_t'.
|
||||
|
||||
\return memif_err_t
|
||||
*/
|
||||
int memif_per_thread_init (memif_per_thread_main_handle_t * pt_main,
|
||||
void *private_ctx,
|
||||
memif_control_fd_update_t * on_control_fd_update,
|
||||
char *app_name, memif_alloc_t * memif_alloc,
|
||||
memif_realloc_t * memif_realloc,
|
||||
memif_free_t * memif_free);
|
||||
|
||||
/** \brief Memif cleanup
|
||||
|
||||
Free libmemif internal allocations.
|
||||
@ -473,6 +523,15 @@ int memif_init (memif_control_fd_update_t * on_control_fd_update,
|
||||
*/
|
||||
int memif_cleanup ();
|
||||
|
||||
/** \brief Memif per thread cleanup
|
||||
@param pt_main - per thread main handle
|
||||
|
||||
Free libmemif internal allocations and sets the handle to NULL.
|
||||
|
||||
\return memif_err_t
|
||||
*/
|
||||
int memif_per_thread_cleanup (memif_per_thread_main_handle_t * pt_main);
|
||||
|
||||
/** \brief Memory interface create function
|
||||
@param conn - connection handle for client app
|
||||
@param args - memory interface connection arguments
|
||||
@ -521,6 +580,19 @@ int memif_create (memif_conn_handle_t * conn, memif_conn_args_t * args,
|
||||
*/
|
||||
int memif_control_fd_handler (int fd, uint8_t events);
|
||||
|
||||
/** \brief Memif per thread control file descriptor handler
|
||||
@param pt_main - per thread main handle
|
||||
@param fd - file descriptor on which the event occured
|
||||
@param events - event type(s) that occured
|
||||
|
||||
Per thread version of memif_control_fd_handler.
|
||||
|
||||
\return memif_err_t
|
||||
|
||||
*/
|
||||
int memif_per_thread_control_fd_handler (memif_per_thread_main_handle_t
|
||||
pt_main, int fd, uint8_t events);
|
||||
|
||||
/** \brief Memif delete
|
||||
@param conn - pointer to memif connection handle
|
||||
|
||||
@ -608,6 +680,17 @@ int memif_rx_burst (memif_conn_handle_t conn, uint16_t qid,
|
||||
*/
|
||||
int memif_poll_event (int timeout);
|
||||
|
||||
/** \brief Memif poll event
|
||||
@param pt_main - per thread main handle
|
||||
@param timeout - timeout in seconds
|
||||
|
||||
Per thread version of memif_poll_event.
|
||||
|
||||
\return memif_err_t
|
||||
*/
|
||||
int memif_per_thread_poll_event (memif_per_thread_main_handle_t pt_main,
|
||||
int timeout);
|
||||
|
||||
/** \brief Send signal to stop concurrently running memif_poll_event().
|
||||
|
||||
The function, however, does not wait for memif_poll_event() to stop.
|
||||
@ -622,6 +705,15 @@ int memif_poll_event (int timeout);
|
||||
*/
|
||||
#define MEMIF_HAVE_CANCEL_POLL_EVENT 1
|
||||
int memif_cancel_poll_event ();
|
||||
/** \brief Send signal to stop concurrently running memif_poll_event().
|
||||
@param pt_main - per thread main handle
|
||||
|
||||
Per thread version of memif_cancel_poll_event.
|
||||
|
||||
\return memif_err_t
|
||||
*/
|
||||
int memif_per_thread_cancel_poll_event (memif_per_thread_main_handle_t
|
||||
pt_main);
|
||||
|
||||
/** \brief Set connection request timer value
|
||||
@param timer - new timer value
|
||||
@ -633,6 +725,19 @@ int memif_cancel_poll_event ();
|
||||
*/
|
||||
int memif_set_connection_request_timer (struct itimerspec timer);
|
||||
|
||||
/** \brief Set connection request timer value
|
||||
@param pt_main - per thread main handle
|
||||
@param timer - new timer value
|
||||
|
||||
Per thread version of memif_set_connection_request_timer
|
||||
|
||||
\return memif_err_t
|
||||
*/
|
||||
int
|
||||
memif_per_thread_set_connection_request_timer (memif_per_thread_main_handle_t
|
||||
pt_main,
|
||||
struct itimerspec timer);
|
||||
|
||||
/** \brief Send connection request
|
||||
@param conn - memif connection handle
|
||||
|
||||
@ -656,8 +761,22 @@ int memif_request_connection (memif_conn_handle_t conn);
|
||||
|
||||
\return memif_err_t
|
||||
*/
|
||||
int memif_create_socket (memif_socket_handle_t * sock, const char * filename,
|
||||
void * private_ctx);
|
||||
int memif_create_socket (memif_socket_handle_t * sock, const char *filename,
|
||||
void *private_ctx);
|
||||
|
||||
/** \brief Create memif socket
|
||||
@param pt_main - per thread main handle
|
||||
@param sock - socket handle for client app
|
||||
@param filename - path to socket file
|
||||
@param private_ctx - private context
|
||||
|
||||
Per thread version of memif_create_sopcket.
|
||||
|
||||
\return memif_err_t
|
||||
*/
|
||||
int memif_per_thread_create_socket (memif_per_thread_main_handle_t pt_main,
|
||||
memif_socket_handle_t * sock,
|
||||
const char *filename, void *private_ctx);
|
||||
|
||||
/** \brief Delete memif socket
|
||||
@param sock - socket handle for client app
|
||||
@ -669,6 +788,15 @@ int memif_create_socket (memif_socket_handle_t * sock, const char * filename,
|
||||
*/
|
||||
int memif_delete_socket (memif_socket_handle_t * sock);
|
||||
|
||||
/** \brief Get socket filename
|
||||
@param sock - socket handle for client app
|
||||
|
||||
Return constant pointer to socket filename.
|
||||
|
||||
\return cosnt char *
|
||||
*/
|
||||
const char *memif_get_socket_filename (memif_socket_handle_t sock);
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* _LIBMEMIF_H_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -120,6 +120,8 @@ typedef struct
|
||||
memif_log2_ring_size_t log2_ring_size;
|
||||
} memif_conn_run_args_t;
|
||||
|
||||
struct libmemif_main;
|
||||
|
||||
typedef struct memif_connection
|
||||
{
|
||||
uint16_t index;
|
||||
@ -165,19 +167,25 @@ typedef struct
|
||||
uint16_t use_count;
|
||||
memif_socket_type_t type;
|
||||
uint8_t *filename;
|
||||
/* unique database */
|
||||
struct libmemif_main *lm;
|
||||
uint16_t interface_list_len;
|
||||
void *private_ctx;
|
||||
memif_list_elt_t *interface_list; /* memif master interfaces listening on this socket */
|
||||
} memif_socket_t;
|
||||
|
||||
typedef struct
|
||||
typedef struct libmemif_main
|
||||
{
|
||||
memif_control_fd_update_t *control_fd_update;
|
||||
int timerfd;
|
||||
int epfd;
|
||||
int poll_cancel_fd;
|
||||
struct itimerspec arm, disarm;
|
||||
uint16_t disconn_slaves;
|
||||
uint8_t app_name[MEMIF_NAME_LEN];
|
||||
|
||||
void *private_ctx;
|
||||
|
||||
memif_socket_handle_t default_socket;
|
||||
|
||||
memif_add_external_region_t *add_external_region;
|
||||
@ -200,7 +208,6 @@ typedef struct
|
||||
} libmemif_main_t;
|
||||
|
||||
extern libmemif_main_t libmemif_main;
|
||||
extern int memif_epfd;
|
||||
|
||||
/* main.c */
|
||||
|
||||
@ -215,7 +222,7 @@ int memif_disconnect_internal (memif_connection_t * c);
|
||||
/* map errno to memif error code */
|
||||
int memif_syscall_error_handler (int err_code);
|
||||
|
||||
int add_list_elt (memif_list_elt_t * e, memif_list_elt_t ** list,
|
||||
int add_list_elt (libmemif_main_t *lm, memif_list_elt_t * e, memif_list_elt_t ** list,
|
||||
uint16_t * len);
|
||||
|
||||
int get_list_elt (memif_list_elt_t ** e, memif_list_elt_t * list,
|
||||
@ -223,6 +230,8 @@ int get_list_elt (memif_list_elt_t ** e, memif_list_elt_t * list,
|
||||
|
||||
int free_list_elt (memif_list_elt_t * list, uint16_t len, int key);
|
||||
|
||||
libmemif_main_t *get_libmemif_main (memif_socket_t * ms);
|
||||
|
||||
#ifndef __NR_memfd_create
|
||||
#if defined __x86_64__
|
||||
#define __NR_memfd_create 319
|
||||
|
@ -71,7 +71,7 @@ memif_msg_send (int fd, memif_msg_t * msg, int afd)
|
||||
static_fn int
|
||||
memif_msg_enq_ack (memif_connection_t * c)
|
||||
{
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
memif_msg_queue_elt_t *e =
|
||||
(memif_msg_queue_elt_t *) lm->alloc (sizeof (memif_msg_queue_elt_t));
|
||||
if (e == NULL)
|
||||
@ -99,9 +99,8 @@ memif_msg_enq_ack (memif_connection_t * c)
|
||||
}
|
||||
|
||||
static_fn int
|
||||
memif_msg_send_hello (int fd)
|
||||
memif_msg_send_hello (libmemif_main_t * lm, int fd)
|
||||
{
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
memif_msg_t msg = { 0 };
|
||||
memif_msg_hello_t *h = &msg.hello;
|
||||
msg.type = MEMIF_MSG_TYPE_HELLO;
|
||||
@ -124,7 +123,7 @@ memif_msg_send_hello (int fd)
|
||||
static_fn int
|
||||
memif_msg_enq_init (memif_connection_t * c)
|
||||
{
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
memif_msg_queue_elt_t *e =
|
||||
(memif_msg_queue_elt_t *) lm->alloc (sizeof (memif_msg_queue_elt_t));
|
||||
if (e == NULL)
|
||||
@ -166,7 +165,7 @@ memif_msg_enq_init (memif_connection_t * c)
|
||||
static_fn int
|
||||
memif_msg_enq_add_region (memif_connection_t * c, uint8_t region_index)
|
||||
{
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
memif_region_t *mr = &c->regions[region_index];
|
||||
|
||||
memif_msg_queue_elt_t *e =
|
||||
@ -203,7 +202,7 @@ memif_msg_enq_add_region (memif_connection_t * c, uint8_t region_index)
|
||||
static_fn int
|
||||
memif_msg_enq_add_ring (memif_connection_t * c, uint8_t index, uint8_t dir)
|
||||
{
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
memif_msg_queue_elt_t *e =
|
||||
(memif_msg_queue_elt_t *) lm->alloc (sizeof (memif_msg_queue_elt_t));
|
||||
if (e == NULL)
|
||||
@ -250,7 +249,7 @@ memif_msg_enq_add_ring (memif_connection_t * c, uint8_t index, uint8_t dir)
|
||||
static_fn int
|
||||
memif_msg_enq_connect (memif_connection_t * c)
|
||||
{
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
memif_msg_queue_elt_t *e =
|
||||
(memif_msg_queue_elt_t *) lm->alloc (sizeof (memif_msg_queue_elt_t));
|
||||
if (e == NULL)
|
||||
@ -285,7 +284,7 @@ memif_msg_enq_connect (memif_connection_t * c)
|
||||
static_fn int
|
||||
memif_msg_enq_connected (memif_connection_t * c)
|
||||
{
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
memif_msg_queue_elt_t *e =
|
||||
(memif_msg_queue_elt_t *) lm->alloc (sizeof (memif_msg_queue_elt_t));
|
||||
if (e == NULL)
|
||||
@ -371,10 +370,11 @@ memif_msg_receive_init (memif_socket_t * ms, int fd, memif_msg_t * msg)
|
||||
memif_list_elt_t *elt = NULL;
|
||||
memif_list_elt_t elt2;
|
||||
memif_connection_t *c = NULL;
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (ms);
|
||||
uint8_t err_string[96];
|
||||
memset (err_string, 0, sizeof (char) * 96);
|
||||
int err = MEMIF_ERR_SUCCESS; /* 0 */
|
||||
|
||||
if (i->version != MEMIF_VERSION)
|
||||
{
|
||||
DBG ("MEMIF_VER_ERR");
|
||||
@ -464,7 +464,7 @@ memif_msg_receive_init (memif_socket_t * ms, int fd, memif_msg_t * msg)
|
||||
elt2.key = c->fd;
|
||||
elt2.data_struct = c;
|
||||
|
||||
add_list_elt (&elt2, &lm->control_list, &lm->control_list_len);
|
||||
add_list_elt (lm, &elt2, &lm->control_list, &lm->control_list_len);
|
||||
free_list_elt (lm->pending_list, lm->pending_list_len, fd);
|
||||
|
||||
return err;
|
||||
@ -483,7 +483,7 @@ static_fn int
|
||||
memif_msg_receive_add_region (memif_connection_t * c, memif_msg_t * msg,
|
||||
int fd)
|
||||
{
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
|
||||
memif_msg_add_region_t *ar = &msg->add_region;
|
||||
memif_region_t *mr;
|
||||
@ -517,7 +517,7 @@ memif_msg_receive_add_region (memif_connection_t * c, memif_msg_t * msg,
|
||||
static_fn int
|
||||
memif_msg_receive_add_ring (memif_connection_t * c, memif_msg_t * msg, int fd)
|
||||
{
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
|
||||
memif_msg_add_ring_t *ar = &msg->add_ring;
|
||||
|
||||
@ -580,7 +580,7 @@ static_fn int
|
||||
memif_msg_receive_connect (memif_connection_t * c, memif_msg_t * msg)
|
||||
{
|
||||
memif_msg_connect_t *cm = &msg->connect;
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
memif_list_elt_t elt;
|
||||
|
||||
int err;
|
||||
@ -598,7 +598,8 @@ memif_msg_receive_connect (memif_connection_t * c, memif_msg_t * msg)
|
||||
{
|
||||
elt.key = c->rx_queues[i].int_fd;
|
||||
elt.data_struct = c;
|
||||
add_list_elt (&elt, &lm->interrupt_list, &lm->interrupt_list_len);
|
||||
add_list_elt (lm, &elt, &lm->interrupt_list,
|
||||
&lm->interrupt_list_len);
|
||||
|
||||
lm->control_fd_update (c->rx_queues[i].int_fd, MEMIF_FD_EVENT_READ,
|
||||
c->private_ctx);
|
||||
@ -616,7 +617,7 @@ static_fn int
|
||||
memif_msg_receive_connected (memif_connection_t * c, memif_msg_t * msg)
|
||||
{
|
||||
memif_msg_connect_t *cm = &msg->connect;
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
|
||||
int err;
|
||||
err = memif_connect1 (c);
|
||||
@ -658,7 +659,7 @@ memif_msg_receive_disconnect (memif_connection_t * c, memif_msg_t * msg)
|
||||
}
|
||||
|
||||
static_fn int
|
||||
memif_msg_receive (int ifd)
|
||||
memif_msg_receive (libmemif_main_t * lm, int ifd)
|
||||
{
|
||||
char ctl[CMSG_SPACE (sizeof (int)) +
|
||||
CMSG_SPACE (sizeof (struct ucred))] = { 0 };
|
||||
@ -669,7 +670,6 @@ memif_msg_receive (int ifd)
|
||||
int err = MEMIF_ERR_SUCCESS; /* 0 */
|
||||
int fd = -1;
|
||||
int i;
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
memif_connection_t *c = NULL;
|
||||
memif_socket_t *ms = NULL;
|
||||
memif_list_elt_t *elt = NULL;
|
||||
@ -827,8 +827,10 @@ memif_conn_fd_error (memif_connection_t * c)
|
||||
int
|
||||
memif_conn_fd_read_ready (memif_connection_t * c)
|
||||
{
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
int err;
|
||||
err = memif_msg_receive (c->fd);
|
||||
|
||||
err = memif_msg_receive (lm, c->fd);
|
||||
if (err != 0)
|
||||
{
|
||||
err = memif_disconnect_internal (c);
|
||||
@ -840,7 +842,7 @@ memif_conn_fd_read_ready (memif_connection_t * c)
|
||||
int
|
||||
memif_conn_fd_write_ready (memif_connection_t * c)
|
||||
{
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (c->args.socket);
|
||||
int err = MEMIF_ERR_SUCCESS; /* 0 */
|
||||
|
||||
|
||||
@ -869,7 +871,7 @@ memif_conn_fd_accept_ready (memif_socket_t * ms)
|
||||
int addr_len;
|
||||
struct sockaddr_un client;
|
||||
int conn_fd;
|
||||
libmemif_main_t *lm = &libmemif_main;
|
||||
libmemif_main_t *lm = get_libmemif_main (ms);
|
||||
|
||||
DBG ("accept called");
|
||||
|
||||
@ -888,19 +890,19 @@ memif_conn_fd_accept_ready (memif_socket_t * ms)
|
||||
elt.key = conn_fd;
|
||||
elt.data_struct = ms;
|
||||
|
||||
add_list_elt (&elt, &lm->pending_list, &lm->pending_list_len);
|
||||
add_list_elt (lm, &elt, &lm->pending_list, &lm->pending_list_len);
|
||||
lm->control_fd_update (conn_fd, MEMIF_FD_EVENT_READ | MEMIF_FD_EVENT_WRITE,
|
||||
ms->private_ctx);
|
||||
|
||||
return memif_msg_send_hello (conn_fd);
|
||||
return memif_msg_send_hello (lm, conn_fd);
|
||||
}
|
||||
|
||||
int
|
||||
memif_read_ready (int fd)
|
||||
memif_read_ready (libmemif_main_t * lm, int fd)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = memif_msg_receive (fd);
|
||||
err = memif_msg_receive (lm, fd);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ int memif_conn_fd_error (memif_connection_t * c);
|
||||
|
||||
int memif_conn_fd_accept_ready (memif_socket_t * ms);
|
||||
|
||||
int memif_read_ready (int fd);
|
||||
int memif_read_ready (libmemif_main_t *lm, int fd);
|
||||
|
||||
int memif_msg_send_disconnect (int fd, uint8_t * err_string,
|
||||
uint32_t err_code);
|
||||
@ -53,7 +53,7 @@ int memif_msg_send (int fd, memif_msg_t * msg, int afd);
|
||||
|
||||
int memif_msg_enq_ack (memif_connection_t * c);
|
||||
|
||||
int memif_msg_send_hello (int fd);
|
||||
int memif_msg_send_hello (libmemif_main_t *lm, int fd);
|
||||
|
||||
int memif_msg_enq_init (memif_connection_t * c);
|
||||
|
||||
|
@ -94,7 +94,7 @@ START_TEST (test_init_epoll)
|
||||
ck_assert_ptr_ne (lm, NULL);
|
||||
ck_assert_ptr_ne (lm->control_fd_update, NULL);
|
||||
ck_assert_int_gt (lm->timerfd, 2);
|
||||
ck_assert_int_gt (memif_epfd, -1);
|
||||
ck_assert_int_gt (lm->epfd, -1);
|
||||
|
||||
if (lm->timerfd > 0)
|
||||
close (lm->timerfd);
|
||||
|
@ -296,7 +296,9 @@ START_TEST (test_send_hello)
|
||||
NULL, NULL)) != MEMIF_ERR_SUCCESS)
|
||||
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
|
||||
|
||||
if ((err = memif_msg_send_hello (conn.fd)) != MEMIF_ERR_SUCCESS)
|
||||
conn.args.socket = libmemif_main.default_socket;
|
||||
|
||||
if ((err = memif_msg_send_hello (get_libmemif_main (conn.args.socket), conn.fd)) != MEMIF_ERR_SUCCESS)
|
||||
ck_assert_msg (err == MEMIF_ERR_BAD_FD,
|
||||
"err code: %u, err msg: %s", err, memif_strerror (err));
|
||||
}
|
||||
@ -387,7 +389,7 @@ START_TEST (test_recv_init)
|
||||
memif_list_elt_t elt;
|
||||
elt.key = 69;
|
||||
elt.data_struct = &conn;
|
||||
add_list_elt (&elt, &ms.interface_list, &ms.interface_list_len);
|
||||
add_list_elt (get_libmemif_main (conn.args.socket), &elt, &ms.interface_list, &ms.interface_list_len);
|
||||
|
||||
if ((err =
|
||||
memif_init (control_fd_update, TEST_APP_NAME, NULL,
|
||||
|
Reference in New Issue
Block a user