summaryrefslogtreecommitdiff
path: root/src/libs/xpcom18a4/ipc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/xpcom18a4/ipc')
-rw-r--r--src/libs/xpcom18a4/ipc/ipcd/client/Makefile.kup0
-rw-r--r--src/libs/xpcom18a4/ipc/ipcd/client/src/Makefile.kup0
-rw-r--r--src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp75
-rw-r--r--src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp111
-rw-r--r--src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.cpp26
-rw-r--r--src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.h29
6 files changed, 165 insertions, 76 deletions
diff --git a/src/libs/xpcom18a4/ipc/ipcd/client/Makefile.kup b/src/libs/xpcom18a4/ipc/ipcd/client/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/libs/xpcom18a4/ipc/ipcd/client/Makefile.kup
diff --git a/src/libs/xpcom18a4/ipc/ipcd/client/src/Makefile.kup b/src/libs/xpcom18a4/ipc/ipcd/client/src/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/libs/xpcom18a4/ipc/ipcd/client/src/Makefile.kup
diff --git a/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp b/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp
index 3477949a..9212273b 100644
--- a/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp
+++ b/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp
@@ -58,6 +58,11 @@
#include "prproces.h"
#include "pratom.h"
+#ifdef VBOX
+# include <iprt/critsect.h>
+# define VBOX_WITH_IPCCLIENT_RW_CS
+#endif
+
/* ------------------------------------------------------------------------- */
#define IPC_REQUEST_TIMEOUT PR_SecondsToInterval(30)
@@ -146,10 +151,15 @@ public:
~ipcClientState()
{
+#ifndef VBOX_WITH_IPCCLIENT_RW_CS
if (monitor)
nsAutoMonitor::DestroyMonitor(monitor);
+#else
+ RTCritSectRwDelete(&critSect);
+#endif
}
+#ifndef VBOX_WITH_IPCCLIENT_RW_CS
//
// the monitor protects the targetMap and the connected and shutdown flags.
//
@@ -159,6 +169,9 @@ public:
// wrapper for PRLock.
//
PRMonitor *monitor;
+#else /* VBOX_WITH_IPCCLIENT_RW_CS */
+ RTCRITSECTRW critSect;
+#endif /* VBOX_WITH_IPCCLIENT_RW_CS */
ipcTargetMap targetMap;
PRBool connected;
PRBool shutdown;
@@ -171,11 +184,20 @@ public:
private:
ipcClientState()
+#ifndef VBOX_WITH_IPCCLIENT_RW_CS
: monitor(nsAutoMonitor::NewMonitor("ipcClientState"))
, connected(PR_FALSE)
+#else
+ : connected(PR_FALSE)
+#endif
, shutdown(PR_FALSE)
, selfID(0)
- {}
+ {
+#ifdef VBOX_WITH_IPCCLIENT_RW_CS
+ /* Not employing the lock validator here to keep performance up in debug builds. */
+ RTCritSectRwInitEx(&critSect, RTCRITSECT_FLAGS_NO_LOCK_VAL, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, NULL);
+#endif
+ }
};
ipcClientState *
@@ -185,7 +207,11 @@ ipcClientState::Create()
if (!cs)
return NULL;
+#ifndef VBOX_WITH_IPCCLIENT_RW_CS
if (!cs->monitor || !cs->targetMap.Init())
+#else
+ if (!RTCritSectRwIsInitialized(&cs->critSect) || !cs->targetMap.Init())
+#endif
{
delete cs;
return NULL;
@@ -201,22 +227,42 @@ static ipcClientState *gClientState;
static PRBool
GetTarget(const nsID &aTarget, ipcTargetData **td)
{
+#ifndef VBOX_WITH_IPCCLIENT_RW_CS
nsAutoMonitor mon(gClientState->monitor);
return gClientState->targetMap.Get(nsIDHashKey(&aTarget).GetKey(), td);
+#else
+ RTCritSectRwEnterShared(&gClientState->critSect);
+ PRBool fRc = gClientState->targetMap.Get(nsIDHashKey(&aTarget).GetKey(), td);
+ RTCritSectRwLeaveShared(&gClientState->critSect);
+ return fRc;
+#endif
}
static PRBool
PutTarget(const nsID &aTarget, ipcTargetData *td)
{
+#ifndef VBOX_WITH_IPCCLIENT_RW_CS
nsAutoMonitor mon(gClientState->monitor);
return gClientState->targetMap.Put(nsIDHashKey(&aTarget).GetKey(), td);
+#else
+ RTCritSectRwEnterExcl(&gClientState->critSect);
+ PRBool fRc = gClientState->targetMap.Put(nsIDHashKey(&aTarget).GetKey(), td);
+ RTCritSectRwLeaveExcl(&gClientState->critSect);
+ return fRc;
+#endif
}
static void
DelTarget(const nsID &aTarget)
{
+#ifndef VBOX_WITH_IPCCLIENT_RW_CS
nsAutoMonitor mon(gClientState->monitor);
gClientState->targetMap.Remove(nsIDHashKey(&aTarget).GetKey());
+#else
+ RTCritSectRwEnterExcl(&gClientState->critSect);
+ gClientState->targetMap.Remove(nsIDHashKey(&aTarget).GetKey());
+ RTCritSectRwLeaveExcl(&gClientState->critSect);
+#endif
}
/* ------------------------------------------------------------------------- */
@@ -804,9 +850,18 @@ IPC_Shutdown()
// first, set the shutdown flag and unblock any calls to WaitTarget.
// all targets but IPCM will not be able to use WaitTarget any more.
+#ifndef VBOX_WITH_IPCCLIENT_RW_CS
nsAutoMonitor mon(gClientState->monitor);
+#else
+ RTCritSectRwEnterExcl(&gClientState->critSect);
+#endif
+
gClientState->shutdown = PR_TRUE;
gClientState->targetMap.EnumerateRead(EnumerateTargetMapAndNotify, nsnull);
+
+#ifdef VBOX_WITH_IPCCLIENT_RW_CS
+ RTCritSectRwLeaveExcl(&gClientState->critSect);
+#endif
}
// inform all client observers that we're being shutdown to let interested
@@ -1289,9 +1344,18 @@ IPC_OnConnectionEnd(nsresult error)
// now, go through the target map, and tickle each monitor. that should
// unblock any calls to WaitTarget.
+#ifndef VBOX_WITH_IPCCLIENT_RW_CS
nsAutoMonitor mon(gClientState->monitor);
+#else
+ RTCritSectRwEnterExcl(&gClientState->critSect);
+#endif
+
gClientState->connected = PR_FALSE;
gClientState->targetMap.EnumerateRead(EnumerateTargetMapAndNotify, nsnull);
+
+#ifdef VBOX_WITH_IPCCLIENT_RW_CS
+ RTCritSectRwLeaveExcl(&gClientState->critSect);
+#endif
}
/* ------------------------------------------------------------------------- */
@@ -1309,6 +1373,7 @@ PlaceOnPendingQ(const nsID &target, ipcTargetData *td, ipcMessage *msg)
td->pendingQ.Append(msg);
#ifdef IPC_LOGGING
+ if (IPC_LOG_ENABLED())
{
char *targetStr = target.ToString();
LOG(("placed message on pending queue for target %s and notifying all...\n", targetStr));
@@ -1391,9 +1456,17 @@ IPC_OnMessageAvailable(ipcMessage *msg)
// pending event queue. that unblocks all WaitTarget calls (on all
// targets) giving them an opportuninty to finish wait cycle because of
// the peer client death, when appropriate.
+#ifndef VBOX_WITH_IPCCLIENT_RW_CS
nsAutoMonitor mon(gClientState->monitor);
+#else
+ RTCritSectRwEnterShared(&gClientState->critSect);
+#endif
+
gClientState->targetMap.EnumerateRead(EnumerateTargetMapAndPlaceMsg, msg);
+#ifdef VBOX_WITH_IPCCLIENT_RW_CS
+ RTCritSectRwLeaveShared(&gClientState->critSect);
+#endif
delete msg;
return;
diff --git a/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp b/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp
index e9a40271..b20fdd8e 100644
--- a/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp
+++ b/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp
@@ -1580,7 +1580,7 @@ DConnectStub::AddRefIPC()
// DConnectInstance::CreateStub
nsrefcnt count = AddRef();
- mRefCntLevels.Push((void *) count);
+ mRefCntLevels.Push((void *)(uintptr_t) count);
return count;
}
@@ -1981,7 +1981,13 @@ ipcDConnectService::SerializeException(ipcMessageWriter &writer,
if (!xcpt)
{
// write null address
+#ifdef VBOX
+ // see ipcDConnectService::DeserializeException()!
+ PtrBits bits = 0;
+ writer.PutBytes(&bits, sizeof(bits));
+#else
writer.PutBytes(&xcpt, sizeof(xcpt));
+#endif
}
else
{
@@ -2232,10 +2238,13 @@ ipcDConnectService::DeserializeException(ipcMessageReader &reader,
DConnectStub::~DConnectStub()
{
#ifdef IPC_LOGGING
- const char *name = NULL;
- mIInfo->GetNameShared(&name);
- LOG(("{%p} DConnectStub::<dtor>(): peer=%d instance=0x%Lx {%s}\n",
- this, mPeerID, mInstance, name));
+ if (IPC_LOG_ENABLED())
+ {
+ const char *name = NULL;
+ mIInfo->GetNameShared(&name);
+ LOG(("{%p} DConnectStub::<dtor>(): peer=%d instance=0x%Lx {%s}\n",
+ this, mPeerID, mInstance, name));
+ }
#endif
// release the cached nsISupports instance if it's not the same object
@@ -2273,10 +2282,13 @@ DConnectStub::Release()
#ifdef IPC_LOGGING
- const char *name;
- mIInfo->GetNameShared(&name);
- LOG(("{%p} DConnectStub::Release(): peer=%d instance=0x%Lx {%s}, new count=%d\n",
- this, mPeerID, mInstance, name, count));
+ if (IPC_LOG_ENABLED())
+ {
+ const char *name;
+ mIInfo->GetNameShared(&name);
+ LOG(("{%p} DConnectStub::Release(): peer=%d instance=0x%Lx {%s}, new count=%d\n",
+ this, mPeerID, mInstance, name, count));
+ }
#endif
// mRefCntLevels may already be empty here (due to the "stabilize" trick below)
@@ -2431,6 +2443,7 @@ DConnectStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
// else, we need to query the peer object by making an IPC call
#ifdef IPC_LOGGING
+ if (IPC_LOG_ENABLED())
{
const char *name;
mIInfo->GetNameShared(&name);
@@ -2517,13 +2530,16 @@ DConnectStub::CallMethod(PRUint16 aMethodIndex,
PRUint8 i, paramCount = aInfo->GetParamCount();
#ifdef IPC_LOGGING
- const char *name;
- nsCOMPtr<nsIInterfaceInfo> iinfo;
- GetInterfaceInfo(getter_AddRefs(iinfo));
- iinfo->GetNameShared(&name);
- LOG((" instance=0x%Lx {%s}\n", mInstance, name));
- LOG((" name=%s\n", aInfo->GetName()));
- LOG((" param-count=%u\n", (PRUint32) paramCount));
+ if (IPC_LOG_ENABLED())
+ {
+ const char *name;
+ nsCOMPtr<nsIInterfaceInfo> iinfo;
+ GetInterfaceInfo(getter_AddRefs(iinfo));
+ iinfo->GetNameShared(&name);
+ LOG((" instance=0x%Lx {%s}\n", mInstance, name));
+ LOG((" name=%s\n", aInfo->GetName()));
+ LOG((" param-count=%u\n", (PRUint32) paramCount));
+ }
#endif
@@ -3006,10 +3022,13 @@ EnumerateInstanceMapAndDelete (const DConnectInstanceKey::Key &aKey,
// disregarding the reference counter
#ifdef IPC_LOGGING
- const char *name;
- aData->InterfaceInfo()->GetNameShared(&name);
- LOG(("ipcDConnectService: WARNING: deleting unreleased "
- "instance=%p iface=%p {%s}\n", aData, aData->RealInstance(), name));
+ if (IPC_LOG_ENABLED())
+ {
+ const char *name;
+ aData->InterfaceInfo()->GetNameShared(&name);
+ LOG(("ipcDConnectService: WARNING: deleting unreleased "
+ "instance=%p iface=%p {%s}\n", aData, aData->RealInstance(), name));
+ }
#endif
delete aData;
@@ -3251,10 +3270,13 @@ nsresult
ipcDConnectService::StoreInstance(DConnectInstance *wrapper)
{
#ifdef IPC_LOGGING
- const char *name;
- wrapper->InterfaceInfo()->GetNameShared(&name);
- LOG(("ipcDConnectService::StoreInstance(): instance=%p iface=%p {%s}\n",
- wrapper, wrapper->RealInstance(), name));
+ if (IPC_LOG_ENABLED())
+ {
+ const char *name;
+ wrapper->InterfaceInfo()->GetNameShared(&name);
+ LOG(("ipcDConnectService::StoreInstance(): instance=%p iface=%p {%s}\n",
+ wrapper, wrapper->RealInstance(), name));
+ }
#endif
nsresult rv = mInstanceSet.Put(wrapper);
@@ -3276,10 +3298,13 @@ ipcDConnectService::DeleteInstance(DConnectInstance *wrapper,
PR_Lock(mLock);
#ifdef IPC_LOGGING
- const char *name;
- wrapper->InterfaceInfo()->GetNameShared(&name);
- LOG(("ipcDConnectService::DeleteInstance(): instance=%p iface=%p {%s}\n",
- wrapper, wrapper->RealInstance(), name));
+ if (IPC_LOG_ENABLED())
+ {
+ const char *name;
+ wrapper->InterfaceInfo()->GetNameShared(&name);
+ LOG(("ipcDConnectService::DeleteInstance(): instance=%p iface=%p {%s}\n",
+ wrapper, wrapper->RealInstance(), name));
+ }
#endif
mInstances.Remove(wrapper->GetKey());
@@ -3318,12 +3343,15 @@ nsresult
ipcDConnectService::StoreStub(DConnectStub *stub)
{
#ifdef IPC_LOGGING
- const char *name;
- nsCOMPtr<nsIInterfaceInfo> iinfo;
- stub->GetInterfaceInfo(getter_AddRefs(iinfo));
- iinfo->GetNameShared(&name);
- LOG(("ipcDConnectService::StoreStub(): stub=%p instance=0x%Lx {%s}\n",
- stub, stub->Instance(), name));
+ if (IPC_LOG_ENABLED())
+ {
+ const char *name;
+ nsCOMPtr<nsIInterfaceInfo> iinfo;
+ stub->GetInterfaceInfo(getter_AddRefs(iinfo));
+ iinfo->GetNameShared(&name);
+ LOG(("ipcDConnectService::StoreStub(): stub=%p instance=0x%Lx {%s}\n",
+ stub, stub->Instance(), name));
+ }
#endif
return mStubs.Put(stub->GetKey(), stub)
@@ -3334,12 +3362,15 @@ void
ipcDConnectService::DeleteStub(DConnectStub *stub)
{
#ifdef IPC_LOGGING
- const char *name;
- nsCOMPtr<nsIInterfaceInfo> iinfo;
- stub->GetInterfaceInfo(getter_AddRefs(iinfo));
- iinfo->GetNameShared(&name);
- LOG(("ipcDConnectService::DeleteStub(): stub=%p instance=0x%Lx {%s}\n",
- stub, stub->Instance(), name));
+ if (IPC_LOG_ENABLED())
+ {
+ const char *name;
+ nsCOMPtr<nsIInterfaceInfo> iinfo;
+ stub->GetInterfaceInfo(getter_AddRefs(iinfo));
+ iinfo->GetNameShared(&name);
+ LOG(("ipcDConnectService::DeleteStub(): stub=%p instance=0x%Lx {%s}\n",
+ stub, stub->Instance(), name));
+ }
#endif
// this method is intended to be called only from DConnectStub::Release().
diff --git a/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.cpp b/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.cpp
index 00035c8e..340b211c 100644
--- a/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.cpp
+++ b/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.cpp
@@ -48,10 +48,10 @@
#include "plstr.h"
#ifdef VBOX
-#if defined(__OS2__) && defined(PAGE_SIZE)
-#undef PAGE_SIZE
-#endif
-#include <iprt/initterm.h> // for RTR3InitDll
+# if defined(__OS2__) && defined(PAGE_SIZE)
+# undef PAGE_SIZE
+# endif
+# include <iprt/initterm.h> // for RTR3InitDll
#else // !VBOX
PRBool ipcLogEnabled = PR_FALSE;
#endif // !VBOX
@@ -65,21 +65,6 @@ char ipcLogPrefix[10] = {0};
//-----------------------------------------------------------------------------
#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
- #if defined(L4ENV)
-#include <l4/sys/types.h>
-#include <l4/sys/syscalls.h>
-
-static inline PRUint32
-WritePrefix(char *buf, PRUint32 bufLen)
-{
- l4_threadid_t my_id = l4_myself();
- return PR_snprintf(buf, bufLen, "[%u.%u] %s ",
- static_cast<unsigned>(my_id.id.task),
- static_cast<unsigned>(my_id.id.lthread),
- ipcLogPrefix);
-}
-
- #else /* Not L4ENV */
#include <sys/types.h>
#include <unistd.h>
@@ -91,7 +76,6 @@ WritePrefix(char *buf, PRUint32 bufLen)
PR_GetCurrentThread(),
ipcLogPrefix);
}
- #endif /* Not L4ENV */
#endif
//-----------------------------------------------------------------------------
@@ -121,7 +105,7 @@ IPC_InitLog(const char *prefix)
{
#ifdef VBOX
// initialize VBox Runtime
- RTR3InitDll(0);
+ RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
PL_strncpyz(ipcLogPrefix, prefix, sizeof(ipcLogPrefix));
#else
diff --git a/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.h b/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.h
index 8d480190..e21f6211 100644
--- a/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.h
+++ b/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcLog.h
@@ -52,15 +52,15 @@
#ifdef VBOX
/* Redefine logging group to IPC */
-#ifdef LOG_GROUP
-#undef LOG_GROUP
-#endif
-#define LOG_GROUP LOG_GROUP_IPC
+# ifdef LOG_GROUP
+# undef LOG_GROUP
+# endif
+# define LOG_GROUP LOG_GROUP_IPC
/* Ensure log macros are enabled */
-#ifndef LOG_ENABLED
-#define LOG_ENABLED
-#endif
+# ifndef LOG_ENABLED
+# define LOG_ENABLED
+# endif
#include <VBox/log.h>
@@ -68,17 +68,18 @@ extern NS_HIDDEN_(void) IPC_InitLog(const char *prefix);
extern NS_HIDDEN_(void) IPC_Log(const char *fmt, ...);
extern NS_HIDDEN_(void) IPC_LogBinary(const PRUint8 *data, PRUint32 len);
-#define IPC_LOG(_args) \
- PR_BEGIN_MACRO \
- IPC_Log _args; \
+# define IPC_LOG(_args) \
+ PR_BEGIN_MACRO \
+ if (IPC_LOG_ENABLED()) \
+ IPC_Log _args; \
PR_END_MACRO
/* IPC_Log() internally uses LogFlow() so use LogIsFlowEnabled() below */
-#define IPC_LOG_ENABLED() (LogIsFlowEnabled())
+# define IPC_LOG_ENABLED() (LogIsFlowEnabled())
-#define LOG(args) IPC_LOG(args)
+# define LOG(args) IPC_LOG(args)
-#else // VBOX
+#else /* !VBOX */
extern PRBool ipcLogEnabled;
extern NS_HIDDEN_(void) IPC_InitLog(const char *prefix);
@@ -95,7 +96,7 @@ extern NS_HIDDEN_(void) IPC_LogBinary(const PRUint8 *data, PRUint32 len);
#define LOG(args) IPC_LOG(args)
-#endif // VBOX
+#endif /* !VBOX */
#else // IPC_LOGGING