Deadlock with libsmbclient functions and Multiple forked processes

Akshay V Rao avrao at
Fri Jun 13 14:08:10 GMT 2003

Well, I tried doing this using threads in the first place but found out
that libsmbclient was not thread safe.  I then moved to forked processes,
therefore, it is in a different address space.  I am not sure that if I
open and close (and read) connections in each forked process, shouldn't
they be different because they exist in different address spaces - where as
threads exist in the same address space.

Thursday, June 12, 2003 8:13 PM
To: Akshay V Rao/Poughkeepsie/IBM at IBMUS
cc: samba-technical at
From: Andrew Bartlett <abartlet at>
Subject: Re: Deadlock with libsmbclient functions and Multiple forked

On Fri, 2003-06-13 at 06:08, Akshay V Rao wrote:
> I am currently developing a program that forks N Processes.  Each child
> forked process, executes a while loop in which the following function
> are issued in the following order: smbc_open(), smbc_read(),
> It appears that these functions are responsible for creating deadlocks
> there exist more than one child forked process (N > 1).  If I comment out
> the function calls and run the program with multiple processes, the
> deadlock is gone and the program runs normally.  If I then uncomment the
> function calls and run the program with only one process, the deadlock is
> gone as well.  I am running Samba version 2.2.7a on RedHat 7.3 kernel
> version 2.4.7-10smp, 512 Mb RAM, Dual PIII.  If anyone has any ideas,
> would definitly be greatly appreciated.

If you are doing this on one connection to the remote server, I'm not
surprised.  The libsmbclient code will still share the connection after
initialization, and you are reading/writing from a common socket!

Don't do that.  We are not thread-safe either.

Andrew Bartlett

Andrew Bartlett                                 abartlet at
Manager, Authentication Subsystems, Samba Team  abartlet at
Student Network Administrator, Hawker College   abartlet at
 (Attachments removed)

More information about the samba-technical mailing list