diff options
author | npmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56> | 2010-02-10 03:07:40 +0000 |
---|---|---|
committer | npmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56> | 2010-02-10 03:07:40 +0000 |
commit | 28fa12244ae076c4d1180c2c34ac2949e2669e3e (patch) | |
tree | 381c58d5eb2996fa076e4ff0062f0b3a78cd98a8 /libproxy/proxy.cpp | |
parent | b450fee8e31cda531ab2b085f5fbfb20325c0940 (diff) | |
download | libproxy-28fa12244ae076c4d1180c2c34ac2949e2669e3e.tar.gz |
add support for win32 mutexes
git-svn-id: http://libproxy.googlecode.com/svn/trunk@535 c587cffe-e639-0410-9787-d7902ae8ed56
Diffstat (limited to 'libproxy/proxy.cpp')
-rw-r--r-- | libproxy/proxy.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/libproxy/proxy.cpp b/libproxy/proxy.cpp index 151dc09..b639b73 100644 --- a/libproxy/proxy.cpp +++ b/libproxy/proxy.cpp @@ -43,7 +43,9 @@ public: vector<string> get_proxies(string url); private: -#ifndef WIN32 +#ifdef WIN32 + HANDLE mutex; +#else pthread_mutex_t mutex; #endif module_manager mm; @@ -99,7 +101,10 @@ _format_pac_response(string response) } proxy_factory::proxy_factory() { -#ifndef WIN32 +#ifdef WIN32 + this->mutex = CreateMutex(NULL, false, NULL); + WaitForSingleObject(this->mutex, INFINITE); +#else pthread_mutex_init(&this->mutex, NULL); pthread_mutex_lock(&this->mutex); #endif @@ -117,18 +122,24 @@ proxy_factory::proxy_factory() { this->mm.load_dir(MODULEDIR); this->mm.load_dir(MODULEDIR, false); -#ifndef WIN32 +#ifdef WIN32 + ReleaseMutex(this->mutex); +#else pthread_mutex_unlock(&this->mutex); #endif } proxy_factory::~proxy_factory() { -#ifndef WIN32 +#ifdef WIN32 + WaitForSingleObject(this->mutex, INFINITE); +#else pthread_mutex_lock(&this->mutex); #endif if (this->pac) delete this->pac; if (this->pacurl) delete this->pacurl; -#ifndef WIN32 +#ifdef WIN32 + ReleaseMutex(this->mutex); +#else pthread_mutex_unlock(&this->mutex); pthread_mutex_destroy(&this->mutex); #endif @@ -150,8 +161,9 @@ vector<string> proxy_factory::get_proxies(string __url) { goto do_return; realurl = new url(__url); -#ifndef WIN32 - // Lock the mutex +#ifdef WIN32 + WaitForSingleObject(this->mutex, INFINITE); +#else pthread_mutex_lock(&this->mutex); #endif @@ -296,7 +308,9 @@ vector<string> proxy_factory::get_proxies(string __url) { /* Actually return, freeing misc stuff */ do_return: -#ifndef WIN32 +#ifdef WIN32 + ReleaseMutex(this->mutex); +#else pthread_mutex_unlock(&this->mutex); #endif if (realurl) |