summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/client.h2
-rw-r--r--source3/include/smb.h2
-rw-r--r--source3/libsmb/clientgen.c5
-rw-r--r--source3/libsmb/clierror.c30
4 files changed, 31 insertions, 8 deletions
diff --git a/source3/include/client.h b/source3/include/client.h
index 7a8889edc5..17fd150065 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -70,7 +70,7 @@ typedef struct smb_sign_info {
struct cli_state {
int port;
int fd;
- int smb_read_error; /* Copy of last read error. */
+ int smb_rw_error; /* Copy of last read or write error. */
uint16 cnum;
uint16 pid;
uint16 mid;
diff --git a/source3/include/smb.h b/source3/include/smb.h
index c39ebed950..f58e3adf54 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -161,6 +161,8 @@ typedef uint16 smb_ucs2_t;
typedef smb_ucs2_t wpstring[PSTRING_LEN];
typedef smb_ucs2_t wfstring[FSTRING_LEN];
+/* This error code can go into the client smb_rw_error. */
+#define WRITE_ERROR 4
#ifdef WORDS_BIGENDIAN
#define UCS2_SHIFT 8
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;
}