summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-02-05 20:42:57 +0300
committeraunsane <aunsane@gmail.com>2018-02-05 20:42:57 +0300
commitc3e7dd7529dc764922e2e728843fb1960caa1838 (patch)
tree170e6a765908699921220f24864f364839f2a1e8
parented602c0063f27466e1ebd2a4d68ee9237ab81bd6 (diff)
Tox: fixes for #1105
-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;