summaryrefslogtreecommitdiff
path: root/protocols/IcqOscarJ/src/chan_05ping.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/IcqOscarJ/src/chan_05ping.cpp')
-rw-r--r--protocols/IcqOscarJ/src/chan_05ping.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/protocols/IcqOscarJ/src/chan_05ping.cpp b/protocols/IcqOscarJ/src/chan_05ping.cpp
index bd5539b974..62c3377ada 100644
--- a/protocols/IcqOscarJ/src/chan_05ping.cpp
+++ b/protocols/IcqOscarJ/src/chan_05ping.cpp
@@ -29,7 +29,6 @@ void CIcqProto::handlePingChannel(BYTE *buf, WORD datalen)
debugLogA("Warning: Ignoring server packet on PING channel");
}
-
void __cdecl CIcqProto::KeepAliveThread(void *arg)
{
serverthread_info *info = (serverthread_info*)arg;
@@ -40,23 +39,21 @@ void __cdecl CIcqProto::KeepAliveThread(void *arg)
info->hKeepAliveEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- for (;;)
- {
+ for (;;) {
DWORD dwWait = ICQWaitForSingleObject(info->hKeepAliveEvent, dwInterval);
if (serverThreadHandle == NULL) // connection lost, end
break;
- if (dwWait == WAIT_TIMEOUT)
- {
+
+ // Possible shutdown in progress
+ if (dwWait == WAIT_IO_COMPLETION)
+ break;
+
+ if (dwWait == WAIT_TIMEOUT) {
// Send a keep alive packet to server
packet.wLen = 0;
write_flap(&packet, ICQ_PING_CHAN);
sendServPacket(&packet);
}
- else if (dwWait == WAIT_IO_COMPLETION)
- // Possible shutdown in progress
- if (Miranda_Terminated()) break;
- else
- break;
}
debugLogA("Keep alive thread ended.");
@@ -65,19 +62,17 @@ void __cdecl CIcqProto::KeepAliveThread(void *arg)
info->hKeepAliveEvent = NULL;
}
-
void CIcqProto::StartKeepAlive(serverthread_info *info)
{
if (info->hKeepAliveEvent) // start only once
return;
if (getByte("KeepAlive", DEFAULT_KEEPALIVE_ENABLED))
- CloseHandle( ForkThreadEx(&CIcqProto::KeepAliveThread, info, 0));
+ ForkThread(&CIcqProto::KeepAliveThread, info);
}
-
void CIcqProto::StopKeepAlive(serverthread_info *info)
-{ // finish keep alive thread
+{
if (info->hKeepAliveEvent)
SetEvent(info->hKeepAliveEvent);
}