[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 12:22:24 PDT 2008


http://www.nsnam.org/bugzilla/show_bug.cgi?id=154





------- Comment #6 from raj.b at gatech.edu  2008-03-27 15:22 -------
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.


-- 
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