[Live-devel] Bug in windows version of the BasicTaskScheduler.cpp

Victor V. Vinokurov victor at dialog.su
Tue Jul 28 04:14:37 PDT 2009


I use live555 lib under windows.
I write code to get MPEG file duration:

  TaskScheduler* scheduler = BasicTaskScheduler::createNew();
  BasicUsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
  MPEG1or2FileServerDemux* demux =
MPEG1or2FileServerDemux::createNew(*env, inputFileName, False);
  if(demux)
    return double(demux->fileDuration());

In ealier versions of live555 all works fine, but in newest version
process terminates abnormally on line
MPEG1or2FileServerDemux::createNew()

I check source code and found bug in BasicTaskScheduler.cpp
In this file lines from line 73

#if defined(__WIN32__) || defined(_WIN32)
    int err = WSAGetLastError();
    // For some unknown reason, select() in Windoze sometimes fails with
WSAEINVAL if
    // it was called with no entries set in "readSet".  If this happens,
ignore it:
    if (err == WSAEINVAL && readSet.fd_count == 0) {
      err = 0;  // BUG at this line
      // To stop this from happening again, create a dummy readable socket:
      int dummySocketNum = socket(AF_INET, SOCK_DGRAM, 0);
      FD_SET((unsigned)dummySocketNum, &fReadSet);
    }
    if (err != EINTR) {
#else

must look like this

#if defined(__WIN32__) || defined(_WIN32)
    int err = WSAGetLastError();
    // For some unknown reason, select() in Windoze sometimes fails with
WSAEINVAL if
    // it was called with no entries set in "readSet".  If this happens,
ignore it:
    if (err == WSAEINVAL && readSet.fd_count == 0) {
      err = EINTR; // err SHOULD be EINTR for the further comparision
      // To stop this from happening again, create a dummy readable socket:
      int dummySocketNum = socket(AF_INET, SOCK_DGRAM, 0);
      FD_SET((unsigned)dummySocketNum, &fReadSet);
    }
    if (err != EINTR) {
#else

Is this right?

-- 
See you!
---
Vityusha V. Vinokurov - programmer
mailto:victor at dialog.su
http://www.dialog.su


More information about the live-devel mailing list