/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* Dave Pare, 1994
* Steve McClure, 1996, 1998
* Doug Hay, 1998
- * Ron Koenderink, 2004-2005
+ * Ron Koenderink, 2004-2009
* Markus Armbruster, 2005-2008
*/
*/
empth_rwlock_t *play_lock;
-/*
- * Is a thread attempting to take an exclusive play_lock?
- * Threads holding a shared play_lock must not sleep while this is
- * true.
- */
-int play_wrlock_wanted;
-
static char pidfname[] = "server.pid";
/* Run as daemon? If yes, detach from controlling terminal etc. */
pid_t pid;
int status;
+ fflush(NULL);
pid = fork();
if (pid < 0) {
logerror("Can't fork for crash dump (%s)", strerror(errno));
return;
}
if (pid == 0)
- abort(); /* child */
+ raise(SIGABRT); /* child */
/* parent */
while (waitpid(pid, &status, 0) < 0) {
if (journal_startup() < 0)
exit(1);
- empth_create(player_accept, 50 * 1024, flags, "AcceptPlayers", 0);
+ empth_create(player_accept, 50 * 1024, flags, "AcceptPlayers", NULL);
market_init();
update_init();
logerror("Shutdown commencing (cleaning up threads.)");
- play_wrlock_wanted = 1;
- for (p = player_next(0); p != 0; p = player_next(p)) {
+ for (p = player_next(NULL); p; p = player_next(p)) {
if (p->state != PS_PLAYING)
continue;
pr_flash(p, "Server shutting down...\n");
p->state = PS_SHUTDOWN;
+ p->may_sleep = PLAYER_SLEEP_NEVER;
p->aborted++;
if (p->command) {
pr_flash(p, "Shutdown aborting command\n");