chan_force_close()

Nicolas Williams Nicolas.Williams at ubsw.com
Wed Feb 6 08:29:40 EST 2002


How's this for nchan.c? I'm testing it with forkoff(X, 1) and -ddd/-vvv,
with and without -f, -f -f, and it's working just fine.

Nico

static
void
chan_force_close1(Channel *c)
{
	error("channel %d: dont know how to force an ssh1 channel closed");
}

static
void
chan_force_close2(Channel *c)
{
	if (c->ostate == CHAN_OUTPUT_CLOSED &&
	   c->istate == CHAN_INPUT_CLOSED &&
	   c->flags & CHAN_CLOSE_SENT)
		return;

	debug("channel %d: force close", c->self);

	c->ostate = CHAN_OUTPUT_CLOSED;
	c->istate = CHAN_INPUT_CLOSED;

	if (buffer_len(&c->output))
		buffer_consume(&c->output, buffer_len(&c->output));

	if (c->flags & CHAN_CLOSE_SENT)
		return;

	packet_start(SSH2_MSG_CHANNEL_CLOSE);
	packet_put_int(c->remote_id);
	packet_send();
	c->flags |= CHAN_CLOSE_SENT;

	chan_shutdown_read(c);
	chan_shutdown_write(c);
	channel_close_fds(c);
}

-- 
-DISCLAIMER: an automatically appended disclaimer may follow. By posting-
-to a public e-mail mailing list I hereby grant permission to distribute-
-and copy this message.-

Visit our website at http://www.ubswarburg.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.




More information about the openssh-unix-dev mailing list