What a smbc_new_context timeout does and is there a way to change it?

Scott Lovenberg scott.lovenberg at gmail.com
Wed Dec 16 08:19:33 UTC 2015


On Wed, Dec 16, 2015 at 1:53 AM, Andreas Schneider <asn at samba.org> wrote:
> On Tuesday 15 December 2015 11:05:41 Jeremy Allison wrote:
>> On Wed, Dec 09, 2015 at 03:08:52PM +0100, Vladimir Marek wrote:
>> > Hi,
>> >
>> > we have a customer who reports that sometimes his smbget processes fail
>> > with error message:
>> >
>> > Can't read 32768000 bytes at offset 7700480000, file smb://...
>> >
>> >
>> > I have traced it to a timeout in smbc_free_context in
>> > source3/libsmb/libsmb_context.c
>> >
>> >
>> > smbc_new_context(void)
>> > {
>> > ...
>> > smbc_setTimeout(context, 20000);
>> > ...
>> >
>> >
>> > This happens for samba 3.6, but I believe that the same code is used in
>> > samba 4.
>> >
>> >
>> > If I increase the timeout the problems with smbget go away.
>> >
>> > I would like to ask for help
>> >
>> > a) what is this timeout doing?
>> > I have suspicion that it's related to network operations and since
>> > customer is transferring huge amounts of data the network might be
>> > saturated.
>>
>> Yes, it times out the connection after that number of msec.
>>
>> > b) Is there a way to modify this timeout without touching the code, ie.
>> > from configuration file? I haven't been able to find a way - I believe
>> > it's set to be 20 seconds.
>>
>> No, you'll need to modify the code.
>>
>> > c) If we accept that the way to fix the problem is to increase the
>> > timeout, what would be the preferred way to do it? Just increase the
>> > number? Make it configurable? I don't know how difficult is to add
>> > configuration variable.
>>
>> I would add a command line parameter, say '-t timeout' (in seconds)
>> to smbget, then just pass that into smbc_setTimeout().
>>
>> Jeremy.
>
> I've started to rewrite several parts of smbget as it is broken in several
> ways. I could add that option. However patches are welcome.
>
>
>

Before I go code diving, since you guys seem to have this part of the
code swapped in to your brain, does this code interact with the
smbclient code at all?  If so, I think you're going to have some
potential interesting unintended consequences between the 3/4 code
bases as they have different smbclient time outs. IIRC, you might get
a socket pulled out from underneath you on a timeout if the client
socket times out before your upper layer timeout.  Just as a
word-to-the-wise if you see things you don't expect and this
intersects the client socket code at all.

If this doesn't intersect that code... I'm offering free hugs to
anyone that wants to unify the client timeouts.  I had a patch set
around somewhere for this, but it didn't incorporate this smbget
timeout, so it might as well be considered inadequate.  Free hugs.
Just sayin'.

-- 
Peace and Blessings,
-Scott.



More information about the samba-technical mailing list