From 40665edf5e6043ad5a8f46731a79ec1d5835b62a Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sun, 3 Sep 2006 00:50:34 +0000 Subject: r18011: Should fix bug 3835. Jeremy: requires your eyes... If the remote connection timed out while cli_list() was retrieving its list of files, the error was not returned to the user, e.g. via smbc_opendir(), so the user didn't have a way to know to set the timeout longer and try again. This problem would occur when a very large directory is being read with a too-small timeout on the cli. Jeremy, although there were a couple of areas that needed to be handled, I needed to make one change that you should bless, in libsmb/clientgen.c. It was setting cli->smb_rw_error = smb_read_error; but smb_read_error is zero, so this had no effect. I'm now doing cli->smb_rw_error = READ_TIMEOUT; instead, and according to the OP, these (cumulative) changes (in a slightly different form) solve the problem. Please confirm this smb_rw_error change will have no other adverse effects that you can see. Derrell (This used to be commit fa664b24b829f973156486896575c1007b6d7b01) --- source3/libsmb/libsmbclient.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/libsmbclient.c') diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index c74e18b13c..101cc02211 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -2540,6 +2540,7 @@ static SMBCFILE * smbc_opendir_ctx(SMBCCTX *context, const char *fname) { + int saved_errno; fstring server, share, user, password, options; pstring workgroup; pstring path; @@ -2547,6 +2548,7 @@ smbc_opendir_ctx(SMBCCTX *context, char *p; SMBCSRV *srv = NULL; SMBCFILE *dir = NULL; + struct _smbc_callbacks *cb; struct in_addr rem_ip; if (!context || !context->internal || @@ -2908,9 +2910,9 @@ smbc_opendir_ctx(SMBCCTX *context, SAFE_FREE(dir->fname); SAFE_FREE(dir); } - errno = smbc_errno(context, targetcli); + saved_errno = smbc_errno(context, targetcli); - if (errno == EINVAL) { + if (saved_errno == EINVAL) { /* * See if they asked to opendir something * other than a directory. If so, the @@ -2926,12 +2928,34 @@ smbc_opendir_ctx(SMBCCTX *context, ! IS_DOS_DIR(mode)) { /* It is. Correct the error value */ - errno = ENOTDIR; + saved_errno = ENOTDIR; } } - return NULL; + /* + * If there was an error and the server is no + * good any more... + */ + cb = &context->callbacks; + if (cli_is_error(targetcli) && + cb->check_server_fn(context, srv)) { + + /* ... then remove it. */ + if (cb->remove_unused_server_fn(context, + srv)) { + /* + * We could not remove the server + * completely, remove it from the + * cache so we will not get it + * again. It will be removed when the + * last file/dir is closed. + */ + cb->remove_cached_srv_fn(context, srv); + } + } + errno = saved_errno; + return NULL; } } -- cgit