diff options
Diffstat (limited to 'chat/i2cbd/patches/patch-aj')
-rw-r--r-- | chat/i2cbd/patches/patch-aj | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/chat/i2cbd/patches/patch-aj b/chat/i2cbd/patches/patch-aj new file mode 100644 index 00000000000..b8aa9c8c118 --- /dev/null +++ b/chat/i2cbd/patches/patch-aj @@ -0,0 +1,154 @@ +--- i2cbd-2.0_BETA3/src/makeport.c 2001-10-26 20:03:37.000000000 +0000 ++++ i2cbd-2.0_BETA3nb2/src/makeport.c 2006-05-11 01:46:34.000000000 +0000 +@@ -64,12 +64,6 @@ + /* start listening for connections */ + listen(s, 5); + +- /* make it non-blocking */ +- if (fcntl(s, F_SETFL, FNDELAY) < 0) { +- perror("makenewport: fcntl"); +- return(-1); +- } +- + /* Don't close on exec */ + flags = fcntl(s, F_GETFD, 0); + flags = flags & ~ FD_CLOEXEC; +--- i2cbd-2.0_BETA3/src/newconnect.c 2006-04-30 23:28:07.000000000 +0000 ++++ i2cbd-2.0_BETA3nb2/src/newconnect.c 2006-05-11 01:46:56.000000000 +0000 +@@ -65,12 +65,6 @@ + perror("SO_SNDBUF"); + } + +- /* make the socket non-blocking */ +- if (fcntl(ns, F_SETFL, FNDELAY) < 0) { +- perror("new_client:fcntl"); +- return(-1); +- } +- + /* Don't close on exec */ + flags = fcntl(ns, F_GETFD, 0); + flags = flags & ~ FD_CLOEXEC; +--- i2cbd-2.0_BETA3/src/sendpacket.c 2000-03-23 14:41:52.000000000 +0000 ++++ i2cbd-2.0_BETA3nb2/src/sendpacket.c 2006-05-11 01:03:30.000000000 +0000 +@@ -7,6 +7,7 @@ + #include <sys/socket.h> + #include <stdio.h> + #include <errno.h> ++#include <fcntl.h> + #include "externs.h" + + int sendpacket(int, char *); +@@ -14,23 +15,37 @@ + int + sendpacket(int s, char *pkt) + { +- int ret; ++ int sent, ret = 1, fcarg; + int totlength; + + /* set up a sample packet for testing purposes */ + totlength = (unsigned char)*pkt + 1; + +- if ((ret = send(s, pkt, totlength, 0)) < 0) { ++ /* make the socket non-blocking */ ++ if (((fcarg = fcntl(s, F_GETFL, 0)) < 0 || ++ fcntl(s, F_SETFL, fcarg | O_NONBLOCK) < 0)) { ++ perror("sendpacket:fcntl"); ++ return(-1); ++ } ++ ++ if ((sent = send(s, pkt, totlength, 0)) < 0) { + if (errno == EWOULDBLOCK) +- return(0); ++ ret = 0; + else if (errno == EPIPE) +- return(-2); ++ ret = -1; + else { + /* DEBUG temorary fix */ +- return(-2); ++ ret = -2; + } ++ } else { ++ if(sent != totlength) ++ ret = -1; ++ } ++ ++ if (fcntl(s, F_SETFL, fcarg & ~O_NONBLOCK) < 0) { ++ perror("sendpacket:fcntl"); ++ ret = -1; + } +- if (ret != totlength) +- return(-1); +- return(1); ++ ++ return(ret); + } +--- i2cbd-2.0_BETA3/src/serverserve.c 2006-05-11 01:42:08.000000000 +0000 ++++ i2cbd-2.0_BETA3nb2/src/serverserve.c 2006-05-11 01:30:24.000000000 +0000 +@@ -5,6 +5,7 @@ + /* active clients, new connections, and perform asynch dungeon action */ + + #include <errno.h> ++#include <fcntl.h> + #include <signal.h> + #include <stdio.h> + #include <stdlib.h> +@@ -103,8 +104,7 @@ + static void + sdoinput(void) + { +- int n; +- register int x; ++ int n, x, fcarg; + + for (x = 1; x <= highestfd; x++) + if (FD_ISSET(x, &efdr) > 0) { +@@ -112,7 +112,9 @@ + } + + /* examine set of file descriptors */ +- for (x = 1; x <= highestfd; x++) ++ for (x = 1; x <= highestfd; x++) { ++ int closed = 0; ++ + if (FD_ISSET(x, &fdr) > 0) { + if (FD_ISSET(x,&serversocks)) { + /* new connect on advertised socket */ +@@ -121,6 +123,16 @@ + s_new_user(n); + } else { + /* fd is client input */ ++ ++ /* make the socket non-blocking */ ++ if (((fcarg = fcntl(x, F_GETFL, 0)) < 0 || ++ fcntl(x, F_SETFL, fcarg | O_NONBLOCK) ++ < 0)) { ++ perror("sdoinput:fcntl"); ++ disconnectuser(x); ++ continue; ++ } ++ + switch(readpacket(x, &cbufs[x])) + { + case 1: +@@ -136,8 +148,19 @@ + case -2: + /* close connection */ + disconnectuser(x); ++ closed = 1; + break; + } ++ ++ if (!closed) { ++ if(fcntl(x, F_SETFL, ++ fcarg & ~O_NONBLOCK) < 0) { ++ perror("sdoinput: fcntl"); ++ disconnectuser(x); ++ } ++ } ++ + } + } ++ } + } |