summaryrefslogtreecommitdiff
path: root/libproxy/proxy.cpp
diff options
context:
space:
mode:
authornpmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56>2010-01-20 00:37:26 +0000
committernpmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56>2010-01-20 00:37:26 +0000
commit099020bc04d77a2db79e8d0648392d361d78d9a5 (patch)
tree1b8addf989f5e3ade9ec386bc61c8adcd83284ad /libproxy/proxy.cpp
parentac51c595e812e5fd352ba16c6f8ebc01d2237af6 (diff)
downloadlibproxy-099020bc04d77a2db79e8d0648392d361d78d9a5.tar.gz
more win32 build fixes, including disabling pthread on win32
git-svn-id: http://libproxy.googlecode.com/svn/trunk@484 c587cffe-e639-0410-9787-d7902ae8ed56
Diffstat (limited to 'libproxy/proxy.cpp')
-rw-r--r--libproxy/proxy.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/libproxy/proxy.cpp b/libproxy/proxy.cpp
index eb3bacf..c71eaa2 100644
--- a/libproxy/proxy.cpp
+++ b/libproxy/proxy.cpp
@@ -20,11 +20,11 @@
#include <iostream>
#include <cstring>
-#include <pthread.h>
-
#ifdef _WIN32
#include <windows.h>
#define setenv(name, value, overwrite) SetEnvironmentVariable(name, value)
+#else
+#include <pthread.h>
#endif
#include "config_file.hpp"
@@ -42,7 +42,9 @@ public:
vector<string> get_proxies(string url);
private:
+#ifndef WIN32
pthread_mutex_t mutex;
+#endif
module_manager mm;
libproxy::pac* pac;
bool wpad;
@@ -95,8 +97,10 @@ _format_pac_response(string response)
}
proxy_factory::proxy_factory() {
+#ifndef WIN32
pthread_mutex_init(&this->mutex, NULL);
pthread_mutex_lock(&this->mutex);
+#endif
this->pac = NULL;
// Register our singletons
@@ -116,14 +120,20 @@ proxy_factory::proxy_factory() {
// Load all modules
this->mm.load_dir(MODULEDIR);
+#ifndef WIN32
pthread_mutex_unlock(&this->mutex);
+#endif
}
proxy_factory::~proxy_factory() {
+#ifndef WIN32
pthread_mutex_lock(&this->mutex);
+#endif
if (this->pac) delete this->pac;
+#ifndef WIN32
pthread_mutex_unlock(&this->mutex);
pthread_mutex_destroy(&this->mutex);
+#endif
}
@@ -142,8 +152,10 @@ vector<string> proxy_factory::get_proxies(string __url) {
goto do_return;
realurl = new url(__url);
+#ifndef WIN32
// Lock the mutex
pthread_mutex_lock(&this->mutex);
+#endif
// Check to see if our network topology has changed...
networks = this->mm.get_modules<network_module>();
@@ -275,7 +287,9 @@ vector<string> proxy_factory::get_proxies(string __url) {
/* Actually return, freeing misc stuff */
do_return:
+#ifndef WIN32
pthread_mutex_unlock(&this->mutex);
+#endif
if (realurl)
delete realurl;
if (response.size() == 0)