wesnoth-cvs-commits
[Top][All Lists]
Advanced

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

[Wesnoth-cvs-commits] wesnoth/src network_worker.cpp


From: Jon Daniel
Subject: [Wesnoth-cvs-commits] wesnoth/src network_worker.cpp
Date: Mon, 05 Sep 2005 15:46:04 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Jon Daniel <address@hidden>     05/09/05 19:46:04

Modified files:
        src            : network_worker.cpp 

Log message:
        add select fallback if poll is not available

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/network_worker.cpp.diff?tr1=1.47&tr2=1.48&r1=text&r2=text

Patches:
Index: wesnoth/src/network_worker.cpp
diff -u wesnoth/src/network_worker.cpp:1.47 wesnoth/src/network_worker.cpp:1.48
--- wesnoth/src/network_worker.cpp:1.47 Mon Sep  5 16:43:54 2005
+++ wesnoth/src/network_worker.cpp      Mon Sep  5 19:46:04 2005
@@ -1,4 +1,4 @@
-/* $Id: network_worker.cpp,v 1.47 2005/09/05 16:43:54 j_daniel Exp $ */
+/* $Id: network_worker.cpp,v 1.48 2005/09/05 19:46:04 j_daniel Exp $ */
 /*
    Copyright (C) 2003-5 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -18,6 +18,7 @@
 #include "network.hpp"
 #include "thread.hpp"
 #include "wassert.hpp"
+#include "wesconfig.h"
 
 #include <algorithm>
 #include <cerrno>
@@ -26,7 +27,6 @@
 #include <iostream>
 #include <map>
 #include <vector>
-#include "config.h"
 
 #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
 #include <windows.h>
@@ -44,14 +44,13 @@
 #ifdef HAVE_POLL_H
 #define USE_POLL 1
 #include <poll.h>
-#endif
-
-#ifdef HAVE_SYS_POLL_H
+#elif defined(HAVE_SYS_POLL_H)
 #define USE_POLL 1
 #include <sys/poll.h>
 #endif
 
-#ifdef USE_SELECT
+#ifndef USE_POLL
+#define USE_SELECT 1
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #else
@@ -140,8 +139,21 @@
                                if(poll_res > 0)
                                        continue;
                        }
-/* TODO implement the select io wait */
-#else
+#elif defined(USE_SELECT)
+                               fd_set writefds;
+                               FD_ZERO(&writefds);
+                               FD_SET(((_TCPsocket*)sock)->channel, &writefds);
+                               int retval;
+                               struct timeval tv;
+                               tv.tv_sec = 15;
+                               tv.tv_usec = 0;
+
+                               do {
+                                       retval = 
select(((_TCPsocket*)sock)->channel + 1, NULL, &writefds, NULL, &tv);
+                               } while(retval == -1 && errno == EINTR);
+
+                               if(retval > 0)
+                                       continue;
                        }
 #endif
                        return SOCKET_ERROR;




reply via email to

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