pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/chat/i2cbd/patches whoops. resuscitate patch-aj



details:   https://anonhg.NetBSD.org/pkgsrc/rev/0c7a6ca79b6d
branches:  trunk
changeset: 512521:0c7a6ca79b6d
user:      tls <tls%pkgsrc.org@localhost>
date:      Thu May 11 03:40:34 2006 +0000

description:
whoops.  resuscitate patch-aj

diffstat:

 chat/i2cbd/patches/patch-aj |  154 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 154 insertions(+), 0 deletions(-)

diffs (158 lines):

diff -r 9cb4c984dcad -r 0c7a6ca79b6d chat/i2cbd/patches/patch-aj
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/chat/i2cbd/patches/patch-aj       Thu May 11 03:40:34 2006 +0000
@@ -0,0 +1,154 @@
+--- src/makeport.c.orig        2001-10-26 20:03:37.000000000 +0000
++++ 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;
+--- src/newconnect.c.orig      2006-04-30 23:28:07.000000000 +0000
++++ 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;
+--- src/sendpacket.c.orig      2000-03-23 14:41:52.000000000 +0000
++++ 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);
+ }
+--- src/serverserve.c.orig     2006-05-11 01:42:08.000000000 +0000
++++ 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);
++                                      }
++                              }
++
+                       }
+               }
++      }
+ }



Home | Main Index | Thread Index | Old Index