[SCM] Socket Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Wed Oct 28 10:03:31 UTC 2015


The branch, master has been updated
       via  f24f91e tests: Add valgrind suppression file for dlopen() issues
       via  f649d0c swrap: Add a wrapper for write()
      from  21cb6c8 torture: Use a short torture socket dir

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f24f91eb2064ab04f7f289f73a443aafc45649e4
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 28 09:52:25 2015 +0100

    tests: Add valgrind suppression file for dlopen() issues
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit f649d0c5250867bf3d30d8f3059c3fbd75e17dd0
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 28 10:30:32 2015 +0100

    swrap: Add a wrapper for write()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 src/socket_wrapper.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/valgrind.supp  | 16 ++++++++++++++
 2 files changed, 76 insertions(+)
 create mode 100644 tests/valgrind.supp


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 3c0c279..b43c877 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -398,6 +398,7 @@ struct swrap_libc_fns {
 #ifdef HAVE_TIMERFD_CREATE
 	int (*libc_timerfd_create)(int clockid, int flags);
 #endif
+	ssize_t (*libc_write)(int fd, const void *buf, size_t count);
 	ssize_t (*libc_writev)(int fd, const struct iovec *iov, int iovcnt);
 };
 
@@ -837,6 +838,13 @@ static int libc_timerfd_create(int clockid, int flags)
 }
 #endif
 
+static ssize_t libc_write(int fd, const void *buf, size_t count)
+{
+	swrap_load_lib_function(SWRAP_LIBC, write);
+
+	return swrap.fns.libc_write(fd, buf, count);
+}
+
 static ssize_t libc_writev(int fd, const struct iovec *iov, int iovcnt)
 {
 	swrap_load_lib_function(SWRAP_LIBSOCKET, writev);
@@ -4544,6 +4552,58 @@ ssize_t read(int s, void *buf, size_t len)
 }
 
 /****************************************************************************
+ *   WRITE
+ ***************************************************************************/
+
+static ssize_t swrap_write(int s, const void *buf, size_t len)
+{
+	struct msghdr msg;
+	struct iovec tmp;
+	struct sockaddr_un un_addr;
+	ssize_t ret;
+	int rc;
+	struct socket_info *si;
+
+	si = find_socket_info(s);
+	if (si == NULL) {
+		return libc_write(s, buf, len);
+	}
+
+	tmp.iov_base = discard_const_p(char, buf);
+	tmp.iov_len = len;
+
+	ZERO_STRUCT(msg);
+	msg.msg_name = NULL;           /* optional address */
+	msg.msg_namelen = 0;           /* size of address */
+	msg.msg_iov = &tmp;            /* scatter/gather array */
+	msg.msg_iovlen = 1;            /* # elements in msg_iov */
+#if HAVE_STRUCT_MSGHDR_MSG_CONTROL
+	msg.msg_control = NULL;        /* ancillary data, see below */
+	msg.msg_controllen = 0;        /* ancillary data buffer len */
+	msg.msg_flags = 0;             /* flags on received message */
+#endif
+
+	rc = swrap_sendmsg_before(s, si, &msg, &tmp, &un_addr, NULL, NULL, NULL);
+	if (rc < 0) {
+		return -1;
+	}
+
+	buf = msg.msg_iov[0].iov_base;
+	len = msg.msg_iov[0].iov_len;
+
+	ret = libc_write(s, buf, len);
+
+	swrap_sendmsg_after(s, si, &msg, NULL, ret);
+
+	return ret;
+}
+
+ssize_t write(int s, const void *buf, size_t len)
+{
+	return swrap_write(s, buf, len);
+}
+
+/****************************************************************************
  *   SEND
  ***************************************************************************/
 
diff --git a/tests/valgrind.supp b/tests/valgrind.supp
new file mode 100644
index 0000000..9857825
--- /dev/null
+++ b/tests/valgrind.supp
@@ -0,0 +1,16 @@
+### GLIBC
+{
+   glibc_dlopen_alloc
+   Memcheck:Leak
+   fun:calloc
+   fun:_dlerror_run
+   fun:dlopen@@GLIBC_2.2.5
+}
+
+{
+   glibc_dlclose_alloc
+   Memcheck:Leak
+   fun:calloc
+   fun:_dlerror_run
+   fun:dlclose
+}


-- 
Socket Wrapper Repository



More information about the samba-cvs mailing list