Cannot share RPC handles between threads

Peter S. Mazinger ps.m at
Wed May 3 19:56:01 UTC 2006

On Wed, 3 May 2006, Claus Klein wrote:

> Hi,
> I have a multi-threaded application which makes use of remote
> procedure calls (RPC). The application creates an RPC client
> handle (via clnt_create) which is afterwards used in different
> threads (with appropriate locking of course) to make RPC calls.
> This doesn't work if the application is linked against uClibc.
> The reason is that there is a subtle difference in the implementation
> of the RPC client handle data structure between glibc and uClibc.
> The CLIENT structure contains a pointer to an authenticator field of
> type AUTH which is allocated in "libc/inet/rpc/auth_none.c".
> uClibc implements this by using thread-specific data.
> Thus it is only valid in *one* thread (the thread which allocated
> the CLIENT structure). RPC calls in other threads fail.
> This is different in glibc which allocates the structure within the
> global address space which is shared by all threads. Thus the same
> CLIENT handle can be used in different threads to make RPC calls.
> Is there a reason for the different implementation in uClibc?
> Can it be changed? In my opinion it would be nice to have the same
> behaviour in glibc and uClibc.
> Thanks

Your patch won't work if UCLIBC_HAS_THREADS is not defined (__libc_once 
Could you also provide a test case that could be added to uClibc?

I wonder, while you were there, why haven't you synced all of the file to 
the glibc version (especially if it would result in a size win)?

Thanks, Peter

Peter S. Mazinger <ps dot m at gmx dot net>           ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08  BB6E C389 975E A5F0 59F2

More information about the uClibc mailing list