version 1.351, 2016/07/19 11:38:53 |
version 1.352, 2016/09/12 01:22:38 |
|
|
*/ |
*/ |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/param.h> /* MIN MAX */ |
|
#include <sys/stat.h> |
#include <sys/stat.h> |
#include <sys/ioctl.h> |
#include <sys/ioctl.h> |
#include <sys/un.h> |
#include <sys/un.h> |
|
|
int extusage, int nonblock, int is_tty) |
int extusage, int nonblock, int is_tty) |
{ |
{ |
/* Update the maximum file descriptor value. */ |
/* Update the maximum file descriptor value. */ |
channel_max_fd = MAX(channel_max_fd, rfd); |
channel_max_fd = MAXIMUM(channel_max_fd, rfd); |
channel_max_fd = MAX(channel_max_fd, wfd); |
channel_max_fd = MAXIMUM(channel_max_fd, wfd); |
channel_max_fd = MAX(channel_max_fd, efd); |
channel_max_fd = MAXIMUM(channel_max_fd, efd); |
|
|
if (rfd != -1) |
if (rfd != -1) |
fcntl(rfd, F_SETFD, FD_CLOEXEC); |
fcntl(rfd, F_SETFD, FD_CLOEXEC); |
|
|
for (i = 0; i < channels_alloc; i++) { |
for (i = 0; i < channels_alloc; i++) { |
c = channels[i]; |
c = channels[i]; |
if (c != NULL) { |
if (c != NULL) { |
max = MAX(max, c->rfd); |
max = MAXIMUM(max, c->rfd); |
max = MAX(max, c->wfd); |
max = MAXIMUM(max, c->wfd); |
max = MAX(max, c->efd); |
max = MAXIMUM(max, c->efd); |
} |
} |
} |
} |
return max; |
return max; |
|
|
|
|
if (buffer_len(&c->input) < need) { |
if (buffer_len(&c->input) < need) { |
rlen = need - buffer_len(&c->input); |
rlen = need - buffer_len(&c->input); |
len = read(c->rfd, buf, MIN(rlen, CHAN_RBUF)); |
len = read(c->rfd, buf, MINIMUM(rlen, CHAN_RBUF)); |
if (len < 0 && (errno == EINTR || errno == EAGAIN)) |
if (len < 0 && (errno == EINTR || errno == EAGAIN)) |
return buffer_len(&c->input); |
return buffer_len(&c->input); |
if (len <= 0) { |
if (len <= 0) { |
|
|
{ |
{ |
u_int n, sz, nfdset; |
u_int n, sz, nfdset; |
|
|
n = MAX(*maxfdp, channel_max_fd); |
n = MAXIMUM(*maxfdp, channel_max_fd); |
|
|
nfdset = howmany(n+1, NFDBITS); |
nfdset = howmany(n+1, NFDBITS); |
/* Explicitly test here, because xrealloc isn't always called */ |
/* Explicitly test here, because xrealloc isn't always called */ |
|
|
{ |
{ |
int sock, saved_errno; |
int sock, saved_errno; |
struct sockaddr_un *sunaddr; |
struct sockaddr_un *sunaddr; |
char ntop[NI_MAXHOST], strport[MAX(NI_MAXSERV,sizeof(sunaddr->sun_path))]; |
char ntop[NI_MAXHOST], strport[MAXIMUM(NI_MAXSERV,sizeof(sunaddr->sun_path))]; |
|
|
for (; cctx->ai; cctx->ai = cctx->ai->ai_next) { |
for (; cctx->ai; cctx->ai = cctx->ai->ai_next) { |
switch (cctx->ai->ai_family) { |
switch (cctx->ai->ai_family) { |