flow queue handler: use int16_t

Use int16_t instead of int to store the autofp queue id. We should
not easily get to 32k threads so 2 bytes per flow is sufficient.
pull/2070/head
Victor Julien 11 years ago
parent ba64069b35
commit be714a2f02

@ -4907,7 +4907,7 @@ static void TcpSessionReuseHandle(Packet *p) {
/* get some settings that we move over to the new flow */ /* get some settings that we move over to the new flow */
FlowThreadId thread_id = old_f->thread_id; FlowThreadId thread_id = old_f->thread_id;
int autofp_tmqh_flow_qid = SC_ATOMIC_GET(old_f->autofp_tmqh_flow_qid); int16_t autofp_tmqh_flow_qid = SC_ATOMIC_GET(old_f->autofp_tmqh_flow_qid);
/* disconnect the packet from the old flow */ /* disconnect the packet from the old flow */
FlowHandlePacketUpdateRemove(p->flow, p); FlowHandlePacketUpdateRemove(p->flow, p);

@ -289,13 +289,12 @@ void TmqhOutputFlowActivePackets(ThreadVars *tv, Packet *p)
TmqhFlowCtx *ctx = (TmqhFlowCtx *)tv->outctx; TmqhFlowCtx *ctx = (TmqhFlowCtx *)tv->outctx;
/* if no flow we use the first queue, /* if no flow we round robin the packets over the queues */
* should be rare */
if (p->flow != NULL) { if (p->flow != NULL) {
qid = SC_ATOMIC_GET(p->flow->autofp_tmqh_flow_qid); qid = SC_ATOMIC_GET(p->flow->autofp_tmqh_flow_qid);
if (qid == -1) { if (qid == -1) {
uint16_t i = 0; int16_t i = 0;
int lowest_id = 0; int16_t lowest_id = 0;
TmqhFlowMode *queues = ctx->queues; TmqhFlowMode *queues = ctx->queues;
uint32_t lowest = queues[i].q->len; uint32_t lowest = queues[i].q->len;
for (i = 1; i < ctx->size; i++) { for (i = 1; i < ctx->size; i++) {
@ -350,7 +349,7 @@ void TmqhOutputFlowHash(ThreadVars *tv, Packet *p)
addr >>= 7; addr >>= 7;
/* we don't have to worry about possible overflow, since /* we don't have to worry about possible overflow, since
* ctx->size will be lesser than 2 ** 31 for sure */ * ctx->size will be less than 2 ** 15 for sure */
qid = addr % ctx->size; qid = addr % ctx->size;
(void) SC_ATOMIC_SET(p->flow->autofp_tmqh_flow_qid, qid); (void) SC_ATOMIC_SET(p->flow->autofp_tmqh_flow_qid, qid);
(void) SC_ATOMIC_ADD(ctx->queues[qid].total_flows, 1); (void) SC_ATOMIC_ADD(ctx->queues[qid].total_flows, 1);

@ -39,7 +39,7 @@ typedef struct TmqhFlowCtx_ {
TmqhFlowMode *queues; TmqhFlowMode *queues;
SC_ATOMIC_DECLARE(uint16_t, round_robin_idx); SC_ATOMIC_DECLARE(int16_t, round_robin_idx);
} TmqhFlowCtx; } TmqhFlowCtx;
void TmqhFlowRegister (void); void TmqhFlowRegister (void);

Loading…
Cancel
Save