diff options
author | George Hazan <ghazan@miranda.im> | 2018-07-18 21:05:51 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-07-18 21:05:51 +0300 |
commit | 9aeb9578d8e264d4b351b597f20dc1cd7e86b278 (patch) | |
tree | c08a2d0da1475320a0527bd36964a0c921be3f03 /src | |
parent | 2c66660cb5a114cae20dca90348d28d13a1913e9 (diff) |
if there's no need, let's not call that hook
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/netlibbind.cpp | 15 | ||||
-rw-r--r-- | src/mir_app/src/netlibopenconn.cpp | 35 |
2 files changed, 26 insertions, 24 deletions
diff --git a/src/mir_app/src/netlibbind.cpp b/src/mir_app/src/netlibbind.cpp index 19b86361b4..f56fe5a4a0 100644 --- a/src/mir_app/src/netlibbind.cpp +++ b/src/mir_app/src/netlibbind.cpp @@ -292,13 +292,14 @@ LBL_Error: nlbp->hThread = mir_forkThread<NetlibBoundPort>(NetlibBindAcceptThread, nlbp);
- NETLIBCONNECTIONEVENTINFO ncei;
- ZeroMemory(&ncei, sizeof(ncei)); - ncei.connected = 1; - ncei.listening = 1; - ncei.szSettingsModule = nlu->user.szSettingsModule; - memcpy(&ncei.local, &sin, sizeof(sin)); - NotifyFastHook(hEventConnected, (WPARAM)&ncei, 0); + if (GetSubscribersCount((THook*)hEventConnected)) { + NETLIBCONNECTIONEVENTINFO ncei = {};
+ ncei.connected = 1; + ncei.listening = 1; + ncei.szSettingsModule = nlu->user.szSettingsModule; + memcpy(&ncei.local, &sin, sizeof(sin)); + NotifyFastHook(hEventConnected, (WPARAM)&ncei, 0); + } return nlbp;
}
diff --git a/src/mir_app/src/netlibopenconn.cpp b/src/mir_app/src/netlibopenconn.cpp index e0e5bba525..dfd2e365ef 100644 --- a/src/mir_app/src/netlibopenconn.cpp +++ b/src/mir_app/src/netlibopenconn.cpp @@ -773,24 +773,25 @@ bool NetlibDoConnect(NetlibConnection *nlc) Netlib_Logf(nlu, "(%d) Connected to %s:%d", nlc->s, nloc->szHost, nloc->wPort); - NETLIBCONNECTIONEVENTINFO ncei; - ZeroMemory(&ncei, sizeof(ncei)); - ncei.connected = 1; - ncei.szSettingsModule = nlu->user.szSettingsModule; - int size = sizeof(SOCKADDR_IN); - getsockname(nlc->s, (SOCKADDR *)&ncei.local, &size); - if (nlu->settings.useProxy) { - size = sizeof(SOCKADDR_IN); - getpeername(nlc->s, (SOCKADDR *)&ncei.proxy, &size); - ncei.remote.sin_family = AF_INET; - ncei.remote.sin_port = htons((short)nloc->wPort); - ncei.remote.sin_addr.S_un.S_addr = DnsLookup(nlu, nloc->szHost); - } - else { - size = sizeof(SOCKADDR_IN); - getpeername(nlc->s, (SOCKADDR *)&ncei.remote, &size); + if (GetSubscribersCount((THook*)hEventConnected)) { + NETLIBCONNECTIONEVENTINFO ncei = {}; + ncei.connected = 1; + ncei.szSettingsModule = nlu->user.szSettingsModule; + int size = sizeof(SOCKADDR_IN); + getsockname(nlc->s, (SOCKADDR *)&ncei.local, &size); + if (nlu->settings.useProxy) { + size = sizeof(SOCKADDR_IN); + getpeername(nlc->s, (SOCKADDR *)&ncei.proxy, &size); + ncei.remote.sin_family = AF_INET; + ncei.remote.sin_port = htons((short)nloc->wPort); + ncei.remote.sin_addr.S_un.S_addr = DnsLookup(nlu, nloc->szHost); + } + else { + size = sizeof(SOCKADDR_IN); + getpeername(nlc->s, (SOCKADDR *)&ncei.remote, &size); + } + NotifyFastHook(hEventConnected, (WPARAM)&ncei, 0); } - NotifyFastHook(hEventConnected, (WPARAM)&ncei, 0); if (NLOCF_SSL & nloc->flags) return Netlib_StartSsl(nlc, nullptr) != 0; |