]> git.pond.sub.org Git - empserver/blobdiff - src/lib/empthread/pthread.c
Update copyright notice
[empserver] / src / lib / empthread / pthread.c
index 6339459e35c71c66b56fc4d1917fe8d522f31645..de3090b45468dffe0484725fda51699ee22c6d92 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -29,7 +29,7 @@
  *  Known contributors to this file:
  *     Sasha Mikheev
  *     Steve McClure, 1998
- *     Markus Armbruster, 2005-2010
+ *     Markus Armbruster, 2005-2012
  *     Ron Koenderink, 2007-2009
  */
 
@@ -172,7 +172,6 @@ empth_init(void **ctx_ptr, int flags)
     ctx->wakeup = 0;
     pthread_setspecific(ctx_key, ctx);
     pthread_mutex_lock(&mtx_ctxsw);
-    logerror("pthreads initialized");
     return 0;
 }
 
@@ -240,7 +239,7 @@ empth_restorectx(void)
 empth_t *
 empth_self(void)
 {
-    return pthread_getspecific(ctx_key);
+    return udata ? pthread_getspecific(ctx_key) : NULL;
 }
 
 char *
@@ -289,6 +288,11 @@ empth_select(int fd, int flags, struct timeval *timeout)
     empth_t *ctx;
     int res = 0;
 
+    if (CANT_HAPPEN(fd < 0 || fd >= FD_SETSIZE)) {
+       errno = EBADF;
+       return -1;
+    }
+
     ef_make_stale();
     pthread_mutex_unlock(&mtx_ctxsw);
     empth_status("select on %d for %d", fd, flags);