<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><DIV>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">void BasicTaskScheduler::SingleStep(unsigned maxDelayTime) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  fd_set readSet = fReadSet; // make a copy for this select() call<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  fd_set writeSet = fWriteSet; // ditto<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  fd_set exceptionSet = fExceptionSet; // ditto<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><o:p><FONT face="Calibri"> </FONT></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  DelayInterval const& timeToDelay = fDelayQueue.timeToNextAlarm();<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  struct timeval tv_timeToDelay;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  tv_timeToDelay.tv_sec = timeToDelay.seconds();<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  tv_timeToDelay.tv_usec = timeToDelay.useconds();<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  // Very large "tv_sec" values cause select() to fail.<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  // Don't make it any larger than 1 million seconds (11.5 days)<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  const long MAX_TV_SEC = MILLION;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  if (tv_timeToDelay.tv_sec > MAX_TV_SEC) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    tv_timeToDelay.tv_sec = MAX_TV_SEC;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  // Also check our "maxDelayTime" parameter (if it's > 0):<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  if (maxDelayTime > 0 &&<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      (tv_timeToDelay.tv_sec > (long)maxDelayTime/MILLION ||<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">       (tv_timeToDelay.tv_sec == (long)maxDelayTime/MILLION &&<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">        tv_timeToDelay.tv_usec > (long)maxDelayTime%MILLION))) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    tv_timeToDelay.tv_sec = maxDelayTime/MILLION;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    tv_timeToDelay.tv_usec = maxDelayTime%MILLION;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: red" lang="EN-US"><FONT face="Calibri">/* Here should process the queue data before get new frame from source, this very important for IP net work camera, the video latency will 50ms shorter than before. Zack */<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: red" lang="EN-US"><FONT face="Calibri">if (tv_timeToDelay.tv_sec == 0 && tv_timeToDelay.tv_usec == 0){<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: red" lang="EN-US"><FONT face="Calibri">         fDelayQueue.handleAlarm();<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: red" lang="EN-US"><FONT face="Calibri">         return ;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: red" lang="EN-US"><FONT face="Calibri">}<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><o:p><FONT face="Calibri"> </FONT></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  int selectResult = select(fMaxNumSockets, &readSet, &writeSet, &exceptionSet, &tv_timeToDelay);<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  if (selectResult < 0) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">#if defined(__WIN32__) || defined(_WIN32)<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    int err = WSAGetLastError();<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    // For some unknown reason, select() in Windoze sometimes fails with WSAEINVAL if<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    // it was called with no entries set in "readSet".  If this happens, ignore it:<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    if (err == WSAEINVAL && readSet.fd_count == 0) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      err = EINTR;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      // To stop this from happening again, create a dummy socket:<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      int dummySocketNum = socket(AF_INET, SOCK_DGRAM, 0);<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      FD_SET((unsigned)dummySocketNum, &fReadSet);<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      FD_SET((unsigned)dummySocketNum, &fWriteSet);<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      FD_SET((unsigned)dummySocketNum, &fExceptionSet);<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    if (err != EINTR) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">#else<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    if (errno != EINTR && errno != EAGAIN) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">#endif<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">        // Unexpected error - treat this as fatal:<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">#if !defined(_WIN32_WCE)<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">        perror("BasicTaskScheduler::SingleStep(): select() fails");<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">#endif<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">        abort();<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><o:p><FONT face="Calibri"> </FONT></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  // Call the handler function for one readable socket:<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  HandlerIterator iter(*fHandlers);<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  HandlerDescriptor* handler;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  // To ensure forward progress through the handlers, begin past the last<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  // socket number that we handled:<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  if (fLastHandledSocketNum >= 0) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    while ((handler = iter.next()) != NULL) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      if (handler->socketNum == fLastHandledSocketNum) break;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    if (handler == NULL) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      fLastHandledSocketNum = -1;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      iter.reset(); // start from the beginning instead<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  while ((handler = iter.next()) != NULL) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    int sock = handler->socketNum; // alias<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    int resultConditionSet = 0;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    if (FD_ISSET(sock, &readSet) && FD_ISSET(sock, &fReadSet)/*sanity check*/) resultConditionSet |= SOCKET_READABLE;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    if (FD_ISSET(sock, &writeSet) && FD_ISSET(sock, &fWriteSet)/*sanity check*/) resultConditionSet |= SOCKET_WRITABLE;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    if (FD_ISSET(sock, &exceptionSet) && FD_ISSET(sock, &fExceptionSet)/*sanity check*/) resultConditionSet |= SOCKET_EXCEPTION;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    if ((resultConditionSet&handler->conditionSet) != 0 && handler->handlerProc != NULL) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      fLastHandledSocketNum = sock;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">          // Note: we set "fLastHandledSocketNum" before calling the handler,<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">          // in case the handler calls "doEventLoop()" reentrantly.<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      (*handler->handlerProc)(handler->clientData, resultConditionSet);<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      break;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  if (handler == NULL && fLastHandledSocketNum >= 0) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    // We didn't call a handler, but we didn't get to check all of them,<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    // so try again from the beginning:<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    iter.reset();<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    while ((handler = iter.next()) != NULL) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      int sock = handler->socketNum; // alias<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      int resultConditionSet = 0;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      if (FD_ISSET(sock, &readSet) && FD_ISSET(sock, &fReadSet)/*sanity check*/) resultConditionSet |= SOCKET_READABLE;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      if (FD_ISSET(sock, &writeSet) && FD_ISSET(sock, &fWriteSet)/*sanity check*/) resultConditionSet |= SOCKET_WRITABLE;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      if (FD_ISSET(sock, &exceptionSet) && FD_ISSET(sock, &fExceptionSet)/*sanity check*/) resultConditionSet |= SOCKET_EXCEPTION;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      if ((resultConditionSet&handler->conditionSet) != 0 && handler->handlerProc != NULL) {<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">        fLastHandledSocketNum = sock;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">            // Note: we set "fLastHandledSocketNum" before calling the handler,<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">            // in case the handler calls "doEventLoop()" reentrantly.<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">        (*handler->handlerProc)(handler->clientData, resultConditionSet);<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">        break;<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">      }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">    if (handler == NULL) fLastHandledSocketNum = -1;//because we didn't call a handler<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  }<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><o:p><FONT face="Calibri"> </FONT></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  // Also handle any delayed event that may have come due.  (Note that we do this *after* calling a socket<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  // handler, in case the delayed event handler modifies the set of readable sockets.)<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">  fDelayQueue.handleAlarm();<o:p></o:p></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN style="COLOR: #1f497d" lang="EN-US"><FONT face="Calibri">}<o:p></o:p></FONT></SPAN></P></DIV></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>