summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-08-15 16:02:37 +0200
committerVolker Lendecke <vl@samba.org>2010-08-17 12:46:53 +0200
commit40ae8b74b669ced9dee0c33e15bc5e0ac8680506 (patch)
tree13e43f3cf45082ab80d972db7b1ccaea48f53da5
parentf40ef7e24cda2d25dcb04cb7e83cd1f3d62a66e4 (diff)
downloadsamba-40ae8b74b669ced9dee0c33e15bc5e0ac8680506.tar.gz
samba-40ae8b74b669ced9dee0c33e15bc5e0ac8680506.tar.bz2
samba-40ae8b74b669ced9dee0c33e15bc5e0ac8680506.zip
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.
-rw-r--r--source3/lib/util_sock.c21
-rw-r--r--source3/smbd/process.c23
-rw-r--r--source3/smbd/reply.c59
3 files changed, 78 insertions, 25 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index bf04af10bd..bb14c5d885 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -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);
}
/****************************************************************************
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 7430e35e7c..c44d86a6b8 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -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;
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 97451e629c..a2b6b33af5 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -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)));