summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-12-22 22:17:59 +0100
committerVolker Lendecke <vl@samba.org>2008-12-29 13:24:28 +0100
commitafd70855b77aee4500b7d505419c750b6b2df38b (patch)
tree8f605060de32106335ee6637250aa11ebf5ed84b /source3/lib
parent82a152fcf9254fe4189cac12fa3fc1744284ca13 (diff)
downloadsamba-afd70855b77aee4500b7d505419c750b6b2df38b.tar.gz
samba-afd70855b77aee4500b7d505419c750b6b2df38b.tar.bz2
samba-afd70855b77aee4500b7d505419c750b6b2df38b.zip
Make write_data use write_data_iov
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_sock.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index a362938fd3..d23758ad6a 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -707,37 +707,37 @@ ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt)
Write data to a fd.
****************************************************************************/
+/****************************************************************************
+ Write data to a fd.
+****************************************************************************/
+
ssize_t write_data(int fd, const char *buffer, size_t N)
{
- size_t total=0;
ssize_t ret;
- char addr[INET6_ADDRSTRLEN];
+ struct iovec iov;
- while (total < N) {
- ret = sys_write(fd,buffer + total,N - total);
+ iov.iov_base = CONST_DISCARD(char *, buffer);
+ iov.iov_len = N;
- if (ret == -1) {
- if (fd == get_client_fd()) {
- /* 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;
- }
-
- if (ret == 0) {
- return total;
- }
+ ret = write_data_iov(fd, &iov, 1);
+ if (ret >= 0) {
+ return ret;
+ }
- total += ret;
+ if (fd == get_client_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 (ssize_t)total;
+
+ return -1;
}
/****************************************************************************