[Ns-bugs] [Bug 154] Attach sockets to nodes
bugzilla-daemon@nsnam-www.ece.gatech.edu
bugzilla-daemon at nsnam-www.ece.gatech.edu
Thu Mar 27 13:46:21 PDT 2008
http://www.nsnam.org/bugzilla/show_bug.cgi?id=154
------- Comment #7 from mathieu.lacage at sophia.inria.fr 2008-03-27 16:46 -------
(In reply to comment #6)
> The bottom line is that SOMEONE has to retain a reference to the socket
> throughout its lifetime. So far we have two alternatives, one being that the
> node retains references to its sockets (Gustavo's suggestion), the other being
> that the user of sockets (Applications or end-users) keeps a reference (current
> expectation).
>
> An approach we took in Tcp for a similar problem was simply to count the
> references to the socket that live in the Ipv4Endpoint demux:
> http://code.nsnam.org/ns-3-dev/rev/4956586bd798
>
> In UdpSocket::FinishBind, Note that "this" effectively copied into into the
> endpoint by passing the callback. It is never Ref'd however. Our fix was to
> pass a smart pointer into the callback, Ref'ing it in the process.
>
> This way, when the endpoint is deallocated, the smart pointer goes out of scope
> and Unrefs the socket. The assures that the lifetime of the socket is tied to
> the lifetime of its entry in the demux, which seems more correct to me.
What happens if a user releases the reference to the socket and he never calls
Close ?
>
> So a change similar to what we did in TcpSocket should do the trick.
>
(In reply to comment #6)
> The bottom line is that SOMEONE has to retain a reference to the socket
> throughout its lifetime. So far we have two alternatives, one being that the
> node retains references to its sockets (Gustavo's suggestion), the other being
> that the user of sockets (Applications or end-users) keeps a reference (current
> expectation).
>
> An approach we took in Tcp for a similar problem was simply to count the
> references to the socket that live in the Ipv4Endpoint demux:
> http://code.nsnam.org/ns-3-dev/rev/4956586bd798
>
> In UdpSocket::FinishBind, Note that "this" effectively copied into into the
> endpoint by passing the callback. It is never Ref'd however. Our fix was to
> pass a smart pointer into the callback, Ref'ing it in the process.
>
> This way, when the endpoint is deallocated, the smart pointer goes out of scope
> and Unrefs the socket. The assures that the lifetime of the socket is tied to
> the lifetime of its entry in the demux, which seems more correct to me.
>
> So a change similar to what we did in TcpSocket should do the trick.
I was thinking along similar lines but, for UDP, the lifetime of the socket is
much more problematic: i.e., it is not bound to an underlying stream which can
be closed or not by the remote side. So, if the user forgets to call Close, the
socket will live forever, even though it has data to send and cannot forward
its incoming data to anyone.
I might be worried about a non-issue though.
--
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Ns-bugs
mailing list