Skip to content

Commit

Permalink
Fix malfunction of multiple Libevent2ManualEvent instances.
Browse files Browse the repository at this point in the history
Two fields were erroneously "__gshared", which implies "static" and thus caused the fields to be shared among all instances.
  • Loading branch information
s-ludwig committed May 6, 2013
1 parent 97d87cc commit bf65a19
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions source/vibe/core/drivers/libevent2.d
Expand Up @@ -326,9 +326,9 @@ class Libevent2ManualEvent : ManualEvent {
deimos.event2.event.event* event;
bool[Task] tasks;
}
shared int m_emitCount = 0;
__gshared core.sync.mutex.Mutex m_mutex;
__gshared HashMap!(Thread, ThreadSlot) m_waiters;
shared(int) m_emitCount = 0;
core.sync.mutex.Mutex m_mutex;
HashMap!(Thread, ThreadSlot) m_waiters;
}

this()
Expand All @@ -349,7 +349,7 @@ class Libevent2ManualEvent : ManualEvent {
{
atomicOp!"+="(m_emitCount, 1);
synchronized (m_mutex) {
foreach (sl; m_waiters)
foreach (ref sl; m_waiters)
event_active(sl.event, 0, 0);
}
}
Expand All @@ -362,7 +362,6 @@ class Libevent2ManualEvent : ManualEvent {
int wait(int reference_emit_count)
{
assert(!amOwner());
auto self = Fiber.getThis();
acquire();
scope(exit) release();
auto ec = this.emitCount;
Expand All @@ -376,11 +375,12 @@ class Libevent2ManualEvent : ManualEvent {
int wait(Duration timeout, int reference_emit_count)
{
assert(!amOwner());
auto self = Fiber.getThis();
acquire();
scope(exit) release();
scope tm = new Libevent2Timer(cast(Libevent2Driver)getEventDriver(), null);
tm.rearm(timeout);
tm.acquire();
scope(exit) tm.release();

auto ec = this.emitCount;
while( ec == reference_emit_count ){
Expand Down

0 comments on commit bf65a19

Please sign in to comment.