mirror of
https://github.com/samba-team/samba.git
synced 2025-01-27 14:04:05 +03:00
Cope with rw errors and timeout to peer.
Jeremy.
This commit is contained in:
parent
ef7bcaf1b7
commit
736a7bab48
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user