From fe106d38b279b61b0d88498285ebe7c76ebf0394 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Fri, 25 Jul 2008 09:33:14 +0000 Subject: [PATCH] remove socketpair compat. git-svn-id: file:///svn/unbound/trunk@1167 be551aaa-1e26-0410-a405-d3ace91eadb9 --- compat/socketpair.c | 34 ------------- config.h.in | 6 --- configure | 113 ++++---------------------------------------- configure.ac | 4 -- doc/Changelog | 2 + 5 files changed, 10 insertions(+), 149 deletions(-) delete mode 100644 compat/socketpair.c diff --git a/compat/socketpair.c b/compat/socketpair.c deleted file mode 100644 index 337cd3e32..000000000 --- a/compat/socketpair.c +++ /dev/null @@ -1,34 +0,0 @@ -/* socketpair.c - windows mingw32 replacement for socketpair. - * creates a pipe that works like a socketpair a bit - * Taken from libevent-1.4.3.stable WIN32-Code/misc.c - * License: BSD. - */ -#include "config.h" -#include -#include - -int -socketpair(int d, int type, int protocol, int *sv) -{ - static int count; - char buf[64]; - HANDLE fd; - DWORD dwMode; - (void)d; (void)type; (void)protocol; - sprintf(buf, "\\\\.\\pipe\\levent-%d", count++); - /* Create a duplex pipe which will behave like a socket pair */ - fd = CreateNamedPipe(buf, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_NOWAIT, - PIPE_UNLIMITED_INSTANCES, 4096, 4096, 0, NULL); - if (fd == INVALID_HANDLE_VALUE) - return (-1); - sv[0] = (int)fd; - - fd = CreateFile(buf, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (fd == INVALID_HANDLE_VALUE) - return (-1); - dwMode = PIPE_NOWAIT; - SetNamedPipeHandleState(fd, &dwMode, NULL, NULL); - sv[1] = (int)fd; - - return (0); -} diff --git a/config.h.in b/config.h.in index 4b801b101..268ce1917 100644 --- a/config.h.in +++ b/config.h.in @@ -148,9 +148,6 @@ /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF -/* Define to 1 if you have the `socketpair' function. */ -#undef HAVE_SOCKETPAIR - /* Using Solaris threads */ #undef HAVE_SOLARIS_THREADS @@ -552,9 +549,6 @@ struct sockaddr_storage; #ifndef HAVE_SRANDOM #define srandom(x) srand(x) /* on win32, for tests only (bad random) */ #endif /* HAVE_SRANDOM */ -#ifndef HAVE_SOCKETPAIR -int socketpair(int d, int type, int protocol, int *sv); -#endif /* detect if we need to cast to unsigned int for FD_SET to avoid warnings */ #ifdef HAVE_WINSOCK2_H diff --git a/configure b/configure index b777bbd73..e1f1971bb 100755 --- a/configure +++ b/configure @@ -24000,11 +24000,13 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include /* for off_t */ + #include int main () { -return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0); +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } @@ -24044,11 +24046,13 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #define _LARGEFILE_SOURCE 1 -#include +#include /* for off_t */ + #include int main () { -return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0); +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } @@ -25598,107 +25602,6 @@ done -for ac_func in socketpair -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval echo '${'$as_ac_var'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -else - case " $LIBOBJS " in - *" $ac_func.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" - ;; -esac - -fi -done - - # check this after all other compilation checks, since the linking of the lib # may break checks after this. diff --git a/configure.ac b/configure.ac index 99b82936e..6fd28978e 100644 --- a/configure.ac +++ b/configure.ac @@ -823,7 +823,6 @@ AC_REPLACE_FUNCS(snprintf) AC_REPLACE_FUNCS(strlcpy) AC_REPLACE_FUNCS(memmove) AC_REPLACE_FUNCS(gmtime_r) -AC_REPLACE_FUNCS(socketpair) dnl for mingw32 # check this after all other compilation checks, since the linking of the lib # may break checks after this. @@ -1024,9 +1023,6 @@ struct sockaddr_storage; #ifndef HAVE_SRANDOM #define srandom(x) srand(x) /* on win32, for tests only (bad random) */ #endif /* HAVE_SRANDOM */ -#ifndef HAVE_SOCKETPAIR -int socketpair(int d, int type, int protocol, int *sv); -#endif /* detect if we need to cast to unsigned int for FD_SET to avoid warnings */ #ifdef HAVE_WINSOCK2_H diff --git a/doc/Changelog b/doc/Changelog index 57176714b..711a64c9a 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -2,6 +2,8 @@ - added original copyright statement of OpenBSD arc4random code. - created tube signaling solution on windows, as a pipe replacement. this makes background asynchronous resolution work on windows. + - removed very insecure socketpair compat code. It also did not + work with event_waiting. Solved by pipe replacement. 22 July 2008: Wouter - moved pipe actions to util/tube.c. easier porting and shared code.