mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 00:28:21 +00:00
Next version of the threading queue deadlock fix.
We now just use the read/write counters, as suggested by Gilbert.
This commit is contained in:
parent
fbdbe6d35b
commit
64812daa50
2 changed files with 2 additions and 12 deletions
|
@ -82,17 +82,7 @@ double Manager::NextTimestamp(double* network_time)
|
||||||
{
|
{
|
||||||
MsgThread* t = *i;
|
MsgThread* t = *i;
|
||||||
|
|
||||||
// We check here if there's something ready to read from the
|
if ( (*i)->MightHaveOut() && ! t->Killed() )
|
||||||
// queue. Normally the queue will tell us that reliably via
|
|
||||||
// MightHaveOut() because we keep sending heartbeats that
|
|
||||||
// will ensure that the method will eventually return true.
|
|
||||||
// However, when running without network source and without
|
|
||||||
// any communication, the timer_manager's time will always
|
|
||||||
// remain at 1.0, which means that heartbeats will never be
|
|
||||||
// triggered. In that case, we make sure to still process our
|
|
||||||
// threads from time to time.
|
|
||||||
if ( ((*i)->MightHaveOut() && ! t->Killed())
|
|
||||||
|| (timer_mgr->Time() == 1.0 && random() % 10000 == 0) )
|
|
||||||
return timer_mgr->Time();
|
return timer_mgr->Time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
* it is empty. In other words, this method helps to avoid locking the queue
|
* it is empty. In other words, this method helps to avoid locking the queue
|
||||||
* frequently, but doesn't allow you to forgo it completely.
|
* frequently, but doesn't allow you to forgo it completely.
|
||||||
*/
|
*/
|
||||||
bool MaybeReady() { return (read_ptr != write_ptr); }
|
bool MaybeReady() { return (num_reads != num_writes); }
|
||||||
|
|
||||||
/** Wake up the reader if it's currently blocked for input. This is
|
/** Wake up the reader if it's currently blocked for input. This is
|
||||||
primarily to give it a chance to check termination quickly.
|
primarily to give it a chance to check termination quickly.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue