Thanks.
I realised a short while after sending my bug report that I should have
sent some diff, too, to make it easier to figure out. Thanks for
ploughing through the larger file.
My favorite thought about this bug is that it is present in most of the
telnet flavours, and has been there for at least thirty years.
Ed
Debarshi Ray wrote:
I have attached a small manyfd.c program that invokes telnet to show the
problem, and I have attached a better version of sys_bsd.c.
The revised sys_bsd.c adds an integer "nfds" and sets it while using
FD_SET, so that select() can be called this way
select(nfds+1, &ibits, &obits, &xbits, &TimeValue)
Since the attached sys_bsd.c did not produce a clear 'diff' neither
against the 1.5 version or the current copy in CVS, I tried to
visually pick and apply your changes against the file in CVS. That
seems to boil down to:
Index: telnet/sys_bsd.c
===================================================================
RCS file: /sources/inetutils/inetutils/telnet/sys_bsd.c,v
retrieving revision 1.14
diff -u -p -r1.14 sys_bsd.c
--- telnet/sys_bsd.c 4 Jun 2007 17:27:01 -0000 1.14
+++ telnet/sys_bsd.c 14 Apr 2008 11:03:49 -0000
@@ -1062,42 +1062,57 @@ process_rings (int netin, int netout, in
*/
int returnValue = 0;
static struct timeval TimeValue = { 0 };
+ int nfds = 0;
if (netout)
{
FD_SET (net, &obits);
+ if (net > nfds)
+ nfds = net;
}
if (ttyout)
{
FD_SET (tout, &obits);
+ if (tout > nfds)
+ nfds = tout;
}
#if defined(TN3270)
if (ttyin)
{
FD_SET (tin, &ibits);
+ if (tin > nfds)
+ nfds = tin;
}
#else /* defined(TN3270) */
if (ttyin)
{
FD_SET (tin, &ibits);
+ if (tin > nfds)
+ nfds = tin;
}
#endif /* defined(TN3270) */
#if defined(TN3270)
if (netin)
{
FD_SET (net, &ibits);
+ if (net > nfds)
+ nfds = net;
}
#else /* !defined(TN3270) */
if (netin)
{
FD_SET (net, &ibits);
+ if (net > nfds)
+ nfds = net;
}
#endif /* !defined(TN3270) */
if (netex)
{
FD_SET (net, &xbits);
+ if (net > nfds)
+ nfds = net;
}
- if ((c = select (16, &ibits, &obits, &xbits,
+ if ((c = select (nfds+1, &ibits, &obits, &xbits,
(poll == 0) ? (struct timeval *) 0 : &TimeValue)) < 0)
{
if (c == -1)
Also available at http://rishi.fedorapeople.org/gnu/telnet-select.diff
Applying it fixed the issue for me. Thank you Edward. :-)
Happy hacking,
Debarshi
_______________________________________________
bug-inetutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-inetutils