proposal: libsmbclient functionality addition

Tom Jansen tom at ninja.nl
Mon Jun 17 14:51:03 GMT 2002


Hi,

At the moment, libsmbclient caches connections, which is great. There is one
problem with that however: if a server closes the connection (idle timeout for
example) there is no way to get a connection to that server/share combination
again. Ok, there is one way: restart your application that uses libsmbclient.
IMHO, this is not an option.

To solve this problem I want to propose a little change to libsmbclient.c.
There are two ways to do this: automatically or manually. I'm proposing both.

add a few functions:
int smbc_remove_cached_server(char *srv, char *share, char* user, char* pass)
int smbc_auto_reconnect(int tries)

The first function would just remove a server from the cache if it's unused.
This function can be used by the automagic part as weel as the manual mechanism.
The second function would enable/disable automatic reconnects upon failures (and
set the number of times tried). These retries would only take place in functions
calling smbc_server() directly.

The most important part is detecting these disconnects and acting nice upon
occurance. I think there are two ways:
o A callback mechanism to give disconnect messages to the user (libsmbclient.c
and user-written code).
o A simple check in smbc_server(): send keepalive packet and check cli->fd for
errors (in all the clientcode I've seen, the fd is set to -1 on error).

I prefer the last for increased simplicity. Maybe the samba gurus disagree but
that's why I'm posting this here.

Is there any interest in such code? I'm quite happy to code it up and contribute
it because I use libsmbclient a lot (as well as samba-server btw (200+ samba
servers on our network here:-).

Yours sincerely,
    Tom Jansen

--
Tom Jansen -- tom at ninja.nl
Ninja ISD  -- www.ninja.nl




More information about the samba-technical mailing list