diff options
author | George Hazan <george.hazan@gmail.com> | 2016-09-19 09:00:39 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-09-19 09:00:39 +0000 |
commit | 02e620f9e74ba52ed16b009d9ea76169e5a735d8 (patch) | |
tree | 0ff6faa0fa0153526a5ac271c29d6e4a39d84b54 /src/mir_app | |
parent | 52a4fbdec80fd6646f125e26b5319b8dc7fe9a2d (diff) |
no need to lock all chats for each event
we lock only chat creation/destruction and finding chat session
git-svn-id: http://svn.miranda-ng.org/main/trunk@17314 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 1 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 52 |
2 files changed, 26 insertions, 27 deletions
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 9758431011..6fb83d1e92 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -160,6 +160,7 @@ static SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule) if (!pszID || !pszModule)
return NULL;
+ mir_cslock lck(csChat);
for (SESSION_INFO *si = chatApi.wndList; si != NULL; si = si->next)
if (!mir_wstrcmpi(si->ptszID, pszID) && !mir_strcmpi(si->pszModule, pszModule))
return si;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index c6b1e486ec..da27bdd19a 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -260,23 +260,17 @@ EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *gcw) /////////////////////////////////////////////////////////////////////////////////////////
// chat control
-struct ShowChatParam
+struct ChatConrolParam
{
- ShowChatParam(SESSION_INFO *_si, int _command, int _bShow) :
- si(_si), command(_command), bShow(_bShow)
+ ChatConrolParam(const char *_szModule, const wchar_t *_wszId, int _command) :
+ szModule(_szModule), wszId(_wszId), command(_command)
{}
- SESSION_INFO *si;
- int command, bShow;
+ const wchar_t *wszId;
+ const char *szModule;
+ int command;
};
-static void __stdcall stubShowRoom(void *param)
-{
- ShowChatParam *p = (ShowChatParam*)param;
- chatApi.ShowRoom(p->si, p->command, p->bShow);
- delete p;
-}
-
static void SetInitDone(SESSION_INFO *si)
{
if (si->bInitDone)
@@ -288,18 +282,18 @@ static void SetInitDone(SESSION_INFO *si) p->hIcon = HICON(si->iStatusCount - (INT_PTR)p->hIcon - 1);
}
-MIR_APP_DLL(int) Chat_Control(const char *szModule, const wchar_t *wszId, int iCommand)
+static INT_PTR __stdcall stubRoomControl(void *param)
{
- SESSION_INFO *si;
+ ChatConrolParam *p = (ChatConrolParam*)param;
mir_cslock lck(csChat);
- switch (iCommand) {
+ switch (p->command) {
case WINDOW_HIDDEN:
- if (si = chatApi.SM_FindSession(wszId, szModule)) {
+ if (SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule)) {
SetInitDone(si);
chatApi.SetActiveSession(si->ptszID, si->pszModule);
if (si->hWnd)
- CallFunctionAsync(stubShowRoom, new ShowChatParam(si, iCommand, FALSE));
+ chatApi.ShowRoom(si, p->command, FALSE);
}
return 0;
@@ -307,27 +301,27 @@ MIR_APP_DLL(int) Chat_Control(const char *szModule, const wchar_t *wszId, int iC case WINDOW_MAXIMIZE:
case WINDOW_VISIBLE:
case SESSION_INITDONE:
- if (si = chatApi.SM_FindSession(wszId, szModule)) {
+ if (SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule)) {
SetInitDone(si);
- if (iCommand != SESSION_INITDONE || db_get_b(NULL, CHAT_MODULE, "PopupOnJoin", 0) == 0)
- CallFunctionAsync(stubShowRoom, new ShowChatParam(si, iCommand, TRUE));
+ if (p->command != SESSION_INITDONE || db_get_b(NULL, CHAT_MODULE, "PopupOnJoin", 0) == 0)
+ chatApi.ShowRoom(si, p->command, TRUE);
return 0;
}
break;
case SESSION_OFFLINE:
- chatApi.SM_SetOffline(wszId, szModule);
+ chatApi.SM_SetOffline(p->wszId, p->szModule);
// fall through
case SESSION_ONLINE:
- chatApi.SM_SetStatus(wszId, szModule, iCommand == SESSION_ONLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
+ chatApi.SM_SetStatus(p->wszId, p->szModule, p->command == SESSION_ONLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
break;
case SESSION_TERMINATE:
- return chatApi.SM_RemoveSession(wszId, szModule, false);
+ return chatApi.SM_RemoveSession(p->wszId, p->szModule, false);
case WINDOW_CLEARLOG:
- if (si = chatApi.SM_FindSession(wszId, szModule)) {
+ if (SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule)) {
chatApi.LM_RemoveAll(&si->pLog, &si->pLogEnd);
if (chatApi.OnClearLog)
chatApi.OnClearLog(si);
@@ -340,10 +334,16 @@ MIR_APP_DLL(int) Chat_Control(const char *szModule, const wchar_t *wszId, int iC return GC_EVENT_ERROR;
}
- chatApi.SM_SendMessage(wszId, szModule, GC_CONTROL_MSG, iCommand, 0);
+ chatApi.SM_SendMessage(p->wszId, p->szModule, GC_CONTROL_MSG, p->command, 0);
return 0;
}
+MIR_APP_DLL(int) Chat_Control(const char *szModule, const wchar_t *wszId, int iCommand)
+{
+ ChatConrolParam param = { szModule, wszId, iCommand };
+ return CallFunctionSync(stubRoomControl, ¶m);
+}
+
MIR_APP_DLL(int) Chat_Terminate(const char *szModule, const wchar_t *wszId, bool bRemoveContact)
{
mir_cslock lck(csChat);
@@ -430,8 +430,6 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) if (NotifyEventHooks(hHookEvent, 0, LPARAM(gce)))
return 1;
- mir_cslock lck(csChat);
-
// Do different things according to type of event
switch (gcd->iType) {
case GC_EVENT_ADDGROUP:
|