summaryrefslogtreecommitdiff
path: root/chat
diff options
context:
space:
mode:
authortls <tls>2006-05-11 01:54:33 +0000
committertls <tls>2006-05-11 01:54:33 +0000
commit0c734d58e9e09b5d7d31d0afb5fdd2b2afe86ff2 (patch)
tree4390330ba32dff332357fff08588609d82603a0d /chat
parent87cb3d999f234e2ba78234fb86926631856ad99d (diff)
downloadpkgsrc-0c734d58e9e09b5d7d31d0afb5fdd2b2afe86ff2.tar.gz
Don't set O_NDELAY (and leave it set!) on all sockets, all the time. This
was making select always return immediately and was causing the daemon to spin on CPU. Instead, set O_NONBLOCK (= O_NDELAY) on sockets only when reading/writing them, and clear it afterwards, so select is always safe.
Diffstat (limited to 'chat')
-rw-r--r--chat/i2cbd/Makefile4
-rw-r--r--chat/i2cbd/patches/patch-aj154
2 files changed, 156 insertions, 2 deletions
diff --git a/chat/i2cbd/Makefile b/chat/i2cbd/Makefile
index f89e656fbc3..04a19c53d21 100644
--- a/chat/i2cbd/Makefile
+++ b/chat/i2cbd/Makefile
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.19 2006/05/10 20:16:40 christos Exp $
+# $NetBSD: Makefile,v 1.20 2006/05/11 01:54:33 tls Exp $
#
DISTNAME= i2cbd-2.0_BETA3
-PKGREVISION= 1
+PKGREVISION= 2
CATEGORIES= chat
MASTER_SITES= ${MASTER_SITE_LOCAL} \
http://www.draga.com/~jwise/i2cb/
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);
++ }
++ }
++
+ }
+ }
++ }
+ }