summaryrefslogtreecommitdiff
path: root/nchan.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2002-01-22 23:27:45 +1100
committerDamien Miller <djm@mindrot.org>2002-01-22 23:27:45 +1100
commitfcfc43b617e707a7f073c0241029341ed0ebe211 (patch)
treecb8ca5ba07f562d223438d49ee90972830b94dbd /nchan.c
parent89a9232e414e7777d500a944a3fe7639d5e6c60f (diff)
- markus@cvs.openbsd.org 2002/01/14 13:34:07
[nchan.c] merge chan_[io]buf_empty[12]; ok provos@
Diffstat (limited to 'nchan.c')
-rw-r--r--nchan.c50
1 files changed, 13 insertions, 37 deletions
diff --git a/nchan.c b/nchan.c
index ff7607b9c..76674a76d 100644
--- a/nchan.c
+++ b/nchan.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: nchan.c,v 1.38 2002/01/14 13:22:35 markus Exp $"); 26RCSID("$OpenBSD: nchan.c,v 1.39 2002/01/14 13:34:07 markus Exp $");
27 27
28#include "ssh1.h" 28#include "ssh1.h"
29#include "ssh2.h" 29#include "ssh2.h"
@@ -159,8 +159,14 @@ chan_ibuf_empty1(Channel *c)
159 } 159 }
160 switch (c->istate) { 160 switch (c->istate) {
161 case CHAN_INPUT_WAIT_DRAIN: 161 case CHAN_INPUT_WAIT_DRAIN:
162 chan_send_ieof1(c); 162 if (compat20) {
163 chan_set_istate(c, CHAN_INPUT_WAIT_OCLOSE); 163 if (!(c->flags & CHAN_CLOSE_SENT))
164 chan_send_eof2(c);
165 chan_set_istate(c, CHAN_INPUT_CLOSED);
166 } else {
167 chan_send_ieof1(c);
168 chan_set_istate(c, CHAN_INPUT_WAIT_OCLOSE);
169 }
164 break; 170 break;
165 default: 171 default:
166 error("channel %d: chan_ibuf_empty for istate %d", 172 error("channel %d: chan_ibuf_empty for istate %d",
@@ -218,7 +224,8 @@ chan_obuf_empty1(Channel *c)
218 switch (c->ostate) { 224 switch (c->ostate) {
219 case CHAN_OUTPUT_WAIT_DRAIN: 225 case CHAN_OUTPUT_WAIT_DRAIN:
220 chan_shutdown_write(c); 226 chan_shutdown_write(c);
221 chan_send_oclose1(c); 227 if (!compat20)
228 chan_send_oclose1(c);
222 chan_set_ostate(c, CHAN_OUTPUT_CLOSED); 229 chan_set_ostate(c, CHAN_OUTPUT_CLOSED);
223 break; 230 break;
224 default: 231 default:
@@ -301,23 +308,7 @@ chan_rcvd_oclose2(Channel *c)
301static void 308static void
302chan_ibuf_empty2(Channel *c) 309chan_ibuf_empty2(Channel *c)
303{ 310{
304 debug("channel %d: ibuf empty", c->self); 311 chan_ibuf_empty1(c);
305 if (buffer_len(&c->input)) {
306 error("channel %d: chan_ibuf_empty for non empty buffer",
307 c->self);
308 return;
309 }
310 switch (c->istate) {
311 case CHAN_INPUT_WAIT_DRAIN:
312 if (!(c->flags & CHAN_CLOSE_SENT))
313 chan_send_eof2(c);
314 chan_set_istate(c, CHAN_INPUT_CLOSED);
315 break;
316 default:
317 error("channel %d: chan_ibuf_empty for istate %d",
318 c->self, c->istate);
319 break;
320 }
321} 312}
322static void 313static void
323chan_rcvd_ieof2(Channel *c) 314chan_rcvd_ieof2(Channel *c)
@@ -348,22 +339,7 @@ chan_write_failed2(Channel *c)
348static void 339static void
349chan_obuf_empty2(Channel *c) 340chan_obuf_empty2(Channel *c)
350{ 341{
351 debug("channel %d: obuf empty", c->self); 342 chan_obuf_empty1(c);
352 if (buffer_len(&c->output)) {
353 error("channel %d: chan_obuf_empty for non empty buffer",
354 c->self);
355 return;
356 }
357 switch (c->ostate) {
358 case CHAN_OUTPUT_WAIT_DRAIN:
359 chan_shutdown_write(c);
360 chan_set_ostate(c, CHAN_OUTPUT_CLOSED);
361 break;
362 default:
363 error("channel %d: chan_obuf_empty for ostate %d",
364 c->self, c->ostate);
365 break;
366 }
367} 343}
368static void 344static void
369chan_send_eof2(Channel *c) 345chan_send_eof2(Channel *c)