Closed gegles closed 2 years ago
@breese this is the best i could do so far.... It compiles and seems to accept the first socket but then I get runtime exception from socket.ipp:316
receive_output_queue.emplace(std::move(operation));
I haven't dug much into your code yet, but I suspect that you keep track of the socket by their address pointer which is now disrupted by moving the socket around....
I also had to "fix" socket move-constructor logic for things to work (with the shared_ptr).
Appreciate any help to put me on the right track...
Your intuition about addresses is correct.
The multiplexer
keeps track of the mapping between remote endpoints and datagram::socket
s, and it uses the a non-owning pointer for that. The socket
is responsible for adding and removing itself.
The remote endpoint only becomes available when the acceptor
detects a remote connection, at which point we set the multiplexer
on the socket
. This lazy construction means that the socket
destructor must check if multiplexer
has been set.
Now, what happens is that the socket
move constructor moves the multiplexer
leaving the moved-from socket with an empty multiplexer
, so when the destructor of the moved-from socket is called it does not remove itself from the multiplexer
because it has none.
Draft PR to converse about #2