From 04a7eaa170eb327d0ff5c8edf9e4842084e413d8 Mon Sep 17 00:00:00 2001 From: Asanka Herath Date: Thu, 3 Jun 2010 00:55:44 -0400 Subject: [PATCH] Call ioctlsocket() indirectly We were calling ioctlsocket() through a macro. However, due to type safety issues, we have to call it indirectly through rk_SOCK_IOCTL(). --- lib/roken/roken.h.in | 3 ++- lib/roken/socket.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/roken/roken.h.in b/lib/roken/roken.h.in index e36b25f45..219b08775 100644 --- a/lib/roken/roken.h.in +++ b/lib/roken/roken.h.in @@ -68,7 +68,8 @@ typedef SOCKET rk_socket_t; #define rk_IS_BAD_SOCKET(s) ((s) == INVALID_SOCKET) #define rk_IS_SOCKET_ERROR(rv) ((rv) == SOCKET_ERROR) #define rk_SOCK_ERRNO WSAGetLastError() -#define rk_SOCK_IOCTL(s,c,a) ioctlsocket((s),(c),(a)) + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_SOCK_IOCTL(SOCKET s, long cmd, int * argp); #define ETIMEDOUT WSAETIMEDOUT #define EWOULDBLOCK WSAEWOULDBLOCK diff --git a/lib/roken/socket.c b/lib/roken/socket.c index bd800ac5a..ef594ffd0 100644 --- a/lib/roken/socket.c +++ b/lib/roken/socket.c @@ -316,6 +316,19 @@ socket_to_fd(rk_socket_t sock, int flags) #endif } +#ifdef HAVE_WINSOCK +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_SOCK_IOCTL(SOCKET s, long cmd, int * argp) { + u_long ul = (argp)? *argp : 0; + int rv; + + rv = ioctlsocket(s, cmd, &ul); + if (argp) + *argp = (int) ul; + return rv; +} +#endif + #ifndef HEIMDAL_SMALLER #undef socket