|
Lines 371-387
chan_shutdown_write(struct ssh *ssh, Channel *c)
Link Here
|
| 371 |
if (c->type == SSH_CHANNEL_LARVAL) |
371 |
if (c->type == SSH_CHANNEL_LARVAL) |
| 372 |
return; |
372 |
return; |
| 373 |
/* shutdown failure is allowed if write failed already */ |
373 |
/* shutdown failure is allowed if write failed already */ |
| 374 |
debug2("channel %d: close_write", c->self); |
374 |
debug2("channel %d: %s (i%d o%d sock %d wfd %d efd %d [%s])", |
|
|
375 |
c->self, __func__, c->istate, c->ostate, c->sock, c->wfd, c->efd, |
| 376 |
channel_format_extended_usage(c)); |
| 375 |
if (c->sock != -1) { |
377 |
if (c->sock != -1) { |
| 376 |
if (shutdown(c->sock, SHUT_WR) < 0) |
378 |
if (shutdown(c->sock, SHUT_WR) < 0) { |
| 377 |
debug2("channel %d: chan_shutdown_write: " |
379 |
debug2("channel %d: %s: shutdown() failed for " |
| 378 |
"shutdown() failed for fd %d: %.100s", |
380 |
"fd %d [i%d o%d]: %.100s", c->self, __func__, |
| 379 |
c->self, c->sock, strerror(errno)); |
381 |
c->sock, c->istate, c->ostate, |
|
|
382 |
strerror(errno)); |
| 383 |
} |
| 380 |
} else { |
384 |
} else { |
| 381 |
if (channel_close_fd(ssh, &c->wfd) < 0) |
385 |
if (channel_close_fd(ssh, &c->wfd) < 0) { |
| 382 |
logit("channel %d: chan_shutdown_write: " |
386 |
logit("channel %d: %s: close() failed for " |
| 383 |
"close() failed for fd %d: %.100s", |
387 |
"fd %d [i%d o%d]: %.100s", |
| 384 |
c->self, c->wfd, strerror(errno)); |
388 |
c->self, __func__, c->wfd, c->istate, c->ostate, |
|
|
389 |
strerror(errno)); |
| 390 |
} |
| 391 |
if (c->extended_usage == CHAN_EXTENDED_WRITE && |
| 392 |
c->efd != -1 && channel_close_fd(ssh, &c->efd) < 0) { |
| 393 |
logit("channel %d: %s: close() failed for " |
| 394 |
"extended fd %d [i%d o%d]: %.100s", |
| 395 |
c->self, __func__, c->efd, c->istate, c->ostate, |
| 396 |
strerror(errno)); |
| 397 |
} |
| 385 |
} |
398 |
} |
| 386 |
} |
399 |
} |
| 387 |
|
400 |
|
|
Lines 390-406
chan_shutdown_read(struct ssh *ssh, Channel *c)
Link Here
|
| 390 |
{ |
403 |
{ |
| 391 |
if (c->type == SSH_CHANNEL_LARVAL) |
404 |
if (c->type == SSH_CHANNEL_LARVAL) |
| 392 |
return; |
405 |
return; |
| 393 |
debug2("channel %d: close_read", c->self); |
406 |
debug2("channel %d: %s (i%d o%d sock %d wfd %d efd %d [%s])", |
|
|
407 |
c->self, __func__, c->istate, c->ostate, c->sock, c->rfd, c->efd, |
| 408 |
channel_format_extended_usage(c)); |
| 394 |
if (c->sock != -1) { |
409 |
if (c->sock != -1) { |
| 395 |
if (shutdown(c->sock, SHUT_RD) < 0) |
410 |
if (shutdown(c->sock, SHUT_RD) < 0) { |
| 396 |
error("channel %d: chan_shutdown_read: " |
411 |
error("channel %d: %s: shutdown() failed for " |
| 397 |
"shutdown() failed for fd %d [i%d o%d]: %.100s", |
412 |
"fd %d [i%d o%d]: %.100s", |
| 398 |
c->self, c->sock, c->istate, c->ostate, |
413 |
c->self, __func__, c->sock, c->istate, c->ostate, |
| 399 |
strerror(errno)); |
414 |
strerror(errno)); |
|
|
415 |
} |
| 400 |
} else { |
416 |
} else { |
| 401 |
if (channel_close_fd(ssh, &c->rfd) < 0) |
417 |
if (channel_close_fd(ssh, &c->rfd) < 0) { |
| 402 |
logit("channel %d: chan_shutdown_read: " |
418 |
logit("channel %d: %s: close() failed for " |
| 403 |
"close() failed for fd %d: %.100s", |
419 |
"fd %d [i%d o%d]: %.100s", |
| 404 |
c->self, c->rfd, strerror(errno)); |
420 |
c->self, __func__, c->rfd, c->istate, c->ostate, |
|
|
421 |
strerror(errno)); |
| 422 |
} |
| 423 |
if (c->extended_usage == CHAN_EXTENDED_READ && |
| 424 |
c->efd != -1 && channel_close_fd(ssh, &c->efd) < 0) { |
| 425 |
logit("channel %d: %s: close() failed for " |
| 426 |
"extended fd %d [i%d o%d]: %.100s", |
| 427 |
c->self, __func__, c->efd, c->istate, c->ostate, |
| 428 |
strerror(errno)); |
| 429 |
} |
| 405 |
} |
430 |
} |
| 406 |
} |
431 |
} |