VirtualBox

Ignore:
Timestamp:
Dec 5, 2023 11:03:48 AM (14 months ago)
Author:
vboxsync
Message:

libs/xpcom: Convert the PR_Wait() function to take the timeout in milliseconds and get rid of PR_Interval* and use RTTime*, bugref:10545 [2nd attempt]

Location:
trunk/src/libs/xpcom18a4/ipc/ipcd
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/ipc/ipcd/client/public/ipcdclient.h

    r102392 r102470  
    5454#include "ipcIClientObserver.h"
    5555
    56 #include "prinrval.h"
     56#include <iprt/types.h>
    5757
    5858/* This API is only provided for the extensions compiled into the IPCDC
     
    240240  ipcIMessageObserver *aObserver = nsnull,
    241241  ipcIMessageObserver *aConsumer = nsnull,
    242   PRIntervalTime       aTimeout = PR_INTERVAL_NO_TIMEOUT
     242  RTMSINTERVAL        aTimeout = RT_INDEFINITE_WAIT
    243243);
    244244
  • trunk/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcService.cpp

    r102392 r102470  
    105105{
    106106    return IPC_WaitMessage(aSenderID, aTarget, aObserver, nsnull,
    107                            PR_MillisecondsToInterval(aTimeout));
     107                           aTimeout);
    108108}
    109109
  • trunk/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp

    r102392 r102470  
    6666/* ------------------------------------------------------------------------- */
    6767
    68 #define IPC_REQUEST_TIMEOUT PR_SecondsToInterval(30)
     68#define IPC_REQUEST_TIMEOUT (30 * RT_MS_1SEC)
    6969
    7070/* ------------------------------------------------------------------------- */
     
    307307static nsresult
    308308WaitTarget(const nsID           &aTarget,
    309            PRIntervalTime        aTimeout,
     309           RTMSINTERVAL         aTimeout,
    310310           ipcMessage          **aMsg,
    311311           ipcMessageSelector    aSelector = nsnull,
     
    323323  PRBool isIPCMTarget = aTarget.Equals(IPCM_TARGET);
    324324
    325   PRIntervalTime timeStart = PR_IntervalNow();
    326   PRIntervalTime timeEnd;
    327   if (aTimeout == PR_INTERVAL_NO_TIMEOUT)
    328     timeEnd = aTimeout;
    329   else if (aTimeout == PR_INTERVAL_NO_WAIT)
     325  uint64_t timeStart = RTTimeProgramMilliTS();
     326  uint64_t timeEnd;
     327  if (aTimeout == RT_INDEFINITE_WAIT)
     328    timeEnd = UINT64_MAX;
     329  else if (aTimeout == 0)
    330330    timeEnd = timeStart;
    331331  else
     
    335335    // if overflowed, then set to max value
    336336    if (timeEnd < timeStart)
    337       timeEnd = PR_INTERVAL_NO_TIMEOUT;
     337      timeEnd = UINT64_MAX;
    338338  }
    339339
     
    440440#endif /* VBOX */
    441441
    442     PRIntervalTime t = PR_IntervalNow();
    443     if (t > timeEnd) // check if timeout has expired
     442    uint64_t t = RTTimeProgramMilliTS();
     443    if (   aTimeout != RT_INDEFINITE_WAIT
     444        && t > timeEnd) // check if timeout has expired
    444445    {
    445446      rv = IPC_ERROR_WOULD_BLOCK;
    446447      break;
    447448    }
    448     mon.Wait(timeEnd - t);
     449    mon.Wait(  aTimeout == RT_INDEFINITE_WAIT
     450             ? RT_INDEFINITE_WAIT
     451             : timeEnd - t);
    449452
    450453    Log(("woke up from sleep [pendingQempty=%d connected=%d shutdown=%d isIPCMTarget=%d]\n",
     
    10811084                ipcIMessageObserver *aObserver,
    10821085                ipcIMessageObserver *aConsumer,
    1083                 PRIntervalTime       aTimeout)
     1086                RTMSINTERVAL        aTimeout)
    10841087{
    10851088  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp

    r102392 r102470  
    9696//-----------------------------------------------------------------------------
    9797
    98 #define DCON_WAIT_TIMEOUT PR_INTERVAL_NO_TIMEOUT
     98#define DCON_WAIT_TIMEOUT RT_INDEFINITE_WAIT
    9999
    100100//-----------------------------------------------------------------------------
     
    12811281    {
    12821282        uClient = aClient;
    1283         uTimestamp = PR_IntervalNow();
     1283        uTimestamp = RTTimeMilliTS();
    12841284    }
    12851285
    12861286    PRUint32 uClient;
    1287     PRIntervalTime uTimestamp;
     1287    uint64_t uTimestamp;
    12881288} ClientDownInfo;
    12891289typedef std::map<PRUint32, ClientDownInfo *> ClientDownMap;
     
    13261326        // Insert new client down information. Start by expiring outdated
    13271327        // entries and free one element if there's still no space (if needed).
    1328         PRIntervalTime now = PR_IntervalNow();
     1328        uint64_t now = RTTimeMilliTS();
    13291329        while (!g_ClientDownList.empty())
    13301330        {
     
    13321332            PRInt64 diff = (PRInt64)now - cInfo->uTimestamp;
    13331333            if (diff < 0)
    1334                 diff += (PRInt64)((PRIntervalTime)-1) + 1;
    1335             if (diff > PR_SecondsToInterval(15 * 60))
     1334                diff += (PRInt64)((uint64_t)-1) + 1;
     1335            if (diff > 15 * 60 * RT_MS_1SEC)
    13361336            {
    13371337                g_ClientDownMap.erase(cInfo->uClient);
     
    35573557    mon.Exit();
    35583558    {
    3559       PRUint32 ticks = PR_MillisecondsToInterval(PR_MIN(mWorkers.Count() / 20 + 1, 10));
    35603559      nsAutoMonitor workersMon(mWaitingWorkersMon);
    3561       workersMon.Wait(ticks);
     3560      workersMon.Wait(PR_MIN(mWorkers.Count() / 20 + 1, 10));
    35623561    }
    35633562    mon.Enter();
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/lock/src/ipcLockService.cpp

    r102392 r102470  
    109109        do {
    110110            // block the calling thread until we get a response from the daemon
    111             rv = IPC_WaitMessage(0, kLockTargetID, this, nsnull, PR_INTERVAL_NO_TIMEOUT);
     111            rv = IPC_WaitMessage(0, kLockTargetID, this, nsnull, RT_INDEFINITE_WAIT);
    112112        }
    113113        while (NS_SUCCEEDED(rv) && !pendingLock.complete);
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/src/tmTransactionService.cpp

    r102458 r102470  
    327327                  aTrans->GetRawMessageLength());
    328328  if (aSync)
    329     IPC_WaitMessage(0, kTransModuleID, nsnull, nsnull, PR_INTERVAL_NO_TIMEOUT);
     329    IPC_WaitMessage(0, kTransModuleID, nsnull, nsnull, RT_INDEFINITE_WAIT);
    330330}
    331331
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette