summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomasz Kulasek <tomaszx.kulasek@intel.com>2019-01-31 18:26:32 +0100
committerFlorin Coras <florin.coras@gmail.com>2019-02-05 21:56:19 +0000
commit97dcf5bd26ca6de580943f5d39681f0144782c3d (patch)
tree7a7b3849d9296c80f69de54df9aa1bbc524aea70 /src
parent4edc37eb90a74bcd1aad20d6447159c05853d23e (diff)
sock api: allow to start client with no rx_thread
Change-Id: Ia30ff1e62304e65f27497ce05f8e40631c06d69e Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/tests/vnet/session/tcp_echo.c2
-rw-r--r--src/vat/api_format.c2
-rw-r--r--src/vcl/vcl_bapi.c2
-rw-r--r--src/vlibmemory/memory_client.c10
-rw-r--r--src/vlibmemory/memory_client.h3
-rw-r--r--src/vlibmemory/socket_client.c19
-rw-r--r--src/vlibmemory/socket_client.h5
7 files changed, 36 insertions, 7 deletions
diff --git a/src/tests/vnet/session/tcp_echo.c b/src/tests/vnet/session/tcp_echo.c
index 58e29bd5fe8..bd05345cc5c 100644
--- a/src/tests/vnet/session/tcp_echo.c
+++ b/src/tests/vnet/session/tcp_echo.c
@@ -482,7 +482,7 @@ connect_to_vpp (char *name)
return -1;
}
- if (vl_socket_client_init_shm (0))
+ if (vl_socket_client_init_shm (0, 1 /* want_pthread */ ))
{
clib_warning ("init shm api failed");
return -1;
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index d35c19eb416..5ddbb57f281 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -22025,7 +22025,7 @@ api_sock_init_shm (vat_main_t * vam)
config[6].count = 128;
config[6].size = sizeof (uword);
- rv = vl_socket_client_init_shm (config);
+ rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
if (!rv)
vam->client_index_invalid = 1;
return rv;
diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c
index debfb8ff4c3..b7f47d8c579 100644
--- a/src/vcl/vcl_bapi.c
+++ b/src/vcl/vcl_bapi.c
@@ -679,7 +679,7 @@ vppcom_connect_to_vpp (char *app_name)
return VPPCOM_ECONNREFUSED;
}
- if (vl_socket_client_init_shm (0))
+ if (vl_socket_client_init_shm (0, 1 /* want_pthread */ ))
{
VERR ("app (%s) init shm failed!", app_name);
return VPPCOM_ECONNREFUSED;
diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c
index 3add39a4328..fb117340662 100644
--- a/src/vlibmemory/memory_client.c
+++ b/src/vlibmemory/memory_client.c
@@ -468,6 +468,16 @@ vl_client_connect_to_vlib_no_map (const char *svm_name,
0 /* dont map */ );
}
+int
+vl_client_connect_to_vlib_no_rx_pthread_no_map (const char *svm_name,
+ const char *client_name,
+ int rx_queue_size)
+{
+ return connect_to_vlib_internal (svm_name, client_name, rx_queue_size,
+ 0 /* want pthread */ ,
+ 0 /* dont map */ );
+}
+
static void
disconnect_from_vlib_internal (u8 do_unmap)
{
diff --git a/src/vlibmemory/memory_client.h b/src/vlibmemory/memory_client.h
index 6aaf6d7e569..8400d963dcf 100644
--- a/src/vlibmemory/memory_client.h
+++ b/src/vlibmemory/memory_client.h
@@ -35,6 +35,9 @@ int vl_client_connect_to_vlib_no_rx_pthread (const char *svm_name,
int vl_client_connect_to_vlib_no_map (const char *svm_name,
const char *client_name,
int rx_queue_size);
+int vl_client_connect_to_vlib_no_rx_pthread_no_map (const char *svm_name,
+ const char *client_name,
+ int rx_queue_size);
void vl_client_install_client_message_handlers (void);
u8 vl_mem_client_is_connected (void);
diff --git a/src/vlibmemory/socket_client.c b/src/vlibmemory/socket_client.c
index 38bcc2a5156..ca1e53538ae 100644
--- a/src/vlibmemory/socket_client.c
+++ b/src/vlibmemory/socket_client.c
@@ -304,8 +304,18 @@ static void vl_api_sock_init_shm_reply_t_handler
new_name = format (0, "%v[shm]%c", scm->name, 0);
vl_client_install_client_message_handlers ();
- vl_client_connect_to_vlib_no_map ("pvt", (char *) new_name,
- 32 /* input_queue_length */ );
+ if (scm->want_shm_pthread)
+ {
+ vl_client_connect_to_vlib_no_map ("pvt", (char *) new_name,
+ 32 /* input_queue_length */ );
+ }
+ else
+ {
+ vl_client_connect_to_vlib_no_rx_pthread_no_map ("pvt",
+ (char *) new_name, 32
+ /* input_queue_length */
+ );
+ }
vl_socket_client_enable_disable (0);
vec_free (new_name);
}
@@ -402,13 +412,16 @@ vl_socket_client_connect (char *socket_path, char *client_name,
}
int
-vl_socket_client_init_shm (vl_api_shm_elem_config_t * config)
+vl_socket_client_init_shm (vl_api_shm_elem_config_t * config,
+ int want_pthread)
{
socket_client_main_t *scm = &socket_client_main;
vl_api_sock_init_shm_t *mp;
int rv, i;
u64 *cfg;
+ scm->want_shm_pthread = want_pthread;
+
mp = vl_socket_client_msg_alloc (sizeof (*mp) +
vec_len (config) * sizeof (u64));
clib_memset (mp, 0, sizeof (*mp));
diff --git a/src/vlibmemory/socket_client.h b/src/vlibmemory/socket_client.h
index 46e2c865250..68cd0f21994 100644
--- a/src/vlibmemory/socket_client.h
+++ b/src/vlibmemory/socket_client.h
@@ -40,6 +40,8 @@ typedef struct
u8 *name;
clib_time_t clib_time;
ssvm_private_t memfd_segment;
+
+ int want_shm_pthread;
} socket_client_main_t;
extern socket_client_main_t socket_client_main;
@@ -53,7 +55,8 @@ int vl_socket_client_read (int wait);
int vl_socket_client_write (void);
void vl_socket_client_enable_disable (int enable);
void *vl_socket_client_msg_alloc (int nbytes);
-int vl_socket_client_init_shm (vl_api_shm_elem_config_t * config);
+int vl_socket_client_init_shm (vl_api_shm_elem_config_t * config,
+ int want_pthread);
clib_error_t *vl_socket_client_recv_fd_msg (int fds[], int n_fds, u32 wait);
#endif /* SRC_VLIBMEMORY_SOCKET_CLIENT_H_ */