PRBool NTStatsServer::removeInvalidItems(void)
{
    if (pollEvents_ != NULL)
    {
        PRInt32 nRemoved = 0;
        for (PRInt32 i = nPollItems_ - 1; i >= 0; i--)
        {
            if (pollEvents_[i] == INVALID_HANDLE_VALUE)
            {
                // Move everything else to fill the space created by the
                // one entry that was removed
                for (PRInt32 j = i + 1; j < nPollItems_; j++)
                {
                    pollEvents_[j - 1] = pollEvents_[j];
                    // swap the lpoverlapped from j-1 to j.
                    // It is important. We don't want to copy
                    // the overlapped pointer.
                    LPOVERLAPPED lpoverlapped = fdArray_[j - 1].lpoverlapped_;
                    // Also swap the msgChannel_
                    StatsServerMessage* msgChannel =
                        fdArray_[j - 1].msgChannel_;
                    memcpy(&fdArray_[j - 1], &fdArray_[j],
                           sizeof(StatsFileDesc));
                    fdArray_[j].lpoverlapped_ = lpoverlapped;
                    fdArray_[j].msgChannel_ = msgChannel;
                    resetHandles(j);
                }
                nRemoved++;
            }
        }
        nPollItems_ -= nRemoved;
    }
    return PR_TRUE;
}
PRBool NTStatsServer::invalidatePollItem(int nIndex)
{
    PRBool status = PR_FALSE;
    if (pollEvents_ != NULL)
    {
        CloseHandle(pollEvents_[nIndex]);
        DisconnectNamedPipe(fdArray_[nIndex].fd_);
        CloseHandle(fdArray_[nIndex].fd_);
        resetHandles(nIndex);
        status = PR_TRUE;
    }
    return status;
}
Example #3
0
int timeStampTester (int handle1, int handle2)
{
  int i, j, k;
  
  setupHandles(handle1, handle2);
  
  for (k=0; k<NR_OF_TESTS; k++) {
    tMax=-2000000000;
    tMin=2000000000;
    h1Errors=0;
    h2Errors=0;
    memset(ndiff, 0, sizeof(ndiff));
    beginTest(testName[k]);
    
    tStart=timeGetTime();
    for (i=0; i<NUMBER_OF_BURSTS; i++) {
      Blipp();
      
      // Generate a set of messages to be sent
      buildMsgBurst[k]();
      
      // Send the generated messages
      sendMsgBurst(i, handle1, handle2);
      
      // Read all messages on both handles and compare timestamps...
      for (j=0; j<2*BURST_SIZE; j++) {
        
        // Read one message from each handle
        readMsgPair(i, j, handle1, handle2);
          
        // Make sure that both messages are equal and that they are the expected pair
        compareMsgPair(i, j);
        
        // Compare the timestamps
        compareTimeStamps(i, j);
      }
    }
    NoBlipp();
    printSomeStuff();
  }

  if (tMax-tMin > DIFF_ALLOWED)
    Error("Timestamps differ to much (%d us)\n", (tMax-tMin)*10);
  
  resetHandles(handle1, handle2);

  return TRUE;
}