Results 1 to 7 of 7

Thread: portability problems with RecMutex ctor

  1. #1
    marlowa is offline Registered User
    Join Date
    Feb 2003
    Location
    London
    Posts
    64

    portability problems with RecMutex ctor

    The RecMutex ctor has a non-std way of initialising the mutex attributes. It uses PTHREAD_MUTEX_RECURSIVE_NP instead of PTHREAD_MUTEX_RECURSIVE. This stops it compiling on Solaris. There is also a more std way to initalise the mutex attributes. The fixed code is:

    IceUtil::RecMutex::RecMutex() :
    _count(0)
    {
    pthread_mutexattr_t attr;
    int rc = pthread_mutexattr_init(&attr);
    if(rc != 0)
    {
    throw ThreadSyscallException(__FILE__, __LINE__);
    }

    rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
    if(rc != 0)
    {
    throw ThreadSyscallException(__FILE__, __LINE__);
    }

    rc = pthread_mutex_init(&_mutex, &attr);
    if(rc != 0)
    {
    throw ThreadSyscallException(__FILE__, __LINE__);
    }
    }

    Regards,

    Andrew M.
    You are in a maze of twisty little passages, all different.

  2. #2
    rodrigc is offline Registered User
    Join Date
    Feb 2003
    Location
    Boston, MA, U.S.A.
    Posts
    27
    Indeed you are correct!!

    In fact, did you know that "_NP" in PTHREAD_MUTEX_RECURSIVE_NP
    stands for "Not Portable"!

    I'm going to try your patch on FreeBSD.

    Thanks!
    --
    Craig Rodrigues

  3. #3
    rodrigc is offline Registered User
    Join Date
    Feb 2003
    Location
    Boston, MA, U.S.A.
    Posts
    27
    Cool, it seems to work on FreeBSD.

    Thanks!!
    --
    Craig Rodrigues

  4. #4
    marlowa is offline Registered User
    Join Date
    Feb 2003
    Location
    London
    Posts
    64
    Originally posted by rodrigc
    Cool, it seems to work on FreeBSD.

    Thanks!!
    My pleasure.

    -Andrew
    You are in a maze of twisty little passages, all different.

  5. #5
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    I changed the code so that PTHREAD_MUTEX_RECUSRIVE_NP will only be used if __linux__ is defined. Otherwise PTHREAD_MUTEX_RECURSIVE is used.

    This fix will be in Ice-1.0.1.

  6. #6
    marlowa is offline Registered User
    Join Date
    Feb 2003
    Location
    London
    Posts
    64
    Originally posted by marc
    I changed the code so that PTHREAD_MUTEX_RECUSRIVE_NP will only be used if __linux__ is defined. Otherwise PTHREAD_MUTEX_RECURSIVE is used.

    This fix will be in Ice-1.0.1.
    Unfortunately more is required than just a change to the macro name. The initialisation fails to compile on Solaris when all that is changed is the macro name. I strongly recommend that the POSIX-compliant way be used as given in a previous post. Is there any reason why it can't?

    -Andrew
    You are in a maze of twisty little passages, all different.

  7. #7
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    Originally posted by marlowa
    Unfortunately more is required than just a change to the macro name. The initialisation fails to compile on Solaris when all that is changed is the macro name. I strongly recommend that the POSIX-compliant way be used as given in a previous post. Is there any reason why it can't?

    -Andrew
    No, there is no reason. I just modified the code as you suggested.

    Thanks,
    Marc

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. new exception wrong ctor called
    By loheron in forum Bug Reports
    Replies: 7
    Last Post: 10-02-2008, 01:04 PM
  2. Doc: return value of RecMutex::tryLock()
    By n2503v in forum Comments
    Replies: 1
    Last Post: 12-18-2006, 03:45 AM
  3. Reliability, Footprint & Portability
    By prakashbuddhira in forum Help Center
    Replies: 1
    Last Post: 04-03-2006, 05:36 AM
  4. Hello example problems
    By jpm in forum Help Center
    Replies: 1
    Last Post: 06-02-2003, 03:26 PM
  5. Portability problems with iceccp
    By marlowa in forum Bug Reports
    Replies: 0
    Last Post: 02-21-2003, 08:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •