Using threads (pthreads) in a VFS module on Linux

Richard Sharpe realrichardsharpe at gmail.com
Sun Sep 30 22:19:46 MDT 2012


On Sat, Sep 29, 2012 at 12:31 PM, Volker Lendecke
<Volker.Lendecke at sernet.de> wrote:
> On Sat, Sep 29, 2012 at 01:45:45PM -0700, Richard Sharpe wrote:
>> At Samba XP during my presentation on the Samba VFS someone asked me
>> about whether or not you can really use threads in a VFS Module.
>>
>> At that time I blithely answered yes. While the answer is true, in my
>> experience, at least for Linux, it is a little more complicated than
>> that.
>>
>> If you use AIO, you should be aware that it uses signals. If you do
>> not disable the signals that Samba uses in your threads you risk nasty
>> things happening. For example, IO completions can silently disappear
>> if you have multiple outstanding AIO requests at any one time, which
>> after all, is the raison d'être of AIO. Windows does not like it when
>> it does not get a response for some IOs for a long period of time and
>> simply resets the connection.
>>
>> The solution is to use pthread_sigmask and friends to switch off all
>> signals, or at least the ones Samba wants, before starting your
>> threads.
>
> Please be aware that neither aio_fork nor aio_pthread (now
> the default) use signals. The Posix API is now done in the
> aio_posix module. Please also be aware that our internal
> messaging system uses SIGUSR1, but this use might possibly
> go away relatively soon (not for 4.0 though).

Heh. Thanks. I did not think to look for aio modules :-( Both aio_fork
and aio_pthread are available as modules in 3.6.x while aio_fork is
available as a module in 3.5.x by the look of things.

So, you will still probably want to switch off signals like SIGUSR1.
In our case we were using the default AIO support.

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)


More information about the samba-technical mailing list