diff options
author | Jeremy Allison <jra@samba.org> | 2002-10-01 06:50:38 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-10-01 06:50:38 +0000 |
commit | 8147df0b6b4674670e70b45c603e8323e5c61c33 (patch) | |
tree | 1829641fa33ccb9eda1a3fd96f1bdf77b6658ac4 /source3/libsmb | |
parent | 88e481ec13505f7e870a2172db3d4edf5ce47caf (diff) | |
download | samba-8147df0b6b4674670e70b45c603e8323e5c61c33.tar.gz samba-8147df0b6b4674670e70b45c603e8323e5c61c33.tar.bz2 samba-8147df0b6b4674670e70b45c603e8323e5c61c33.zip |
Cope with rw errors and timeout to peer.
Jeremy.
(This used to be commit d8d351eb01ea7c84828dbc96224d7b13d643b558)
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/clientgen.c | 5 | ||||
-rw-r--r-- | source3/libsmb/clierror.c | 30 |
2 files changed, 28 insertions, 7 deletions
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 4a102097ce..2236d8508d 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -100,7 +100,7 @@ BOOL cli_receive_smb(struct cli_state *cli) /* If the server is not responding, note that now */ if (!ret) { - cli->smb_read_error = smb_read_error; + cli->smb_rw_error = smb_read_error; close(cli->fd); cli->fd = -1; } @@ -131,6 +131,7 @@ BOOL cli_send_smb(struct cli_state *cli) if (ret <= 0) { close(cli->fd); cli->fd = -1; + cli->smb_rw_error = WRITE_ERROR; DEBUG(0,("Error writing %d bytes to client. %d (%s)\n", (int)len,(int)ret, strerror(errno) )); return False; @@ -295,7 +296,7 @@ void cli_close_connection(struct cli_state *cli) if (cli->fd != -1) close(cli->fd); cli->fd = -1; - cli->smb_read_error = 0; + cli->smb_rw_error = 0; } /**************************************************************************** diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index fb88b66786..f5281eb047 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -85,11 +85,31 @@ char *cli_errstr(struct cli_state *cli) return cli_error_message; } - /* Was it server timeout ? */ - if (cli->fd == -1 && cli->timeout > 0 && cli->smb_read_error == READ_TIMEOUT) { - slprintf(cli_error_message, sizeof(cli_error_message) - 1, - "Call timed out: server did not respond after %d milliseconds", - cli->timeout); + /* Was it server socket error ? */ + if (cli->fd == -1 && cli->smb_rw_error) { + switch(cli->smb_rw_error) { + case READ_TIMEOUT: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Call timed out: server did not respond after %d milliseconds", + cli->timeout); + break; + case READ_EOF: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Call returned zero bytes (EOF)\n" ); + break; + case READ_ERROR: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Read error: %s\n", strerror(errno) ); + break; + case WRITE_ERROR: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Write error: %s\n", strerror(errno) ); + break; + default: + slprintf(cli_error_message, sizeof(cli_error_message) - 1, + "Unknown error code %d\n", cli->smb_rw_error ); + break; + } return cli_error_message; } |