Deleted Added
full compact
nchan.c (181111) nchan.c (192595)
1/* $OpenBSD: nchan.c,v 1.60 2008/06/30 12:16:02 djm Exp $ */
1/* $OpenBSD: nchan.c,v 1.62 2008/11/07 18:50:18 stevesk Exp $ */
2/*
3 * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 372 unchanged lines hidden (view full) ---

382chan_send_eow2(Channel *c)
383{
384 debug2("channel %d: send eow", c->self);
385 if (c->ostate == CHAN_OUTPUT_CLOSED) {
386 error("channel %d: must not sent eow on closed output",
387 c->self);
388 return;
389 }
2/*
3 * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 372 unchanged lines hidden (view full) ---

382chan_send_eow2(Channel *c)
383{
384 debug2("channel %d: send eow", c->self);
385 if (c->ostate == CHAN_OUTPUT_CLOSED) {
386 error("channel %d: must not sent eow on closed output",
387 c->self);
388 return;
389 }
390 if (!(datafellows & SSH_NEW_OPENSSH))
391 return;
390 packet_start(SSH2_MSG_CHANNEL_REQUEST);
391 packet_put_int(c->remote_id);
392 packet_put_cstring("eow@openssh.com");
393 packet_put_char(0);
394 packet_send();
395}
396
397/* shared */

--- 81 unchanged lines hidden (view full) ---

479 buffer_clear(&c->output);
480 if (compat20 && c->type == SSH_CHANNEL_LARVAL)
481 return;
482 /* shutdown failure is allowed if write failed already */
483 debug2("channel %d: close_write", c->self);
484 if (c->sock != -1) {
485 if (shutdown(c->sock, SHUT_WR) < 0)
486 debug2("channel %d: chan_shutdown_write: "
392 packet_start(SSH2_MSG_CHANNEL_REQUEST);
393 packet_put_int(c->remote_id);
394 packet_put_cstring("eow@openssh.com");
395 packet_put_char(0);
396 packet_send();
397}
398
399/* shared */

--- 81 unchanged lines hidden (view full) ---

481 buffer_clear(&c->output);
482 if (compat20 && c->type == SSH_CHANNEL_LARVAL)
483 return;
484 /* shutdown failure is allowed if write failed already */
485 debug2("channel %d: close_write", c->self);
486 if (c->sock != -1) {
487 if (shutdown(c->sock, SHUT_WR) < 0)
488 debug2("channel %d: chan_shutdown_write: "
487 "shutdown() failed for fd%d: %.100s",
489 "shutdown() failed for fd %d: %.100s",
488 c->self, c->sock, strerror(errno));
489 } else {
490 if (channel_close_fd(&c->wfd) < 0)
491 logit("channel %d: chan_shutdown_write: "
490 c->self, c->sock, strerror(errno));
491 } else {
492 if (channel_close_fd(&c->wfd) < 0)
493 logit("channel %d: chan_shutdown_write: "
492 "close() failed for fd%d: %.100s",
494 "close() failed for fd %d: %.100s",
493 c->self, c->wfd, strerror(errno));
494 }
495}
496static void
497chan_shutdown_read(Channel *c)
498{
499 if (compat20 && c->type == SSH_CHANNEL_LARVAL)
500 return;
501 debug2("channel %d: close_read", c->self);
502 if (c->sock != -1) {
503 /*
504 * shutdown(sock, SHUT_READ) may return ENOTCONN if the
505 * write side has been closed already. (bug on Linux)
506 * HP-UX may return ENOTCONN also.
507 */
508 if (shutdown(c->sock, SHUT_RD) < 0
509 && errno != ENOTCONN)
510 error("channel %d: chan_shutdown_read: "
495 c->self, c->wfd, strerror(errno));
496 }
497}
498static void
499chan_shutdown_read(Channel *c)
500{
501 if (compat20 && c->type == SSH_CHANNEL_LARVAL)
502 return;
503 debug2("channel %d: close_read", c->self);
504 if (c->sock != -1) {
505 /*
506 * shutdown(sock, SHUT_READ) may return ENOTCONN if the
507 * write side has been closed already. (bug on Linux)
508 * HP-UX may return ENOTCONN also.
509 */
510 if (shutdown(c->sock, SHUT_RD) < 0
511 && errno != ENOTCONN)
512 error("channel %d: chan_shutdown_read: "
511 "shutdown() failed for fd%d [i%d o%d]: %.100s",
513 "shutdown() failed for fd %d [i%d o%d]: %.100s",
512 c->self, c->sock, c->istate, c->ostate,
513 strerror(errno));
514 } else {
515 if (channel_close_fd(&c->rfd) < 0)
516 logit("channel %d: chan_shutdown_read: "
514 c->self, c->sock, c->istate, c->ostate,
515 strerror(errno));
516 } else {
517 if (channel_close_fd(&c->rfd) < 0)
518 logit("channel %d: chan_shutdown_read: "
517 "close() failed for fd%d: %.100s",
519 "close() failed for fd %d: %.100s",
518 c->self, c->rfd, strerror(errno));
519 }
520}
520 c->self, c->rfd, strerror(errno));
521 }
522}