From 27beec2e42d9acc55394ba03333de136c11f70b7 Mon Sep 17 00:00:00 2001 From: "darin%netscape.com" Date: Sun, 10 Nov 2002 22:34:47 +0000 Subject: [PATCH] make daemon PlatformSendMsg async on XP_WIN. git-svn-id: svn://10.0.0.236/trunk@133549 18797224-902f-48f8-a5cc-f745e15eee43 --- .../modules/ipc/daemon/ipcCommandModule.cpp | 2 +- mozilla/modules/ipc/daemon/ipcdWin.cpp | 40 +++++++++++++------ mozilla/modules/ipc/src/ipcTransportWin.cpp | 8 ++-- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/mozilla/modules/ipc/daemon/ipcCommandModule.cpp b/mozilla/modules/ipc/daemon/ipcCommandModule.cpp index 8d38ff2bac5..beb0ec58d66 100644 --- a/mozilla/modules/ipc/daemon/ipcCommandModule.cpp +++ b/mozilla/modules/ipc/daemon/ipcCommandModule.cpp @@ -167,7 +167,7 @@ IPCM_HandleMsg(ipcClient *client, const ipcMessage *rawMsg) }; int type = IPCM_GetMsgType(rawMsg); - LOG(("ipcCommandModule::HandleMsg [type=%d]\n", type)); + LOG(("IPCM_HandleMsg [type=%d]\n", type)); if (type < IPCM_MSG_TYPE_UNKNOWN) { if (handlers[type]) { diff --git a/mozilla/modules/ipc/daemon/ipcdWin.cpp b/mozilla/modules/ipc/daemon/ipcdWin.cpp index e717100cb5c..582b91095f5 100644 --- a/mozilla/modules/ipc/daemon/ipcdWin.cpp +++ b/mozilla/modules/ipc/daemon/ipcdWin.cpp @@ -57,7 +57,8 @@ static ipcClient ipcClientArray[IPC_MAX_CLIENTS]; static HWND ipcHwnd; #define IPC_PURGE_TIMER_ID 1 -#define IPC_WM_SHUTDOWN (WM_USER + 1) +#define IPC_WM_SENDMSG (WM_USER + 1) +#define IPC_WM_SHUTDOWN (WM_USER + 2) //----------------------------------------------------------------------------- // client array manipulation @@ -195,22 +196,19 @@ ProcessMsg(HWND hwnd, PRUint32 pid, const ipcMessage *msg) PRStatus IPC_PlatformSendMsg(ipcClient *client, ipcMessage *msg) { - LOG(("IPC_SendMessageNow [clientID=%u clientPID=%u]\n", + LOG(("IPC_PlatformSendMsg [clientID=%u clientPID=%u]\n", client->ID(), client->PID())); - // XXX use PostMessage to make this asynchronous; otherwise we might get + // use PostMessage to make this asynchronous; otherwise we might get // some wierd SendMessage recursion between processes. - COPYDATASTRUCT cd; - cd.dwData = GetCurrentProcessId(); - cd.cbData = (DWORD) msg->MsgLen(); - cd.lpData = (PVOID) msg->MsgBuf(); - - LOG(("calling SendMessage...\n")); - SendMessage(client->Hwnd(), WM_COPYDATA, 0, (LPARAM) &cd); - LOG((" done.\n")); - - delete msg; + WPARAM wParam = (WPARAM) client->Hwnd(); + LPARAM lParam = (LPARAM) msg; + if (!PostMessage(ipcHwnd, IPC_WM_SENDMSG, wParam, lParam)) { + LOG(("PostMessage failed\n")); + delete msg; + return PR_FAILURE; + } return PR_SUCCESS; } @@ -248,6 +246,22 @@ WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return 0; } + if (uMsg == IPC_WM_SENDMSG) { + HWND hWndDest = (HWND) wParam; + ipcMessage *msg = (ipcMessage *) lParam; + + COPYDATASTRUCT cd; + cd.dwData = GetCurrentProcessId(); + cd.cbData = (DWORD) msg->MsgLen(); + cd.lpData = (PVOID) msg->MsgBuf(); + + LOG(("calling SendMessage...\n")); + SendMessage(hWndDest, WM_COPYDATA, (WPARAM) hWnd, (LPARAM) &cd); + LOG((" done.\n")); + + delete msg; + } + if (uMsg == IPC_WM_SHUTDOWN) { DestroyWindow(hWnd); ipcHwnd = NULL; diff --git a/mozilla/modules/ipc/src/ipcTransportWin.cpp b/mozilla/modules/ipc/src/ipcTransportWin.cpp index 7f71a6c5b44..7cb70e1e16a 100644 --- a/mozilla/modules/ipc/src/ipcTransportWin.cpp +++ b/mozilla/modules/ipc/src/ipcTransportWin.cpp @@ -56,8 +56,8 @@ // windows message thread //----------------------------------------------------------------------------- -#define IPC_WM_SEND_MESSAGE (WM_USER + 0x1) -#define IPC_WM_SHUTDOWN (WM_USER + 0x2) +#define IPC_WM_SENDMSG (WM_USER + 0x1) +#define IPC_WM_SHUTDOWN (WM_USER + 0x2) static nsresult ipcThreadStatus = NS_OK; static PRThread *ipcThread; @@ -148,7 +148,7 @@ ipcThreadWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TRUE; } - if (uMsg == IPC_WM_SEND_MESSAGE) { + if (uMsg == IPC_WM_SENDMSG) { ipcMessage *msg = (ipcMessage *) lParam; if (msg) { LOG((" sending message...\n")); @@ -334,7 +334,7 @@ ipcTransport::SendMsg_Internal(ipcMessage *msg) NS_ENSURE_TRUE(ipcDaemonHwnd, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(ipcHwnd, NS_ERROR_NOT_INITIALIZED); - if (!PostMessage(ipcHwnd, IPC_WM_SEND_MESSAGE, 0, (LPARAM) msg)) { + if (!PostMessage(ipcHwnd, IPC_WM_SENDMSG, 0, (LPARAM) msg)) { LOG((" PostMessage failed w/ error = %u\n", GetLastError())); delete msg; return NS_ERROR_FAILURE;