[SCM] Socket Wrapper Repository - branch master updated
Andreas Schneider
asn at samba.org
Wed Oct 1 06:08:34 MDT 2014
The branch, master has been updated
via 163f089 Bump version to 1.1.2.
via b6e69a3 swrap: Add support for eventfd with unsigned count variable.
via 362136b swrap: Add a trace message for swrap_socket().
via 0456896 swrap: Implement fcntl() to catch F_DUPFD.
via 7dad23a swrap: Include the function name in the debug output.
from 20555bf tests: Add missing breaks in sockaddr assert functions.
http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 163f08939567d5f837343ca6844c7121d6fe954e
Author: Andreas Schneider <asn at samba.org>
Date: Wed Oct 1 12:56:21 2014 +0200
Bump version to 1.1.2.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit b6e69a39dd211626159865f1ece4989c7552a9ee
Author: Andreas Schneider <asn at samba.org>
Date: Wed Oct 1 12:51:56 2014 +0200
swrap: Add support for eventfd with unsigned count variable.
The prototype in glibc 2.20.90 changed.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 362136b89adedbf112beb354e31b0e9b763db37f
Author: Andreas Schneider <asn at samba.org>
Date: Wed Oct 1 12:48:13 2014 +0200
swrap: Add a trace message for swrap_socket().
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 045689644b87a3f6a3f4c2baeb70d22d3f6c441c
Author: Andreas Schneider <asn at samba.org>
Date: Thu Sep 11 10:17:06 2014 +0200
swrap: Implement fcntl() to catch F_DUPFD.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 7dad23ab56c707a0c5e3780436259781375be0e0
Author: Andreas Schneider <asn at samba.org>
Date: Thu Sep 11 08:30:04 2014 +0200
swrap: Include the function name in the debug output.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
-----------------------------------------------------------------------
Summary of changes:
CMakeLists.txt | 4 +-
ChangeLog | 4 ++
ConfigureChecks.cmake | 8 +++
config.h.cmake | 1 +
src/socket_wrapper.c | 120 ++++++++++++++++++++++++++++++++++++++++++++-----
5 files changed, 123 insertions(+), 14 deletions(-)
Changeset truncated at 500 lines:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 49e47a4..4c57a62 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
set(APPLICATION_VERSION_MAJOR "1")
set(APPLICATION_VERSION_MINOR "1")
-set(APPLICATION_VERSION_PATCH "1")
+set(APPLICATION_VERSION_PATCH "2")
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
# Increment AGE. Set REVISION to 0
# If the source code was changed, but there were no interface changes:
# Increment REVISION.
-set(LIBRARY_VERSION "0.1.1")
+set(LIBRARY_VERSION "0.1.2")
set(LIBRARY_SOVERSION "0")
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
diff --git a/ChangeLog b/ChangeLog
index e5eabfc..052abb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
ChangeLog
==========
+version 1.1.2 (released 2014-10-01)
+ * Added support for fnctl(F_DUPFD).
+ * Added support for glibc 2.20.90.
+
version 1.1.1 (released 2014-06-05)
* Disable incomplete address in use check in bind().
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index fb73449..ea0a208 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -119,6 +119,14 @@ check_prototype_definition(ioctl
"unistd.h;sys/ioctl.h"
HAVE_IOCTL_INT)
+if (HAVE_EVENTFD)
+ check_prototype_definition(eventfd
+ "int eventfd(unsigned int count, int flags)"
+ "-1"
+ "sys/eventfd.h"
+ HAVE_EVENTFD_UNSIGNED_INT)
+endif (HAVE_EVENTFD)
+
# IPV6
check_c_source_compiles("
#include <stdlib.h>
diff --git a/config.h.cmake b/config.h.cmake
index 466b951..8b66420 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -42,6 +42,7 @@
#cmakedefine HAVE_ACCEPT_PSOCKLEN_T 1
#cmakedefine HAVE_IOCTL_INT 1
+#cmakedefine HAVE_EVENTFD_UNSIGNED_INT 1
/*************************** LIBRARIES ***************************/
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 061a820..d5c343d 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -272,10 +272,12 @@ void swrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
# define SWRAP_LOG(...)
#else
-static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...) PRINTF_ATTRIBUTE(2, 3);
-# define SWRAP_LOG(dbglvl, ...) swrap_log((dbglvl), __VA_ARGS__)
+static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *func, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
+# define SWRAP_LOG(dbglvl, ...) swrap_log((dbglvl), __func__, __VA_ARGS__)
-static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...)
+static void swrap_log(enum swrap_dbglvl_e dbglvl,
+ const char *func,
+ const char *format, ...)
{
char buffer[1024];
va_list va;
@@ -295,23 +297,23 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...)
switch (dbglvl) {
case SWRAP_LOG_ERROR:
fprintf(stderr,
- "SWRAP_ERROR(%d): %s\n",
- (int)getpid(), buffer);
+ "SWRAP_ERROR(%d) - %s: %s\n",
+ (int)getpid(), func, buffer);
break;
case SWRAP_LOG_WARN:
fprintf(stderr,
- "SWRAP_WARN(%d): %s\n",
- (int)getpid(), buffer);
+ "SWRAP_WARN(%d) - %s: %s\n",
+ (int)getpid(), func, buffer);
break;
case SWRAP_LOG_DEBUG:
fprintf(stderr,
- "SWRAP_DEBUG(%d): %s\n",
- (int)getpid(), buffer);
+ "SWRAP_DEBUG(%d) - %s: %s\n",
+ (int)getpid(), func, buffer);
break;
case SWRAP_LOG_TRACE:
fprintf(stderr,
- "SWRAP_TRACE(%d): %s\n",
- (int)getpid(), buffer);
+ "SWRAP_TRACE(%d) - %s: %s\n",
+ (int)getpid(), func, buffer);
break;
}
}
@@ -337,6 +339,7 @@ struct swrap_libc_fns {
socklen_t addrlen);
int (*libc_dup)(int fd);
int (*libc_dup2)(int oldfd, int newfd);
+ int (*libc_fcntl)(int fd, int cmd, ...);
FILE *(*libc_fopen)(const char *name, const char *mode);
#ifdef HAVE_EVENTFD
int (*libc_eventfd)(int count, int flags);
@@ -589,6 +592,28 @@ static int libc_eventfd(int count, int flags)
}
#endif
+static int libc_vfcntl(int fd, int cmd, va_list ap)
+{
+ long int args[4];
+ int rc;
+ int i;
+
+ swrap_load_lib_function(SWRAP_LIBC, fcntl);
+
+ for (i = 0; i < 4; i++) {
+ args[i] = va_arg(ap, long int);
+ }
+
+ rc = swrap.fns.libc_fcntl(fd,
+ cmd,
+ args[0],
+ args[1],
+ args[2],
+ args[3]);
+
+ return rc;
+}
+
static int libc_getpeername(int sockfd,
struct sockaddr *addr,
socklen_t *addrlen)
@@ -2405,6 +2430,11 @@ static int swrap_socket(int family, int type, int protocol)
SWRAP_DLIST_ADD(si->fds, fi);
SWRAP_DLIST_ADD(sockets, si);
+ SWRAP_LOG(SWRAP_LOG_TRACE,
+ "Created %s socket for protocol %s",
+ si->family == AF_INET ? "IPv4" : "IPv6",
+ si->type == SOCK_DGRAM ? "UDP" : "TCP");
+
return fd;
}
@@ -4916,7 +4946,69 @@ int dup2(int fd, int newfd)
}
/****************************
- * DUP2
+ * FCNTL
+ ***************************/
+
+static int swrap_vfcntl(int fd, int cmd, va_list va)
+{
+ struct socket_info_fd *fi;
+ struct socket_info *si;
+ int rc;
+
+ si = find_socket_info(fd);
+ if (si == NULL) {
+ rc = libc_vfcntl(fd, cmd, va);
+
+ return rc;
+ }
+
+ switch (cmd) {
+ case F_DUPFD:
+ fi = (struct socket_info_fd *)calloc(1, sizeof(struct socket_info_fd));
+ if (fi == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ fi->fd = libc_vfcntl(fd, cmd, va);
+ if (fi->fd == -1) {
+ int saved_errno = errno;
+ free(fi);
+ errno = saved_errno;
+ return -1;
+ }
+
+ /* Make sure we don't have an entry for the fd */
+ swrap_remove_stale(fi->fd);
+
+ SWRAP_DLIST_ADD(si->fds, fi);
+
+ rc = fi->fd;
+ break;
+ default:
+ rc = libc_vfcntl(fd, cmd, va);
+ break;
+ }
+
+ return rc;
+}
+
+int fcntl(int fd, int cmd, ...)
+{
+ va_list va;
+ int rc;
+
+ va_start(va, cmd);
+
+ rc = swrap_vfcntl(fd, cmd, va);
+
+ va_end(va);
+
+ return rc;
+}
+
+/****************************
+ * EVENTFD
***************************/
#ifdef HAVE_EVENTFD
@@ -4932,7 +5024,11 @@ static int swrap_eventfd(int count, int flags)
return fd;
}
+#ifdef HAVE_EVENTFD_UNSIGNED_INT
+int eventfd(unsigned int count, int flags)
+#else
int eventfd(int count, int flags)
+#endif
{
return swrap_eventfd(count, flags);
}
--
Socket Wrapper Repository
More information about the samba-cvs
mailing list