Problem with FD_SETSIZE using netcat
Hi here's what can be found in netcat.c (release 110-r4): /* have to do this *before* including types.h. xxx: Linux still has it wrong */ #ifdef FD_SETSIZE /* should be in types.h, butcha never know. */ #undef FD_SETSIZE /* if we ever need more than 16 active */ #endif /* fd's, something is horribly wrong! */ #define FD_SETSIZE 16 /* <-- this'll give us a long anyways, wtf */ #include <sys/types.h> /* *now* do it. Sigh, this is broken */ As FD_SETSIZE does'nt seem to be included in /usr/include/sys/types.h (linux-headers 2.4.19-r1), FD_SETSIZE=16. Later in the netcat's code, we have : if (fd > FD_SETSIZE) { holler ("Preposterous fd value %d", fd); return (1); } So netcat does'nt work if more than 16 files are opened. I'm using netcat within cacti, a rrdtool frontend. As a lot of files are opened, I got : nc -vv xxx.xxx.xxx.xxx 50000 -w 5, output: Preposterous fd value 71 sent 0, rcvd 0 I've tweaked FD_SETSIZE=16 to FD_SETSIZE=1024, and now it works as expected : nc -vv xxx.xxx.xxx.xxx 50000 -w 5, output: xxxxxxxxxxx sent 0, rcvd 17 Could you add this as a patch to the ebuild ? Thanks in advance. Regards, Fr
Hi here's what can be found in netcat.c (release 110-r4): /* have to do this *before* including types.h. xxx: Linux still has it wrong */ #ifdef FD_SETSIZE /* should be in types.h, butcha never know. */ #undef FD_SETSIZE /* if we ever need more than 16 active */ #endif /* fd's, something is horribly wrong! */ #define FD_SETSIZE 16 /* <-- this'll give us a long anyways, wtf */ #include <sys/types.h> /* *now* do it. Sigh, this is broken */ As FD_SETSIZE does'nt seem to be included in /usr/include/sys/types.h (linux-headers 2.4.19-r1), FD_SETSIZE=16. Later in the netcat's code, we have : if (fd > FD_SETSIZE) { holler ("Preposterous fd value %d", fd); return (1); } So netcat does'nt work if more than 16 files are opened. I'm using netcat within cacti, a rrdtool frontend. As a lot of files are opened, I got : nc -vv xxx.xxx.xxx.xxx 50000 -w 5, output: Preposterous fd value 71 sent 0, rcvd 0 I've tweaked FD_SETSIZE=16 to FD_SETSIZE=1024, and now it works as expected : nc -vv xxx.xxx.xxx.xxx 50000 -w 5, output: xxxxxxxxxxx sent 0, rcvd 17 Could you add this as a patch to the ebuild ? Thanks in advance. Regards, Frédéric Mangeant
added this to -r4: sed -i 's:#define FD_SETSIZE 16:#define FD_SETSIZE 1024:' netcat.c
Created attachment 21312 [details, diff] Change FD_SETSIZE from 16 to 1024