diff options
Diffstat (limited to 'Src/Modules/tcp.c')
-rw-r--r-- | Src/Modules/tcp.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c index 2825cb978..3f92050ae 100644 --- a/Src/Modules/tcp.c +++ b/Src/Modules/tcp.c @@ -446,10 +446,7 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func)) } if (targetfd) { - if (redup(sess->fd,targetfd) == -1) - sess->fd = -1; - else - sess->fd = targetfd; + sess->fd = redup(sess->fd, targetfd); } else { /* move the fd since no one will want to read from it */ @@ -547,8 +544,11 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func)) } if (targetfd) { - redup(rfd, targetfd); - sess->fd = targetfd; + sess->fd = redup(rfd, targetfd); + if (sess->fd < 0) { + zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno); + return 1; + } } else { sess->fd = rfd; @@ -662,8 +662,11 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func)) else { if (targetfd) { - redup(sess->fd, targetfd); - sess->fd = targetfd; + sess->fd = redup(sess->fd, targetfd); + if (sess->fd < 0) { + zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno); + return 1; + } } setiparam("REPLY", sess->fd); |