Bug 828

Summary: PacketSocket::Close does not unregister protocol handler
Product: ns-3 Reporter: Quincy Tse <quincy.tse>
Component: networkAssignee: Mathieu Lacage <mathieu.lacage>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, quincy.tse, tomh
Priority: P5    
Version: ns-3.7   
Hardware: All   
OS: All   
URL: http://groups.google.com.au/group/ns-3-users/browse_frm/thread/835f6d32208b841f
Attachments: Proposed patch.

Description Quincy Tse 2010-03-02 19:52:18 UTC
It seems that PacketSocket::Close doesn't work properly for me - I 
kept getting segfaults when packets are attempted to be forwarded 
through closed sockets that had already had the memory deallocated.

During a typical lifetime of a PacketSocket, the protocal handler is registered in the function PacketSocket::DoBind, executed on transiting from STATE_OPEN to STATE_BOUND. When transiting from STATE_BOUND to STATE_CONNECTED, the protocol remains registered. In order to clean up properly, the PacketSocket should unregister the protocol handler on close for the transitions STATE_BOUND->STATE_CLOSED and STATE_CONNECTED->STATE_CLOSED.

Platform and version: NS-3.7 on Linux 2.6.31-14 (amd64), gcc 4.4.1

Have not developed test code to reproduce the segfault.
Comment 1 Quincy Tse 2010-03-02 19:56:48 UTC
Created attachment 774 [details]
Proposed patch.
Comment 2 Quincy Tse 2010-03-02 20:00:59 UTC
Possibly related #649, #650
Comment 3 Quincy Tse 2010-05-23 21:49:54 UTC
Patch not yet applied to ns-3-dev or ns-3.8.
Comment 4 Tom Henderson 2010-05-24 09:24:40 UTC
I'll apply this in a day or so after testing, but just cc'ing ns-bugs in the meantime in case anyone has a comment.
Comment 5 Tom Henderson 2010-05-30 23:55:29 UTC
changeset:  7476f746ba5d