Menu

can't leave mutex sometime...

Help
wakan
2007-01-27
2012-11-20
  • wakan

    wakan - 2007-01-27

    Hi,
    I'm using commoncpp library in a project that includes a multithread
    server that
    can accept many tcp connection and each connection generates a thread.
    In this server I'm using a thirdy party proprietary library (compiled),
    that (as the producer says)
    can't work in multithread environment.
    As each connection thread needs to call functions of this thirdy party
    library, I've used a mutex to protect the piece of
    code where this external library function is called.
    In this way I can use this library fine, because all calls are
    serialized and the protected function is called by one thread each time.
    This is an example:
    ...
        while(1) {
            if(isPending(pendingInput)) {
                    mutex.enterMutex();
                    ---> protected function call (a function that can't work
    in multithread env) <---      
                    mutex.leaveMutex();
           }
        }
    ...
    in 99% of cases it works fine. But it accidentally happens that a thread
    can't exit from the mutex
    maybe because the thirdy party function freezes itself.
    When this happens, the server can accept other connections, soit still
    works, but each thread can't enter in the mutex proteced piece of code.
    I'm thinking about something, like a timeout, that exits the mutex after
    a time, if the thread is not exiting...
    Can someone help me to resolve this problem? Are there other solutions?
    Thanks in advance,
    Regards
    Carlo

     
    • Buck

      Buck - 2007-01-30

      first of all, this project is dead;
      the project admin has absorbed this
      project, including forum and bug-
      tracking components, as well as re-
      leases of updated software, into the
      overall gnutelephony project. see

      http://sourceforge.net/projects/gnutelephony

      as for your question, you may want to
      try using a Conditional:

      http://data.gnutelephony.org/docs/framework/a00376.html

       
      • wakan

        wakan - 2007-01-30

        Sorry if I continue to reply here even if this forum is closed,
        but I'm doing that just to finish this discussion...
        About your reply, can you make me an example of Conditional
        to resolve my problem?
        Thanks in advance,
        carlo

         

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.