summaryrefslogtreecommitdiff
path: root/plugins/FavContacts
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-19 20:00:14 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-19 20:00:14 +0000
commit984d7e53da6eae8952d453ce6ae811ad9a82fd6d (patch)
tree6bdc450e827028ed0f8131ba95d55cee532d1365 /plugins/FavContacts
parent1f3a176affb5722a8183dafba354c6936f1aa3b6 (diff)
direct calls of ::CreateThread removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@7769 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/FavContacts')
-rw-r--r--plugins/FavContacts/src/Version.h2
-rw-r--r--plugins/FavContacts/src/cserver.cpp32
-rw-r--r--plugins/FavContacts/src/cserver.h4
-rw-r--r--plugins/FavContacts/src/http_api.cpp3
-rw-r--r--plugins/FavContacts/src/http_api.h2
-rw-r--r--plugins/FavContacts/src/main.cpp2
6 files changed, 17 insertions, 28 deletions
diff --git a/plugins/FavContacts/src/Version.h b/plugins/FavContacts/src/Version.h
index ecb84caf58..ce63cf30a2 100644
--- a/plugins/FavContacts/src/Version.h
+++ b/plugins/FavContacts/src/Version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 0
#define __RELEASE_NUM 0
-#define __BUILD_NUM 6
+#define __BUILD_NUM 7
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
diff --git a/plugins/FavContacts/src/cserver.cpp b/plugins/FavContacts/src/cserver.cpp
index b39c1df431..881f84cec2 100644
--- a/plugins/FavContacts/src/cserver.cpp
+++ b/plugins/FavContacts/src/cserver.cpp
@@ -5,12 +5,11 @@ void CServer::Start(int port, IConnectionProcessorFactory *connectionProcessorFa
m_socket = socket(AF_INET, SOCK_STREAM, 0);
if (m_socket == INVALID_SOCKET) return;
- sockaddr_in addr = {0};
+ sockaddr_in addr = { 0 };
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
addr.sin_port = htons((WORD)port);
- if (bind(m_socket, (sockaddr *)&addr, sizeof(addr)) == SOCKET_ERROR)
- {
+ if (bind(m_socket, (sockaddr *)&addr, sizeof(addr)) == SOCKET_ERROR) {
closesocket(m_socket);
m_socket = INVALID_SOCKET;
return;
@@ -21,15 +20,9 @@ void CServer::Start(int port, IConnectionProcessorFactory *connectionProcessorFa
m_connectionProcessorFactory = connectionProcessorFactory;
if (background)
- {
- CreateThread(NULL, 0,
- GlobalConnectionAcceptThread,
- this,
- 0, NULL);
- } else
- {
+ mir_forkthread(GlobalConnectionAcceptThread, this);
+ else
ConnectionAcceptThread();
- }
}
void CServer::Stop()
@@ -40,15 +33,11 @@ void CServer::Stop()
DWORD CServer::ConnectionAcceptThread()
{
- while (1)
- {
+ while (1) {
SOCKET s = accept(m_socket, NULL, NULL);
if (s == INVALID_SOCKET) break;
- CreateThread(NULL, 0,
- GlobalConnectionProcessThread,
- new GlobalConnectionProcessThreadArgs(this, s),
- 0, NULL);
+ mir_forkthread(GlobalConnectionProcessThread, new GlobalConnectionProcessThreadArgs(this, s));
}
return 0;
}
@@ -62,16 +51,15 @@ DWORD CServer::ConnectionProcessThread(SOCKET s)
return 0;
}
-DWORD WINAPI CServer::GlobalConnectionAcceptThread(void *arg)
+void CServer::GlobalConnectionAcceptThread(void *arg)
{
CServer *server = (CServer *)arg;
- return server->ConnectionAcceptThread();
+ server->ConnectionAcceptThread();
}
-DWORD WINAPI CServer::GlobalConnectionProcessThread(void *arg)
+void CServer::GlobalConnectionProcessThread(void *arg)
{
GlobalConnectionProcessThreadArgs *args = (GlobalConnectionProcessThreadArgs *)arg;
- DWORD result = args->m_server->ConnectionProcessThread(args->m_socket);
+ args->m_server->ConnectionProcessThread(args->m_socket);
delete args;
- return result;
}
diff --git a/plugins/FavContacts/src/cserver.h b/plugins/FavContacts/src/cserver.h
index 007a341896..f96c87b2c1 100644
--- a/plugins/FavContacts/src/cserver.h
+++ b/plugins/FavContacts/src/cserver.h
@@ -23,7 +23,7 @@ private:
DWORD ConnectionAcceptThread();
DWORD ConnectionProcessThread(SOCKET s);
- static DWORD WINAPI GlobalConnectionAcceptThread(void *arg);
+ static void GlobalConnectionAcceptThread(void *arg);
struct GlobalConnectionProcessThreadArgs
{
@@ -32,7 +32,7 @@ private:
GlobalConnectionProcessThreadArgs(CServer *server, SOCKET s): m_server(server), m_socket(s) {}
};
- static DWORD WINAPI GlobalConnectionProcessThread(void *arg);
+ static void GlobalConnectionProcessThread(void *arg);
public:
void Start(int port, IConnectionProcessorFactory *connectionProcessorFactory, bool background);
diff --git a/plugins/FavContacts/src/http_api.cpp b/plugins/FavContacts/src/http_api.cpp
index 18bae918ee..da0f9ee01c 100644
--- a/plugins/FavContacts/src/http_api.cpp
+++ b/plugins/FavContacts/src/http_api.cpp
@@ -154,7 +154,8 @@ void LoadHttpApi()
g_httpServer.Start(60888, &g_httpProcessorFactory, true);
}
-void UnloadHttpApi()
+int UnloadHttpApi(WPARAM, LPARAM)
{
g_httpServer.Stop();
+ return 0;
}
diff --git a/plugins/FavContacts/src/http_api.h b/plugins/FavContacts/src/http_api.h
index cccb7ea13b..936becc0e0 100644
--- a/plugins/FavContacts/src/http_api.h
+++ b/plugins/FavContacts/src/http_api.h
@@ -2,6 +2,6 @@
#define http_api_h__
void LoadHttpApi();
-void UnloadHttpApi();
+int UnloadHttpApi(WPARAM, LPARAM);
#endif // http_api_h__
diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp
index 18a6dd9df9..9339b613ae 100644
--- a/plugins/FavContacts/src/main.cpp
+++ b/plugins/FavContacts/src/main.cpp
@@ -296,6 +296,7 @@ extern "C" __declspec(dllexport) int Load(void)
HookEvent(ME_OPT_INITIALISE, ProcessOptInitialise);
HookEvent(ME_SYSTEM_MODULESLOADED, ProcessModulesLoaded);
+ HookEvent(ME_SYSTEM_SHUTDOWN, UnloadHttpApi);
/////////////////////////////////////////////////////////////////////////////////////
@@ -317,7 +318,6 @@ extern "C" __declspec(dllexport) int Load(void)
extern "C" __declspec(dllexport) int Unload(void)
{
- UnloadHttpApi();
if (g_hwndMenuHost) DestroyWindow(g_hwndMenuHost);
if (g_Options.hfntName) DeleteObject(g_Options.hfntName);
if (g_Options.hfntSecond) DeleteObject(g_Options.hfntSecond);