[Ns-bugs] [Bug 244] PacketSink is not multitasking

bugzilla-daemon@nsnam-www.ece.gatech.edu bugzilla-daemon at nsnam-www.ece.gatech.edu
Fri Jul 11 12:21:47 PDT 2008


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





------- Comment #12 from tomh at tomh.org  2008-07-11 15:21 -------
(In reply to comment #11)
> The following is a snippet that verifies that the forked sockets upcall to
> HandleRead correctly already, and I verified this is due to the compiler
> generated (POD) copy constructors copying the socket base class callbacks.
> 
> @@ -102,6 +108,21 @@ void PacketSink::StopApplication()     /
> 
>  void PacketSink::HandleRead (Ptr<Socket> socket)
>  {
> +  if(socket != m_socket)
> +    {
> +      std::cout<<"HandleRead got an upcall from a forked socket"<<std::endl;
> +      std::list<Ptr<Socket> >::iterator i = m_socketList.begin();
> +      bool iOwnThisSocket = false;
> +      while(i != m_socketList.end())
> +        {
> +          if (*i == socket)
> +            {
> +              iOwnThisSocket = true;
> +            }
> +          ++i;
> +        }
> +      NS_ASSERT(iOwnThisSocket);
> +    }
>    Ptr<Packet> packet;
>    Address from;
>    while (packet = socket->RecvFrom (from))
> 

What seems to be happening is that the automatically generated copy constructor
of class Socket is copying the callback.  This is being done implicitly (the
copy constructor of TcpSocketImpl does not explicitly copy this callback).

So, it does seem to work, but raises the question of whether it should work
this way, implicitly.  A more explicit way to handle this would be to prevent
this particular callback (or all callbacks) from being copied implicitly by
implementing empty Socket copy constructor, then implement an explicit copy in
the application.

The reason that might be preferred is that, it works now, but that is an
artifact of the way that PacketSink is implemented.  It might be possible for
someone to implement an application for which this implicit copy of this
callback might be the wrong thing to do.


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