summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/netlibbind.cpp15
-rw-r--r--src/mir_app/src/netlibopenconn.cpp35
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;