Fix out of order processing issue with the TCP connection callback.
It could happen that the socket FD got reused before the connection callback was cleared. This in turn could result in the new connection callback to get overwritten with null.
This commit is contained in:
parent
4703f021ec
commit
956978cc79
|
@ -43,6 +43,8 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets
|
||||||
|
|
||||||
final override StreamSocketFD connectStream(scope Address address, scope Address bind_address, ConnectCallback on_connect)
|
final override StreamSocketFD connectStream(scope Address address, scope Address bind_address, ConnectCallback on_connect)
|
||||||
{
|
{
|
||||||
|
assert(on_connect !is null);
|
||||||
|
|
||||||
auto sockfd = createSocket(address.addressFamily, SOCK_STREAM);
|
auto sockfd = createSocket(address.addressFamily, SOCK_STREAM);
|
||||||
if (sockfd == -1) return StreamSocketFD.invalid;
|
if (sockfd == -1) return StreamSocketFD.invalid;
|
||||||
|
|
||||||
|
@ -105,8 +107,10 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets
|
||||||
m_loop.setNotifyCallback!(EventType.write)(sock, null);
|
m_loop.setNotifyCallback!(EventType.write)(sock, null);
|
||||||
with (m_loop.m_fds[sock].streamSocket) {
|
with (m_loop.m_fds[sock].streamSocket) {
|
||||||
state = ConnectionState.connected;
|
state = ConnectionState.connected;
|
||||||
connectCallback(cast(StreamSocketFD)sock, ConnectStatus.connected);
|
assert(connectCallback !is null);
|
||||||
|
auto cb = connectCallback;
|
||||||
connectCallback = null;
|
connectCallback = null;
|
||||||
|
cb(cast(StreamSocketFD)sock, ConnectStatus.connected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue