Ensure proper reference count for created Posix events.
This commit is contained in:
parent
7795195ec1
commit
4d00376873
|
@ -50,6 +50,7 @@ final class PosixEventDriverEvents(Loop : PosixEventLoop, Sockets : EventDriverS
|
||||||
m_loop.registerFD(id, EventMask.read);
|
m_loop.registerFD(id, EventMask.read);
|
||||||
m_loop.setNotifyCallback!(EventType.read)(id, &onEvent);
|
m_loop.setNotifyCallback!(EventType.read)(id, &onEvent);
|
||||||
releaseRef(id); // setNotifyCallback increments the reference count, but we need a value of 1 upon return
|
releaseRef(id); // setNotifyCallback increments the reference count, but we need a value of 1 upon return
|
||||||
|
assert(getRC(id) == 1);
|
||||||
return id;
|
return id;
|
||||||
} else {
|
} else {
|
||||||
auto addr = new InternetAddress(0x7F000001, 0);
|
auto addr = new InternetAddress(0x7F000001, 0);
|
||||||
|
@ -58,7 +59,9 @@ final class PosixEventDriverEvents(Loop : PosixEventLoop, Sockets : EventDriverS
|
||||||
m_sockets.receive(s, m_buf, IOMode.once, &onSocketData);
|
m_sockets.receive(s, m_buf, IOMode.once, &onSocketData);
|
||||||
m_events[s] = EventSlot(new ConsumableQueue!EventCallback, false, is_internal); // FIXME: avoid dynamic memory allocation
|
m_events[s] = EventSlot(new ConsumableQueue!EventCallback, false, is_internal); // FIXME: avoid dynamic memory allocation
|
||||||
m_sockets.releaseRef(s); // receive() increments the reference count, but we need a value of 1 upon return
|
m_sockets.releaseRef(s); // receive() increments the reference count, but we need a value of 1 upon return
|
||||||
return cast(EventID)s;
|
auto id = cast(EventID)s;
|
||||||
|
assert(getRC(id) == 1);
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue