Fixed in revision 1693 - SLP atomics now return the correct (new) value on
AIX.

 

John

 

From: John Calcote [mailto:john.calc...@gmail.com] 
Sent: Tuesday, October 30, 2012 12:14 PM
To: Jim Marshall
Cc: openslp-devel@lists.sourceforge.net
Subject: Re: [Openslp-devel] slptool hangs on AIX?

 

Hi Jim,

On Tue, Oct 30, 2012 at 10:54 AM, Jim Marshall
<jim.marsh...@wbemsolutions.com> wrote:

Hi,
 Been testing the AIX build I have and the agent is working fine but when I
invoke slptool it basically hangs. Stepping into the code we get to
libslp_handle.c line 66

if (SLPAtomicInc(&s_OpenSLPHandleCount) == 1)

The SLPAtomicInc function does this on AIX:

return (intptr_t)fetch_and_add((atomic_p)pn, 1);

This is the cause of the hang, because fetch_and_add "[...] returns the
original value of the variable" (from the man page), in this case '0'. When
this happens the code enters a while loop

 

 

Well, that's kind of useless, isn't it? It should be replaced with:

 

   return (intptr_t)fetch_and_add((atomic_p)pn, 1) + 1;

 

The idea here is to atomically increment the value stored at pn. If two
threads try to do it at once, then they could both read the value, increment
it and both write the same value back out. The use of atomic_add should
cause both threads to actually increment the value, regardless of how
in-sync they are on their attempts to update the value.

 

It's only a side-effect (that we take advantage of) that most atomic incs
return the newly updated value. Since the AIX version returns the original
value, and we're guaranteed to read/update/write atomically when we add 1 to
that original value, then we can assume that the value we get back PLUS ONE
is our actual desired return value.

 

I'll fix it.

 

John

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Openslp-devel mailing list
Openslp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openslp-devel

Reply via email to