hash_foreach (handle, sm_index, app_wrk->listeners_table, ({
listener = listen_session_get_from_handle (handle);
if (listener->session_type == sst
- && listener->enqueue_epoch != SESSION_PROXY_LISTENER_INDEX)
+ && !(listener->flags & SESSION_F_PROXY))
return listener;
}));
/* *INDENT-ON* */
/* *INDENT-OFF* */
hash_foreach (handle, sm_index, app_wrk->listeners_table, ({
listener = listen_session_get_from_handle (handle);
- if (listener->session_type == sst
- && listener->enqueue_epoch == SESSION_PROXY_LISTENER_INDEX)
+ if (listener->session_type == sst && (listener->flags & SESSION_F_PROXY))
return listener;
}));
/* *INDENT-ON* */
s = session_alloc (thread_index);
s->session_type = session_type_from_proto_and_ip (tc->proto, tc->is_ip4);
- s->enqueue_epoch = (u64) ~ 0;
s->session_state = SESSION_STATE_CLOSED;
/* Attach transport to session and vice versa */
session_worker_t *wrk;
wrk = session_main_get_worker (s->thread_index);
- if (s->enqueue_epoch != wrk->current_enqueue_epoch[tc->proto])
+ if (!(s->flags & SESSION_F_RX_EVT))
{
- s->enqueue_epoch = wrk->current_enqueue_epoch[tc->proto];
+ s->flags |= SESSION_F_RX_EVT;
vec_add1 (wrk->session_to_enqueue[tc->proto], s->session_index);
}
}
session_worker_t *wrk;
wrk = session_main_get_worker (s->thread_index);
- if (s->enqueue_epoch != wrk->current_enqueue_epoch[proto])
+ if (!(s->flags & SESSION_F_RX_EVT))
{
- s->enqueue_epoch = wrk->current_enqueue_epoch[proto];
+ s->flags |= SESSION_F_RX_EVT;
vec_add1 (wrk->session_to_enqueue[proto], s->session_index);
}
}
}));
/* *INDENT-ON* */
+ s->flags &= ~SESSION_F_RX_EVT;
if (PREDICT_FALSE (app_worker_lock_and_send_event (app_wrk, s,
SESSION_IO_EVT_RX)))
return -1;
vec_reset_length (indices);
wrk->session_to_enqueue[transport_proto] = indices;
- wrk->current_enqueue_epoch[transport_proto]++;
return errors;
}
vlib_thread_main_t *vtm = vlib_get_thread_main ();
u32 num_threads, preallocated_sessions_per_worker;
session_worker_t *wrk;
- int i, j;
+ int i;
num_threads = 1 /* main thread */ + vtm->n_threads;
/* Allocate cache line aligned worker contexts */
vec_validate_aligned (smm->wrk, num_threads - 1, CLIB_CACHE_LINE_BYTES);
- for (i = 0; i < TRANSPORT_N_PROTO; i++)
- {
- for (j = 0; j < num_threads; j++)
- smm->wrk[j].current_enqueue_epoch[i] = 1;
- }
-
for (i = 0; i < num_threads; i++)
{
wrk = &smm->wrk[i];
#include <svm/message_queue.h>
#include <svm/ssvm.h>
-#define SESSION_PROXY_LISTENER_INDEX ((u8)~0 - 1)
-
#define foreach_session_input_error \
_(NO_SESSION, "No session drops") \
_(NO_LISTENER, "No listener for dst port drops") \
/** vlib_time_now last time around the track */
f64 last_vlib_time;
- /** Per-proto enqueue epoch counters */
- u64 current_enqueue_epoch[TRANSPORT_N_PROTO];
-
/** Per-proto vector of sessions to enqueue */
u32 *session_to_enqueue[TRANSPORT_N_PROTO];
SESSION_STATE_N_STATES,
} session_state_t;
+typedef enum session_flags_
+{
+ SESSION_F_RX_EVT,
+ SESSION_F_PROXY
+} session_flags_t;
+
typedef struct session_
{
/** Pointers to rx/tx buffers. Once allocated, these do not move */
/** Index of the thread that allocated the session */
u8 thread_index;
- /** Tracks last enqueue epoch to avoid generating multiple enqueue events */
- u64 enqueue_epoch;
+ /** Session flags. See @ref session_flags_t */
+ u32 flags;
/** Index of the transport connection associated to the session */
u32 connection_index;