summaryrefslogtreecommitdiff
path: root/nchan.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2018-10-04 00:10:11 +0000
committerDamien Miller <djm@mindrot.org>2018-10-04 10:44:49 +1000
commitf1dd179e122bdfdb7ca3072d9603607740efda05 (patch)
tree422eb37f82b6fd14e3f8f10668bc3cef8ea447e9 /nchan.c
parent2d1428b11c8b6f616f070f2ecedce12328526944 (diff)
upstream: include a little more information about the status and
disposition of channel's extended (stderr) fd; makes debugging some things a bit easier. No behaviour change. OpenBSD-Commit-ID: 483eb6467dc7d5dbca8eb109c453e7a43075f7ce
Diffstat (limited to 'nchan.c')
-rw-r--r--nchan.c52
1 files changed, 31 insertions, 21 deletions
diff --git a/nchan.c b/nchan.c
index 24929556d..da7a9d6d6 100644
--- a/nchan.c
+++ b/nchan.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: nchan.c,v 1.67 2017/09/12 06:35:32 djm Exp $ */ 1/* $OpenBSD: nchan.c,v 1.68 2018/10/04 00:10:11 djm Exp $ */
2/* 2/*
3 * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved. 3 * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved.
4 * 4 *
@@ -373,17 +373,23 @@ chan_shutdown_write(struct ssh *ssh, Channel *c)
373 if (c->type == SSH_CHANNEL_LARVAL) 373 if (c->type == SSH_CHANNEL_LARVAL)
374 return; 374 return;
375 /* shutdown failure is allowed if write failed already */ 375 /* shutdown failure is allowed if write failed already */
376 debug2("channel %d: close_write", c->self); 376 debug2("channel %d: %s (i%d o%d sock %d wfd %d efd %d [%s])",
377 c->self, __func__, c->istate, c->ostate, c->sock, c->wfd, c->efd,
378 channel_format_extended_usage(c));
377 if (c->sock != -1) { 379 if (c->sock != -1) {
378 if (shutdown(c->sock, SHUT_WR) < 0) 380 if (shutdown(c->sock, SHUT_WR) < 0) {
379 debug2("channel %d: chan_shutdown_write: " 381 debug2("channel %d: %s: shutdown() failed for "
380 "shutdown() failed for fd %d: %.100s", 382 "fd %d [i%d o%d]: %.100s", c->self, __func__,
381 c->self, c->sock, strerror(errno)); 383 c->sock, c->istate, c->ostate,
384 strerror(errno));
385 }
382 } else { 386 } else {
383 if (channel_close_fd(ssh, &c->wfd) < 0) 387 if (channel_close_fd(ssh, &c->wfd) < 0) {
384 logit("channel %d: chan_shutdown_write: " 388 logit("channel %d: %s: close() failed for "
385 "close() failed for fd %d: %.100s", 389 "fd %d [i%d o%d]: %.100s",
386 c->self, c->wfd, strerror(errno)); 390 c->self, __func__, c->wfd, c->istate, c->ostate,
391 strerror(errno));
392 }
387 } 393 }
388} 394}
389 395
@@ -392,23 +398,27 @@ chan_shutdown_read(struct ssh *ssh, Channel *c)
392{ 398{
393 if (c->type == SSH_CHANNEL_LARVAL) 399 if (c->type == SSH_CHANNEL_LARVAL)
394 return; 400 return;
395 debug2("channel %d: close_read", c->self); 401 debug2("channel %d: %s (i%d o%d sock %d wfd %d efd %d [%s])",
402 c->self, __func__, c->istate, c->ostate, c->sock, c->rfd, c->efd,
403 channel_format_extended_usage(c));
396 if (c->sock != -1) { 404 if (c->sock != -1) {
397 /* 405 /*
398 * shutdown(sock, SHUT_READ) may return ENOTCONN if the 406 * shutdown(sock, SHUT_READ) may return ENOTCONN if the
399 * write side has been closed already. (bug on Linux) 407 * write side has been closed already. (bug on Linux)
400 * HP-UX may return ENOTCONN also. 408 * HP-UX may return ENOTCONN also.
401 */ 409 */
402 if (shutdown(c->sock, SHUT_RD) < 0 410 if (shutdown(c->sock, SHUT_RD) < 0 && errno != ENOTCONN) {
403 && errno != ENOTCONN) 411 error("channel %d: %s: shutdown() failed for "
404 error("channel %d: chan_shutdown_read: " 412 "fd %d [i%d o%d]: %.100s",
405 "shutdown() failed for fd %d [i%d o%d]: %.100s", 413 c->self, __func__, c->sock, c->istate, c->ostate,
406 c->self, c->sock, c->istate, c->ostate, 414 strerror(errno));
407 strerror(errno)); 415 }
408 } else { 416 } else {
409 if (channel_close_fd(ssh, &c->rfd) < 0) 417 if (channel_close_fd(ssh, &c->rfd) < 0) {
410 logit("channel %d: chan_shutdown_read: " 418 logit("channel %d: %s: close() failed for "
411 "close() failed for fd %d: %.100s", 419 "fd %d [i%d o%d]: %.100s",
412 c->self, c->rfd, strerror(errno)); 420 c->self, __func__, c->rfd, c->istate, c->ostate,
421 strerror(errno));
422 }
413 } 423 }
414} 424}