/*
* 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-2011, 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,
* 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/>.
*
* ---
*
#include <stdarg.h>
#include <sys/types.h>
#include <time.h>
-#include <winsock2.h>
-#undef NS_ALL
#include <windows.h>
#include <process.h>
#include "misc.h"
#include "empthread.h"
+#include "file.h"
#include "prototypes.h"
#include "server.h"
+#include "sys/socket.h"
#define loc_MIN_THREAD_STACK 16384
/* 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);
empth_t *pThread = NULL;
loc_debug("creating new thread %s", name);
+ ef_make_stale();
pThread = malloc(sizeof(*pThread));
if (!pThread) {
empth_t *pThread = TlsGetValue(dwTLSIndex);
loc_debug("empth_exit");
+ ef_make_stale();
loc_BlockThisThread();
TlsSetValue(dwTLSIndex, NULL);
void
empth_yield(void)
{
+ ef_make_stale();
loc_BlockThisThread();
Sleep(0);
loc_RunThisThread(NULL);
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;
empth_t *pThread = TlsGetValue(dwTLSIndex);
DWORD result;
+ ef_make_stale();
loc_BlockThisThread();
do {
int
empth_wait_for_signal(void)
{
+ ef_make_stale();
loc_BlockThisThread();
loc_RunThisThread(hShutdownEvent);
return SIGTERM;
void
empth_rwlock_wrlock(empth_rwlock_t *rwlock)
{
+ ef_make_stale();
/* block any new readers */
ResetEvent(rwlock->can_read);
rwlock->nwrite++;
void
empth_rwlock_rdlock(empth_rwlock_t *rwlock)
{
+ ef_make_stale();
loc_BlockThisThread();
loc_RunThisThread(rwlock->can_read);
ResetEvent(rwlock->can_write);