Re: Channel close confirmation

[email protected] (Jonas Borgström) 29 Aug 2002 00:50:47 +0200
Newsgroups gmane.network.beep.roadrunner.general
Message-ID <[email protected]>
Matt Small <[email protected]> writes:

> I'm trying to wait until I've closed a channel before going to close other
> channels.. for instance, from the syslog reliable rfc:
> 
> L: <close number='1' code='200' />
> I: <ok />
> { check the order here; the <ok /> must be sent before the new close is
> 	sent }
> I: <close number='0' code='200' />
> L: <ok />
> 
> I can check a variable (locked, obviously) before I close channel 0, but where
> can I set this variable after I've received the confirmation from the close
> of channel 1?  I thought that close_confirmation() would be the right answer,
> but that seems to be too early in the close process.
> 
Hi Matt,

You are correct, close_confirmation is called before the actual "<ok />" message
has been sent.

This is what RoadRunner does (in rr-manager.c:handle_incoming_close() ):

1 - close_confirmation () is invoked
2 - the channel is removed from the list of active channels and unref:ed
3 - the <ok /> message is placed on the out queue for channel 0

So what you want is to know when the <ok /> reply has been transmitted. The
problem is that there doesn't exist any easy way to do this.

One way would be to do like this.

1 - set a flag in close_confirmation ()
2 - when the initiator notices that close_confirmation has been invoked then
    use rr_channel_flush (manager) to make sure that all pending frames are
    sent.
3 - call rr_connection_disconnect ()

But this still wouldn't always work, because rr_channel_flush might be called
_before_ the <ok /> message is enqueued.

So the only thing I can think of now is to change RRManager to enqueue the
close reply before calling close_confirmation. But I haven't yet tested if that
would break something else.

/ Jonas
-- 
Jonas Borgström                  [email protected]
CodeFactory AB                   http://www.codefactory.se/
Office: +46 (0)90 71 86 10       Cell: +46 (0)70 248 89 58