{
int n_to_read, n_read;
- n_to_read = svm_fifo_max_dequeue (s->rx_fifo);
+ n_to_read = svm_fifo_max_dequeue_cons (s->rx_fifo);
if (!n_to_read)
return;
while (n_to_read > 0);
}
-void
-client_handle_rx (echo_main_t * em, session_event_t * e, u8 * rx_buf)
-{
- echo_session_t *s;
-
- s = pool_elt_at_index (em->sessions, e->fifo->client_session_index);
- recv_data_chunk (em, s, rx_buf);
-}
-
static void
send_data_chunk (echo_main_t * em, echo_session_t * s)
{
pthread_exit (0);
}
-/*
- * Rx thread that handles all connections.
- *
- * Not used.
- */
-void *
-client_rx_thread_fn (void *arg)
-{
- session_event_t _e, *e = &_e;
- echo_main_t *em = &echo_main;
- static u8 *rx_buf = 0;
- svm_msg_q_msg_t msg;
-
- vec_validate (rx_buf, 1 << 20);
-
- while (!em->time_to_stop && em->state != STATE_READY)
- ;
-
- while (!em->time_to_stop)
- {
- svm_msg_q_sub (em->our_event_queue, &msg, SVM_Q_WAIT, 0);
- e = svm_msg_q_msg_data (em->our_event_queue, &msg);
- switch (e->event_type)
- {
- case FIFO_EVENT_APP_RX:
- client_handle_rx (em, e, rx_buf);
- break;
- default:
- clib_warning ("unknown event type %d", e->event_type);
- break;
- }
- svm_msg_q_free_msg (em->our_event_queue, &msg);
- }
- pthread_exit (0);
-}
-
void
client_send_connect (echo_main_t * em)
{
if (start_time == 0.0)
start_time = clib_time_now (&em->clib_time);
- ip_str = format (0, "%U", format_ip46_address, &mp->ip, mp->is_ip4);
+ ip_str = format (0, "%U", format_ip46_address, &mp->rmt.ip, mp->rmt.is_ip4);
clib_warning ("Accepted session from: %s:%d", ip_str,
- clib_net_to_host_u16 (mp->port));
+ clib_net_to_host_u16 (mp->rmt.port));
/* Allocate local session and set it up */
pool_get (em->sessions, session);
em->n_clients_connected += 1;
clib_warning ("session %u (0x%llx) connected with local ip %U port %d",
- session_index, mp->handle, format_ip46_address, mp->lcl_ip,
- mp->is_ip4, clib_net_to_host_u16 (mp->lcl_port));
+ session_index, mp->handle, format_ip46_address, &mp->lcl.ip,
+ mp->lcl.is_ip4, clib_net_to_host_u16 (mp->lcl.port));
}
static void
continue;
}
e = svm_msg_q_msg_data (em->our_event_queue, &msg);
- if (e->event_type != FIFO_EVENT_APP_RX)
+ if (e->event_type != SESSION_IO_EVT_RX)
handle_mq_event (e);
svm_msg_q_free_msg (em->our_event_queue, &msg);
}
u32 offset, to_dequeue;
echo_session_t *s;
- s = pool_elt_at_index (em->sessions, e->fifo->client_session_index);
+ s = pool_elt_at_index (em->sessions, e->session_index);
/* Clear event only once. Otherwise, if we do it in the loop by calling
* app_recv_stream, we may end up with a lot of unhandled rx events on the
* message queue */
svm_fifo_unset_event (s->rx_fifo);
- max_dequeue = svm_fifo_max_dequeue (s->rx_fifo);
+ max_dequeue = svm_fifo_max_dequeue_cons (s->rx_fifo);
if (PREDICT_FALSE (!max_dequeue))
return;
e = svm_msg_q_msg_data (em->our_event_queue, &msg);
switch (e->event_type)
{
- case FIFO_EVENT_APP_RX:
+ case SESSION_IO_EVT_RX:
server_handle_rx (em, e);
break;
default: