Go Back   ZeroC Forums > Patches

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 02-21-2003
marlowa 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.
Reply With Quote
  #2 (permalink)  
Old 02-21-2003
rodrigc 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
Reply With Quote
  #3 (permalink)  
Old 02-21-2003
rodrigc 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
Reply With Quote
  #4 (permalink)  
Old 02-22-2003
marlowa marlowa is offline
Registered User
 
 
Join Date: Feb 2003
Location: London
Posts: 64
Quote:
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.
Reply With Quote
  #5 (permalink)  
Old 02-22-2003
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,772
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.
Reply With Quote
  #6 (permalink)  
Old 02-23-2003
marlowa marlowa is offline
Registered User
 
 
Join Date: Feb 2003
Location: London
Posts: 64
Quote:
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.
Reply With Quote
  #7 (permalink)  
Old 02-23-2003
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,772
Quote:
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
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Doc: return value of RecMutex::tryLock() n2503v Comments 1 12-18-2006 03:45 AM
Reliability, Footprint & Portability prakashbuddhira Help Center 1 04-03-2006 05:36 AM
some problems with dll simpley Help Center 1 01-21-2005 03:18 AM
Hello example problems jpm Help Center 1 06-02-2003 03:26 PM
Portability problems with iceccp marlowa Bug Reports 0 02-21-2003 08:54 AM


All times are GMT -4. The time now is 07:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.