version 1.242, 2006/03/25 00:05:41 |
version 1.243, 2006/03/25 01:13:23 |
|
|
if (channels_alloc > 10000) |
if (channels_alloc > 10000) |
fatal("channel_new: internal error: channels_alloc %d " |
fatal("channel_new: internal error: channels_alloc %d " |
"too big.", channels_alloc); |
"too big.", channels_alloc); |
channels = xrealloc(channels, |
channels = xrealloc(channels, channels_alloc + 10, |
(channels_alloc + 10) * sizeof(Channel *)); |
sizeof(Channel *)); |
channels_alloc += 10; |
channels_alloc += 10; |
debug2("channel: expanding %d", channels_alloc); |
debug2("channel: expanding %d", channels_alloc); |
for (i = found; i < channels_alloc; i++) |
for (i = found; i < channels_alloc; i++) |
|
|
channel_prepare_select(fd_set **readsetp, fd_set **writesetp, int *maxfdp, |
channel_prepare_select(fd_set **readsetp, fd_set **writesetp, int *maxfdp, |
u_int *nallocp, int rekeying) |
u_int *nallocp, int rekeying) |
{ |
{ |
u_int n, sz; |
u_int n, sz, nfdset; |
|
|
n = MAX(*maxfdp, channel_max_fd); |
n = MAX(*maxfdp, channel_max_fd); |
|
|
sz = howmany(n+1, NFDBITS) * sizeof(fd_mask); |
nfdset = howmany(n+1, NFDBITS); |
|
/* Explicitly test here, because xrealloc isn't always called */ |
|
if (nfdset && SIZE_T_MAX / nfdset < sizeof(fd_mask)) |
|
fatal("channel_prepare_select: max_fd (%d) is too large", n); |
|
sz = nfdset * sizeof(fd_mask); |
|
|
/* perhaps check sz < nalloc/2 and shrink? */ |
/* perhaps check sz < nalloc/2 and shrink? */ |
if (*readsetp == NULL || sz > *nallocp) { |
if (*readsetp == NULL || sz > *nallocp) { |
*readsetp = xrealloc(*readsetp, sz); |
*readsetp = xrealloc(*readsetp, nfdset, sizeof(fd_mask)); |
*writesetp = xrealloc(*writesetp, sz); |
*writesetp = xrealloc(*writesetp, nfdset, sizeof(fd_mask)); |
*nallocp = sz; |
*nallocp = sz; |
} |
} |
*maxfdp = n; |
*maxfdp = n; |