[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: about deleting TCP



> 	By the way, I thought the current method of realsing TCP 
> agent as following may have some problem. 
> 
> $tcp proc done {} "$ns_ detach-agent $node_ $tcp; delete $tcp"
> 
> 	Sometimes, when this line (which is in Http/Client) is
> executed, the context could be still in a Tcp Agent (e.g.,
> the Tcp Agent on client get a Http message and then pass it
> eventually to the Http/Client object by "target_"), if somehow
> the Http/Client decide to "disconnect" the connection and delete
> the very Tcp Agent where the execution context is still in, potential
> core-dump will be generated especially in my case when disconnect/connect
> are frequently. I suggest following change as:

That line only says: when tcp agent finishes transmission, done with all
acks, etc., then that done{} proc of the tcp agent is called. There are
only two places where the done{} is called in Tcp/Full, i.e., line 725 and
1716. In line 1716 (function recv()), it immediately returns after done{}
is called, thus, no member variable of the object is touched. Line 725
retuns to line 1584, which then goes to line 1736, which does
Packet::free(pkt) and then returns from recv(). It does not touch any
member variable either. So I don't think it'll cause a problem deleting
$tcp inside this done{} proc. Can you give a stack trace to illustrate why
this could be a problem? 

> Http/Client/Clnt instproc disconnect { server } {
>     set servWrapper [$self get-cnc $server]
>     set tcp [$servWrapper agent]
>     $tcp close
>     $ns_ at [$ns_ now] "$self cmd disconnect $server"
>     # detach the tcp agent and delete it
>     $ns_ at [$ns_ now] "$ns_ detach-agent $node_ $tcp;delete $tcp"
>     $server disconnect $self
> }

Once upon a time, it was done in this way. But when outstanding ack/fin
etc reaches this node, ns crashed because of no attached agent. If you are
really concerned about this, can u do something like this:

  $tcp proc done {} "$ns_ detach-agent $node_ $tcp; $ns_ at [$ns_ \
now] \"delete $tcp\""

> 	OK, I'll try to but need to learn how to do that first, what if
> the dump is within otcl? I'm a little puzzled about how to debug the
> mixture of otcl and c++ code:(

If that happens with otcl, often there will be a OTclDispatch()
	int OTclDispatch(ClientData cd, Tcl_Interp* in, int argc, char* argv[]) 
in the stack trace. If you go there and check the argv[] you'll have an
idea which otcl command triggered the core dump. But indeed, even you know
this it's still pretty hard to tell why it happened... 

- Haobo