1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

s3: Remove smbd_server_fd() from write_data()

This completely removes the DEBUG(0, ..) error message from write_data(). I've
gone through all callers of write_data() and made sure that they have their own
equivalent error message printing.
This commit is contained in:
Volker Lendecke 2010-08-15 16:02:37 +02:00
parent f40ef7e24c
commit 40ae8b74b6
3 changed files with 78 additions and 25 deletions

View File

@ -660,26 +660,7 @@ ssize_t write_data(int fd, const char *buffer, size_t N)
iov.iov_base = CONST_DISCARD(void *, buffer);
iov.iov_len = N;
ret = write_data_iov(fd, &iov, 1);
if (ret >= 0) {
return ret;
}
if (fd == smbd_server_fd()) {
char addr[INET6_ADDRSTRLEN];
/*
* Try and give an error message saying what client failed.
*/
DEBUG(0, ("write_data: write failure in writing to client %s. "
"Error %s\n", get_peer_addr(fd,addr,sizeof(addr)),
strerror(errno)));
} else {
DEBUG(0,("write_data: write failure. Error = %s\n",
strerror(errno) ));
}
return -1;
return write_data_iov(fd, &iov, 1);
}
/****************************************************************************

View File

@ -132,8 +132,17 @@ bool srv_send_smb(int fd, char *buffer,
ret = write_data(fd,buf_out+nwritten,len - nwritten);
if (ret <= 0) {
DEBUG(0,("pid[%d] Error writing %d bytes to client. %d. (%s)\n",
(int)sys_getpid(), (int)len,(int)ret, strerror(errno) ));
char addr[INET6_ADDRSTRLEN];
/*
* Try and give an error message saying what
* client failed.
*/
DEBUG(0,("pid[%d] Error writing %d bytes to client %s. %d. (%s)\n",
(int)sys_getpid(), (int)len,
get_peer_addr(fd, addr, sizeof(addr)),
(int)ret, strerror(errno) ));
srv_free_enc_buffer(buf_out);
goto out;
}
@ -2416,7 +2425,15 @@ static bool keepalive_fn(const struct timeval *now, void *private_data)
smbd_unlock_socket(smbd_server_conn);
if (!ret) {
DEBUG( 2, ( "Keepalive failed - exiting.\n" ) );
char addr[INET6_ADDRSTRLEN];
/*
* Try and give an error message saying what
* client failed.
*/
DEBUG(0, ("send_keepalive failed for client %s. "
"Error %s - exiting\n",
get_peer_addr(sconn->sock, addr, sizeof(addr)),
strerror(errno)));
return False;
}
return True;

View File

@ -2812,6 +2812,16 @@ static ssize_t fake_sendfile(files_struct *fsp, SMB_OFF_T startpos,
if (write_data(fsp->conn->sconn->sock, buf, cur_read)
!= cur_read) {
char addr[INET6_ADDRSTRLEN];
/*
* Try and give an error message saying what
* client failed.
*/
DEBUG(0, ("write_data failed for client %s. "
"Error %s\n",
get_peer_addr(fsp->conn->sconn->sock, addr,
sizeof(addr)),
strerror(errno)));
SAFE_FREE(buf);
return -1;
}
@ -2874,8 +2884,19 @@ static void sendfile_short_send(files_struct *fsp,
to_write = MIN(SHORT_SEND_BUFSIZE, smb_maxcnt - nread);
if (write_data(fsp->conn->sconn->sock, buf, to_write)
!= to_write) {
char addr[INET6_ADDRSTRLEN];
/*
* Try and give an error message saying what
* client failed.
*/
DEBUG(0, ("write_data failed for client %s. "
"Error %s\n",
get_peer_addr(
fsp->conn->sconn->sock, addr,
sizeof(addr)),
strerror(errno)));
exit_server_cleanly("sendfile_short_send: "
"write_data failed");
"write_data failed");
}
nread += to_write;
}
@ -2896,6 +2917,16 @@ static void reply_readbraw_error(struct smbd_server_connection *sconn)
smbd_lock_socket(sconn);
if (write_data(sconn->sock,header,4) != 4) {
char addr[INET6_ADDRSTRLEN];
/*
* Try and give an error message saying what
* client failed.
*/
DEBUG(0, ("write_data failed for client %s. "
"Error %s\n",
get_peer_addr(sconn->sock, addr, sizeof(addr)),
strerror(errno)));
fail_readraw();
}
smbd_unlock_socket(sconn);
@ -3013,8 +3044,20 @@ normal_readbraw:
}
_smb_setlen(outbuf,ret);
if (write_data(sconn->sock, outbuf, 4+ret) != 4+ret)
if (write_data(sconn->sock, outbuf, 4+ret) != 4+ret) {
char addr[INET6_ADDRSTRLEN];
/*
* Try and give an error message saying what
* client failed.
*/
DEBUG(0, ("write_data failed for client %s. "
"Error %s\n",
get_peer_addr(fsp->conn->sconn->sock, addr,
sizeof(addr)),
strerror(errno)));
fail_readraw();
}
TALLOC_FREE(outbuf);
}
@ -3558,6 +3601,18 @@ normal_read:
/* Send out the header. */
if (write_data(req->sconn->sock, (char *)headerbuf,
sizeof(headerbuf)) != sizeof(headerbuf)) {
char addr[INET6_ADDRSTRLEN];
/*
* Try and give an error message saying what
* client failed.
*/
DEBUG(0, ("write_data failed for client %s. "
"Error %s\n",
get_peer_addr(req->sconn->sock, addr,
sizeof(addr)),
strerror(errno)));
DEBUG(0,("send_file_readX: write_data failed for file "
"%s (%s). Terminating\n", fsp_str_dbg(fsp),
strerror(errno)));