]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix windows compilation of condition code
authorNick Mathewson <nickm@torproject.org>
Thu, 26 Sep 2013 03:31:40 +0000 (23:31 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 14 Jan 2015 16:09:51 +0000 (11:09 -0500)
src/common/compat.c
src/common/compat_winthreads.c

index a22a61ac4dca3839ba3e2e2371c5b97be03fbbf0..5575316b2bfef54be4055d3868beecae880f2b53 100644 (file)
@@ -27,7 +27,6 @@
 #include "compat.h"
 
 #ifdef _WIN32
-#include <process.h>
 #include <windows.h>
 #include <sys/locking.h>
 #endif
index 0ab26b7ebdc39d1ad447249ee952bc896acb2cc5..e19b1cae859da94f1d62997a2e0b65495a72e6b7 100644 (file)
@@ -9,6 +9,10 @@
 #include "util.h"
 #include "container.h"
 #include "torlog.h"
+#include <process.h>
+
+/* This value is more or less total cargo-cult */
+#define SPIN_COUNT 2000
 
 /** Minimalist interface to run a void function in the background.  On
  * Unix calls fork, on win32 calls beginthread.  Returns -1 on failure.
@@ -108,7 +112,6 @@ tor_cond_signal_impl(tor_cond_t *cond, int broadcast)
   cond->generation++;
   SetEvent(cond->event);
   LeaveCriticalSection(&cond->lock);
-  return 0;
 }
 void
 tor_cond_signal_one(tor_cond_t *cond)
@@ -122,15 +125,15 @@ tor_cond_signal_all(tor_cond_t *cond)
 }
 
 int
-tor_cond_wait(tor_cond_t *cond, tor_mutex_t *lock, const struct timeval *tv)
+tor_cond_wait(tor_cond_t *cond, tor_mutex_t *lock_, const struct timeval *tv)
 {
-  CRITICAL_SECTION *lock = &lock->mutex;
+  CRITICAL_SECTION *lock = &lock_->mutex;
   int generation_at_start;
   int waiting = 1;
   int result = -1;
   DWORD ms = INFINITE, ms_orig = INFINITE, startTime, endTime;
   if (tv)
-    ms_orig = ms = evutil_tv_to_msec_(tv);
+    ms_orig = ms = tv->tv_sec*1000 + (tv->tv_usec+999)/1000;
 
   EnterCriticalSection(&cond->lock);
   ++cond->n_waiting;