summaryrefslogtreecommitdiff
path: root/protocols/Tox
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Tox')
-rw-r--r--protocols/Tox/src/stdafx.h1
-rw-r--r--protocols/Tox/src/tox_connection.cpp9
2 files changed, 6 insertions, 4 deletions
diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h
index ee73c5856d..6d0f70935f 100644
--- a/protocols/Tox/src/stdafx.h
+++ b/protocols/Tox/src/stdafx.h
@@ -64,6 +64,7 @@ extern HINSTANCE g_hInstance;
#define TOX_ERROR -1
#define TOX_DEFAULT_INTERVAL 50
+#define TOX_CHECKING_INTERVAL 1000
#define TOX_MAX_CONNECT_RETRIES 10
#define TOX_MAX_RECONNECT_RETRIES 10
diff --git a/protocols/Tox/src/tox_connection.cpp b/protocols/Tox/src/tox_connection.cpp
index 24371e3233..564490e2e1 100644
--- a/protocols/Tox/src/tox_connection.cpp
+++ b/protocols/Tox/src/tox_connection.cpp
@@ -69,9 +69,11 @@ void CToxProto::CheckingThread(void *arg)
else
CheckConnection(tox, retriesCount);
- WaitForSingleObject(hTerminateEvent, 1000);
+ WaitForSingleObject(hTerminateEvent, TOX_CHECKING_INTERVAL);
}
+ hCheckingThread = nullptr;
+
debugLogA(__FUNCTION__": leaving");
}
@@ -104,7 +106,7 @@ void CToxProto::PollingThread(void*)
m_toxThread = &toxThread;
InitToxCore(toxThread.Tox());
BootstrapNodes(toxThread.Tox());
- ForkThread(&CToxProto::CheckingThread, toxThread.Tox());
+ hCheckingThread = ForkThreadEx(&CToxProto::CheckingThread, toxThread.Tox(), nullptr);
while (!isTerminated) {
tox_iterate(toxThread.Tox(), this);
@@ -116,8 +118,7 @@ void CToxProto::PollingThread(void*)
}
SetEvent(hTerminateEvent);
-
- Sleep(TOX_DEFAULT_INTERVAL * 10);
+ WaitForSingleObject(hCheckingThread, TOX_CHECKING_INTERVAL);
UninitToxCore(toxThread.Tox());
m_toxThread = nullptr;