af-packet: handle possible exit of capture loop.

If a capture loop does exit, the thread needs to start without
synchronization with the other threads. This patch fixes this
by resetting the turn count on the peerslist structure and
adding a test on this condition in the wait function.
pull/57/merge
Eric Leblond 13 years ago committed by Victor Julien
parent 4d8f70c613
commit b2691cbe88

@ -389,6 +389,10 @@ TmEcode AFPPeersListAdd(AFPThreadVars *ptv)
int AFPPeersListWaitTurn(AFPPeer *peer)
{
/* If turn is zero, we already have started threads once */
if (peerslist.turn == 0)
return 0;
if (peer->turn == SC_ATOMIC_GET(peerslist.reached))
return 0;
return 1;
@ -396,7 +400,17 @@ int AFPPeersListWaitTurn(AFPPeer *peer)
void AFPPeersListReachedInc()
{
(void)SC_ATOMIC_ADD(peerslist.reached, 1);
if (peerslist.turn == 0)
return;
if (SC_ATOMIC_ADD(peerslist.reached, 1) == peerslist.turn) {
SCLogInfo("All AFP capture threads are running.");
(void)SC_ATOMIC_SET(peerslist.reached, 0);
/* Set turn to 0 to skip syncrhonization when ReceiveAFPLoop is
* restarted.
*/
peerslist.turn = 0;
}
}
/**

Loading…
Cancel
Save