Menu

SocketService BUG found + fixed (hopefully)

2002-01-04
2004-02-27
  • Nick Liebmann

    Nick Liebmann - 2002-01-04

    Using CommonC++ 1.9.3:
    OS Linux 2.4.3 (mandrake)

    After closing all connections on a SocketService I was unable to connect again. Further investigation showed that the the code was waiting in SocketService::Attach, trying to 'EnterMutex()', but the Mutex is locked elswhere.

    The problem turned out to be that even when no ports are connected the SocketService still calls the system function poll(), which never seems to return.

    This only shows up after a connection has been made and severed, because before that the SocketService thread is not started.

    I am not sure what it is supposed to be polling...it is not clear to me what the iosync member is suppoised to be doing.

    Anyway the solution seems to be to *NOT* call poll, if count == 0. This does mean though that the code sits in a loop until a new connection is made. Maybe a ccxx_yield() call should also be included.

    :::::::
    port.cpp:448
    if(count)
    {
        poll( mfd.getList(), count + 1, timer );
        LeaveMutex();
    }
    else
    {
        LeaveMutex();
        ccxx_yield();
    }

    Obviously if there is a reason to poll the iosync, then this code misses that.

     
    • Frediano Ziglio

      Frediano Ziglio - 2002-01-06

      Well, fixed.
      You must always call poll. There is always a fd to wait. Note that ccxx_yield solution waste many processor time. iosync is used to tell to thread to add or delete a socket from wait list.

       
      • Daniel Fielder

        Daniel Fielder - 2004-02-27

        So what was the final resolution to this?  It is unclear from freddy77's response what "well, fixed" means.  I am having what sounds like the issue nickl described in his post, but I do not see the exact code he referenced in port.cpp so I'm assuming the SocketPort::attach function has been changed since the referenced version.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.