Indentation fixes

remotes/origin/master-1.1.x
Anoop Saldanha 14 years ago committed by Victor Julien
parent e68ca2f32f
commit 99a496e852

@ -481,52 +481,53 @@ static int FlowPrune(FlowQueue *q, struct timeval *ts, int try_cnt)
} }
Flow *f = q->top; Flow *f = q->top;
/* label */ /* label */
while (f != NULL) { while (f != NULL) {
if (try_cnt != 0 && try_cnt_temp == try_cnt) { if (try_cnt != 0 && try_cnt_temp == try_cnt) {
SCMutexUnlock(&q->mutex_q); SCMutexUnlock(&q->mutex_q);
return cnt; return cnt;
} }
try_cnt_temp++; try_cnt_temp++;
if (f == NULL) { if (f == NULL) {
SCMutexUnlock(&q->mutex_q); SCMutexUnlock(&q->mutex_q);
SCLogDebug("top is null"); SCLogDebug("top is null");
#ifdef FLOW_PRUNE_DEBUG #ifdef FLOW_PRUNE_DEBUG
prune_queue_empty++; prune_queue_empty++;
#endif #endif
return cnt; return cnt;
} }
if (SCMutexTrylock(&f->m) != 0) { if (SCMutexTrylock(&f->m) != 0) {
SCLogDebug("cant lock 1"); SCLogDebug("cant lock 1");
#ifdef FLOW_PRUNE_DEBUG #ifdef FLOW_PRUNE_DEBUG
prune_flow_lock++; prune_flow_lock++;
#endif #endif
f = f->lnext; f = f->lnext;
continue; continue;
} }
if (SCSpinTrylock(&f->fb->s) != 0) { if (SCSpinTrylock(&f->fb->s) != 0) {
SCMutexUnlock(&f->m); SCMutexUnlock(&f->m);
SCLogDebug("cant lock 2"); SCLogDebug("cant lock 2");
#ifdef FLOW_PRUNE_DEBUG #ifdef FLOW_PRUNE_DEBUG
prune_bucket_lock++; prune_bucket_lock++;
#endif #endif
f = f->lnext; f = f->lnext;
continue; continue;
} }
/*set the timeout value according to the flow operating mode, flow's state /*set the timeout value according to the flow operating mode, flow's state
and protocol.*/ and protocol.*/
uint32_t timeout = 0; uint32_t timeout = 0;
if (flow_flags & FLOW_EMERGENCY) { if (flow_flags & FLOW_EMERGENCY) {
if (flow_proto[f->protomap].GetProtoState != NULL) { if (flow_proto[f->protomap].GetProtoState != NULL) {
switch(flow_proto[f->protomap].GetProtoState(f->protoctx)) { switch(flow_proto[f->protomap].GetProtoState(f->protoctx)) {
case FLOW_STATE_NEW: case FLOW_STATE_NEW:
timeout = flow_proto[f->protomap].emerg_new_timeout; timeout = flow_proto[f->protomap].emerg_new_timeout;
break; break;
@ -536,16 +537,16 @@ static int FlowPrune(FlowQueue *q, struct timeval *ts, int try_cnt)
case FLOW_STATE_CLOSED: case FLOW_STATE_CLOSED:
timeout = flow_proto[f->protomap].emerg_closed_timeout; timeout = flow_proto[f->protomap].emerg_closed_timeout;
break; break;
}
} else {
if (f->flags & FLOW_EST_LIST)
timeout = flow_proto[f->protomap].emerg_est_timeout;
else
timeout = flow_proto[f->protomap].emerg_new_timeout;
} }
} else { } else { /* implies no emergency */
if (f->flags & FLOW_EST_LIST) if (flow_proto[f->protomap].GetProtoState != NULL) {
timeout = flow_proto[f->protomap].emerg_est_timeout; switch(flow_proto[f->protomap].GetProtoState(f->protoctx)) {
else
timeout = flow_proto[f->protomap].emerg_new_timeout;
}
} else { /* implies no emergency */
if (flow_proto[f->protomap].GetProtoState != NULL) {
switch(flow_proto[f->protomap].GetProtoState(f->protoctx)) {
case FLOW_STATE_NEW: case FLOW_STATE_NEW:
timeout = flow_proto[f->protomap].new_timeout; timeout = flow_proto[f->protomap].new_timeout;
break; break;
@ -555,80 +556,80 @@ static int FlowPrune(FlowQueue *q, struct timeval *ts, int try_cnt)
case FLOW_STATE_CLOSED: case FLOW_STATE_CLOSED:
timeout = flow_proto[f->protomap].closed_timeout; timeout = flow_proto[f->protomap].closed_timeout;
break; break;
}
} else {
if (f->flags & FLOW_EST_LIST)
timeout = flow_proto[f->protomap].est_timeout;
else
timeout = flow_proto[f->protomap].new_timeout;
} }
} else {
if (f->flags & FLOW_EST_LIST)
timeout = flow_proto[f->protomap].est_timeout;
else
timeout = flow_proto[f->protomap].new_timeout;
} }
}
SCLogDebug("got lock, now check: %" PRIdMAX "+%" PRIu32 "=(%" PRIdMAX ") < " SCLogDebug("got lock, now check: %" PRIdMAX "+%" PRIu32 "=(%" PRIdMAX ") < "
"%" PRIdMAX "", (intmax_t)f->lastts_sec, "%" PRIdMAX "", (intmax_t)f->lastts_sec,
timeout, (intmax_t)f->lastts_sec + timeout, timeout, (intmax_t)f->lastts_sec + timeout,
(intmax_t)ts->tv_sec); (intmax_t)ts->tv_sec);
/* do the timeout check */ /* do the timeout check */
if ((int32_t)(f->lastts_sec + timeout) >= ts->tv_sec) { if ((int32_t)(f->lastts_sec + timeout) >= ts->tv_sec) {
SCSpinUnlock(&f->fb->s); SCSpinUnlock(&f->fb->s);
SCMutexUnlock(&f->m); SCMutexUnlock(&f->m);
SCMutexUnlock(&q->mutex_q); SCMutexUnlock(&q->mutex_q);
SCLogDebug("timeout check failed"); SCLogDebug("timeout check failed");
#ifdef FLOW_PRUNE_DEBUG #ifdef FLOW_PRUNE_DEBUG
prune_no_timeout++; prune_no_timeout++;
#endif #endif
return cnt; return cnt;
} }
/** never prune a flow that is used by a packet or stream msg /** never prune a flow that is used by a packet or stream msg
* we are currently processing in one of the threads */ * we are currently processing in one of the threads */
if (SC_ATOMIC_GET(f->use_cnt) > 0) { if (SC_ATOMIC_GET(f->use_cnt) > 0) {
SCLogDebug("timed out but use_cnt > 0: %"PRIu16", %p, proto %"PRIu8"", SC_ATOMIC_GET(f->use_cnt), f, f->proto); SCLogDebug("timed out but use_cnt > 0: %"PRIu16", %p, proto %"PRIu8"", SC_ATOMIC_GET(f->use_cnt), f, f->proto);
SCLogDebug("it is in one of the threads"); SCLogDebug("it is in one of the threads");
#ifdef FLOW_PRUNE_DEBUG #ifdef FLOW_PRUNE_DEBUG
prune_usecnt++; prune_usecnt++;
#endif #endif
Flow *prev_f = f; Flow *prev_f = f;
f = f->lnext; f = f->lnext;
SCSpinUnlock(&prev_f->fb->s); SCSpinUnlock(&prev_f->fb->s);
SCMutexUnlock(&prev_f->m); SCMutexUnlock(&prev_f->m);
continue; continue;
} }
if (FlowForceReassemblyForFlowV2(f) == 1) { if (FlowForceReassemblyForFlowV2(f) == 1) {
Flow *prev_f = f; Flow *prev_f = f;
f = f->lnext; f = f->lnext;
SCMutexUnlock(&prev_f->m); SCMutexUnlock(&prev_f->m);
continue; continue;
} }
/* this should not be possible */ /* this should not be possible */
BUG_ON(SC_ATOMIC_GET(f->use_cnt) > 0); BUG_ON(SC_ATOMIC_GET(f->use_cnt) > 0);
/* remove from the hash */ /* remove from the hash */
if (f->hprev) if (f->hprev)
f->hprev->hnext = f->hnext; f->hprev->hnext = f->hnext;
if (f->hnext) if (f->hnext)
f->hnext->hprev = f->hprev; f->hnext->hprev = f->hprev;
if (f->fb->f == f) if (f->fb->f == f)
f->fb->f = f->hnext; f->fb->f = f->hnext;
f->hnext = NULL; f->hnext = NULL;
f->hprev = NULL; f->hprev = NULL;
SCSpinUnlock(&f->fb->s); SCSpinUnlock(&f->fb->s);
f->fb = NULL; f->fb = NULL;
cnt++; cnt++;
FlowClearMemory (f, f->protomap); FlowClearMemory (f, f->protomap);
Flow *next_flow = f->lnext; Flow *next_flow = f->lnext;
/* move to spare list */ /* move to spare list */
FlowRequeue(f, q, &flow_spare_q, 0); FlowRequeue(f, q, &flow_spare_q, 0);
SCMutexUnlock(&f->m); SCMutexUnlock(&f->m);
f = next_flow; f = next_flow;
} }

Loading…
Cancel
Save