summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/clientgen.c5
-rw-r--r--source3/libsmb/clierror.c30
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;
}