]> git.pond.sub.org Git - empserver/blobdiff - src/lib/empthread/ntthread.c
Update copyright notice
[empserver] / src / lib / empthread / ntthread.c
index 53e20848d3892d6cd0c1972b4872c9d64b988fc1..2a39f5bbb0b9e796e20d9b2835b41a52171f8d50 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
@@ -56,6 +55,7 @@
 #include <process.h>
 #include "misc.h"
 #include "empthread.h"
+#include "file.h"
 #include "prototypes.h"
 #include "server.h"
 #include "sys/socket.h"
@@ -375,7 +375,7 @@ empth_init(void **ctx_ptr, int flags)
     /* Manual reset */
     hShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
     if (!hShutdownEvent) {
-        logerror("Failed to create shutdown event %lu", GetLastError());
+       logerror("Failed to create shutdown event %lu", GetLastError());
        return 0;
     }
     SetConsoleCtrlHandler(loc_Exit_Handler, TRUE);
@@ -423,6 +423,7 @@ empth_create(void (*entry)(void *), int size, int flags,
     empth_t *pThread = NULL;
 
     loc_debug("creating new thread %s", name);
+    ef_make_stale();
 
     pThread = malloc(sizeof(*pThread));
     if (!pThread) {
@@ -501,6 +502,7 @@ empth_exit(void)
     empth_t *pThread = TlsGetValue(dwTLSIndex);
 
     loc_debug("empth_exit");
+    ef_make_stale();
     loc_BlockThisThread();
 
     TlsSetValue(dwTLSIndex, NULL);
@@ -516,6 +518,7 @@ empth_exit(void)
 void
 empth_yield(void)
 {
+    ef_make_stale();
     loc_BlockThisThread();
     Sleep(0);
     loc_RunThisThread(NULL);
@@ -541,12 +544,13 @@ empth_select(int fd, int flags, struct timeval *timeout)
 
     loc_debug("%s select on %d",
              flags == EMPTH_FD_READ ? "read" : "write", fd);
+    ef_make_stale();
     loc_BlockThisThread();
 
     hEventObject[0] = WSACreateEvent();
     hEventObject[1] = pThread->hThreadEvent;
 
-    sock = posix_fd2socket(fd);
+    sock = w32_fd2socket(fd);
     CANT_HAPPEN(sock == (SOCKET)-1);
 
     events = 0;
@@ -615,6 +619,7 @@ empth_sleep(time_t until)
     empth_t *pThread = TlsGetValue(dwTLSIndex);
     DWORD result;
 
+    ef_make_stale();
     loc_BlockThisThread();
 
     do {
@@ -645,6 +650,7 @@ empth_request_shutdown(void)
 int
 empth_wait_for_signal(void)
 {
+    ef_make_stale();
     loc_BlockThisThread();
     loc_RunThisThread(hShutdownEvent);
     return SIGTERM;
@@ -696,6 +702,7 @@ empth_rwlock_destroy(empth_rwlock_t *rwlock)
 void
 empth_rwlock_wrlock(empth_rwlock_t *rwlock)
 {
+    ef_make_stale();
     /* block any new readers */
     ResetEvent(rwlock->can_read);
     rwlock->nwrite++;
@@ -707,6 +714,7 @@ empth_rwlock_wrlock(empth_rwlock_t *rwlock)
 void
 empth_rwlock_rdlock(empth_rwlock_t *rwlock)
 {
+    ef_make_stale();
     loc_BlockThisThread();
     loc_RunThisThread(rwlock->can_read);
     ResetEvent(rwlock->can_write);