/* Made any progress? */
if (actual_transfer <= 0)
{
+ http_server_sessions_reader_unlock ();
vlib_process_suspend (vm, delay);
+ http_server_sessions_reader_lock ();
+
/* 10s deadman timer */
if (vlib_time_now (vm) > last_sent_timer + 10.0)
{
/* Save the args (pointer) in the node runtime */
save_args = vlib_node_get_runtime_data (vm, n->index);
- *save_args = args;
+ *save_args = clib_mem_alloc (sizeof (*args));
+ clib_memcpy_fast (*save_args, args, sizeof (*args));
vlib_start_process (vm, n->runtime_index);
}
static int
http_server_rx_callback (session_t * s)
{
- http_server_args *args;
+ http_server_args args;
http_session_t *hs;
int rv;
return rv;
/* send the command to a new/recycled vlib process */
- args = clib_mem_alloc (sizeof (*args));
- args->hs_index = hs->session_index;
- args->thread_index = hs->thread_index;
+ args.hs_index = hs->session_index;
+ args.thread_index = hs->thread_index;
http_server_sessions_reader_unlock ();
- /* Send an RPC request via the thread-0 input node */
+ /* Send RPC request to main thread */
if (vlib_get_thread_index () != 0)
- session_send_rpc_evt_to_thread (0, alloc_http_process_callback, args);
+ vlib_rpc_call_main_thread (alloc_http_process_callback, (u8 *) & args,
+ sizeof (args));
else
- alloc_http_process (args);
+ alloc_http_process (&args);
return 0;
}
vlib_cli_command_t * cmd)
{
http_server_main_t *hsm = &http_server_main;
+ unformat_input_t _line_input, *line_input = &_line_input;
u64 seg_size;
u8 *html;
int rv;
hsm->private_segment_size = 0;
hsm->fifo_size = 0;
hsm->is_static = 0;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+
+ /* Get a line of input. */
+ if (!unformat_user (input, unformat_line_input, line_input))
+ goto start_server;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (input, "static"))
+ if (unformat (line_input, "static"))
hsm->is_static = 1;
- else if (unformat (input, "prealloc-fifos %d", &hsm->prealloc_fifos))
+ else
+ if (unformat (line_input, "prealloc-fifos %d", &hsm->prealloc_fifos))
;
- else if (unformat (input, "private-segment-size %U",
+ else if (unformat (line_input, "private-segment-size %U",
unformat_memory_size, &seg_size))
{
if (seg_size >= 0x100000000ULL)
}
hsm->private_segment_size = seg_size;
}
- else if (unformat (input, "fifo-size %d", &hsm->fifo_size))
+ else if (unformat (line_input, "fifo-size %d", &hsm->fifo_size))
hsm->fifo_size <<= 10;
- else if (unformat (input, "uri %s", &hsm->uri))
+ else if (unformat (line_input, "uri %s", &hsm->uri))
;
else
return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ format_unformat_error, line_input);
}
+ unformat_free (line_input);
+
+start_server:
+
if (hsm->my_client_index != (u32) ~ 0)
return clib_error_return (0, "test http server is already running");