libsmbclient multiple processes ... very confused.

Akshay V Rao avrao at
Tue Jun 17 18:38:54 GMT 2003

Description of what is to happen:
My program forks into N child forked processes.  Each child forked process 
calls smbc_init and smbc_opendir and then proceeds to a while loop in 
which it issues the following calls in order: smbc_readdir, smbc_open, 
smbc_read, smbc_close.  After the while loop, it then issues a call to 
smbc_closedir.  The N processes are all executing simultaneously, and 
reading data from a common share.  It is at this point where the locking 
occurs. If I only set it to fork one process (N = 1), there is no locking 
problem.  Otherwise, the locking problem exists.  Below is a tcpdump of 2 
processes attacking a share. is where the program is being run. is the share that is being read from.
Akshay Rao
IBM zSeries Linux Scalability Center Coop

Richard Sharpe <rsharpe at>
06/16/2003 06:57 PM

        To:     Akshay V Rao/Poughkeepsie/IBM at IBMUS
        cc:     <samba-technical at>
        Subject:        Re: libsmbclient multiple processes ... very confused.

On Mon, 16 Jun 2003, Akshay V Rao wrote:

> I first had a deadlock when reading files using multiple forked process 
> from a single smb share. I thought it was due to the fact that I called 
> smbc_init before i forked the processes, and used shared memory to 
> communicate common data.  I then proceeded to rectify this by issuing 
> smbc_init call after forking - in the individual foked processes, so 
> are in different address spaces.  I still however, run into a deadlock 
> problem. When running the program set to 1 process, it works fine.  When 

> running the program set to 2 processes, it freezes.  I was wondering if 
> anyone could help me.  I am using Samba 2.2.7a.  Does Samba 3.0 take 
> of this problem?


I think that we are going to need to see what is happening at the protocol 

level to figure this out. 

Can you grab a tcpdump capture or something like that of the packet 
activity that occurs, and send it to us along with what an outline of what 

you think each process should be doing.

In answer to your question, there should be no significant differences 
between the libsmbclient code in 2.2.7a, 2.2.8a and 3.0.0, especially with 

respect to what you are doing.

Richard Sharpe, rsharpe[at], rsharpe[at], 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: tcpdump.log
Type: application/octet-stream
Size: 11526 bytes
Desc: not available
Url :

More information about the samba-technical mailing list