Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2000:
[Freeciv-Dev] [PATCH] make accepting new connects nonblocking
Home

[Freeciv-Dev] [PATCH] make accepting new connects nonblocking

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [PATCH] make accepting new connects nonblocking
From: Markus Linnala <maage@xxxxxxxxx>
Date: Wed, 09 Feb 2000 11:15:27 +0200
Reply-to: Markus Linnala <maage@xxxxxxxxx>

I've run freeciv with profiler.

There seems to be some kind of problem with connecting clients.
Sometimes I have to connect and disconnect several times before
games starts to run.

This patch fixes the problem, but I'm not sure it fixes problem
at freeciv or at glibc / socket implementation.

My system is linux 2.2.14, RH6.1, glibc 2.1.2.

-- 
//Markus

Index: server/sernet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sernet.c,v
retrieving revision 1.31
diff -u -r1.31 sernet.c
--- sernet.c    2000/01/02 11:32:16     1.31
+++ sernet.c    2000/02/09 09:14:11
@@ -56,6 +56,7 @@
 #ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
 #endif
+#include <fcntl.h>
 
 #include "log.h"
 #include "packets.h"
@@ -243,8 +244,8 @@
 
   fromlen = sizeof fromend;
 
+  fcntl(sockfd, F_SETFL, O_NONBLOCK);
   new_sock = accept(sockfd, (struct sockaddr *) &fromend, &fromlen);
-
   from=gethostbyaddr((char*)&fromend.sin_addr, 
sizeof(sizeof(fromend.sin_addr)), 
                     AF_INET);
 


[Prev in Thread] Current Thread [Next in Thread]