[Live-devel] RTSPClient blocking/non-blocking bug?

Jeremy Noring jnoring at logitech.com
Thu Jan 14 17:58:40 PST 2010


I was reviewing the code in RTSPClient::openConnectionFromUrl(), and I had a
question about the codepath involving setting a timeout.  In particular,
this code:

//Start change for timeout on connect

      /*
      if (connect(fInputSocketNum, (struct sockaddr*)&remoteName, sizeof
remoteName)
      != 0) {
      envir().setResultErrMsg("
connect() failed: ");
      break;
      */
      fd_set set;
      FD_ZERO(&set);
      timeval tvout = {0,0};
      if (timeout > 0) {
          FD_SET((unsigned)fInputSocketNum, &set);
          tvout.tv_sec = timeout;
          tvout.tv_usec = 0;
          makeSocketNonBlocking(fInputSocketNum);
      }
      if (connect(fInputSocketNum, (struct sockaddr*) &remoteName, sizeof
remoteName) != 0)
      {
          if (envir().getErrno() != EINPROGRESS && envir().getErrno() !=
EWOULDBLOCK)
          {
              envir().setResultErrMsg("connect() failed: ");
              break;
          }
          if (timeout > 0 && (select(fInputSocketNum + 1, NULL, &set, NULL,
&tvout) <= 0))
          {
              envir().setResultErrMsg("select/connect() failed: ");
              break;
          }
          /*
          errno = 0;
          if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &len) < 0 || errno
!= 0 )
          {
          break;
          }
          */
          //End change for timeout on connect
      }

...I see that if timeout > 0, then fInputSocketNum is set to a non-blocking
socket (i.e. makeSocketNonBlocking).  Shouldn't this get set back to a
blocking socket once this connect attempt is completed?

(it may be that this happens somewhere else, but my quick checks through the
code didn't reveal any such code)

If this is an issue, I have code I can submit that will set the socket back
to blocking.

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20100114/1d2aa61e/attachment.html>


More information about the live-devel mailing list