]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorAndreas Gustafsson <source@isc.org>
Mon, 22 Oct 2001 23:28:26 +0000 (23:28 +0000)
committerAndreas Gustafsson <source@isc.org>
Mon, 22 Oct 2001 23:28:26 +0000 (23:28 +0000)
1068.   [bug]           errno could be overwritten by catgets(). [RT #1921]
1066.   [bug]           Provide a thread safe wrapper for strerror().
                        [RT #1689]
(Also some changes to configure.in, config.h.in, and acconfig.h that were
necessary to allow config.h.in to be correctly regenerated with the
HAVE_STRERROR definition needed by 1066.)

16 files changed:
CHANGES
acconfig.h
bin/named/unix/os.c
config.h.in
configure.in
lib/isc/Makefile.in
lib/isc/pthreads/condition.c
lib/isc/unix/Makefile.in
lib/isc/unix/app.c
lib/isc/unix/entropy.c
lib/isc/unix/ifiter_ioctl.c
lib/isc/unix/interfaceiter.c
lib/isc/unix/net.c
lib/isc/unix/socket.c
lib/isc/unix/strerror.c
lib/isc/unix/time.c

diff --git a/CHANGES b/CHANGES
index bb5fb7bb4dacaac4584a7792670a398e08daf1c8..8a5247ffe5f29b6bc060ec95f548318d32bbed01 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+1068.  [bug]           errno could be overwritten by catgets(). [RT #1921]
+
+1066.  [bug]           Provide a thread safe wrapper for strerror().
+                       [RT #1689]
+
 1064.  [bug]           Do not shut down active network interfaces if we
                        are unable to scan the interface list. [RT #1921]
 
index cd3877bc0fddfa20f8ef27d952ae0dd594831824..f1df4cda48adb63b272a613e88354ecb4602661e 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: acconfig.h,v 1.35 2001/07/14 01:55:04 gson Exp $ */
+/* $Id: acconfig.h,v 1.35.2.1 2001/10/22 23:28:07 gson Exp $ */
 
 /***
  *** This file is not to be included by any public header files, because
@@ -23,6 +23,9 @@
  ***/
 @TOP@
 
+/* define to `int' if <sys/types.h> doesn't define.  */
+#undef ssize_t
+
 /* define on DEC OSF to enable 4.4BSD style sa_len support */
 #undef _SOCKADDR_LEN
 
@@ -44,6 +47,9 @@
 /* define if sysconf() is available */
 #undef HAVE_SYSCONF
 
+/* define if sysctlbyname() is available */
+#undef HAVE_SYSCTLBYNAME
+
 /* define if catgets() is available */
 #undef HAVE_CATGETS
 
@@ -120,3 +126,6 @@ int sigwait(const unsigned int *set, int *sig);
 
 /* define if pthread_attr_getstacksize() is available */
 #undef HAVE_PTHREAD_ATTR_GETSTACKSIZE
+
+/* define if you have strerror in the C library. */
+#undef HAVE_STRERROR
index da1874f5e26b79637dee1cef9cbf96cdf1231cf2..ab7652fe6c9f6a221068c01ccfe1125658b59a0b 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: os.c,v 1.46 2001/08/29 18:03:36 gson Exp $ */
+/* $Id: os.c,v 1.46.2.1 2001/10/22 23:28:12 gson Exp $ */
 
 #include <config.h>
 #include <stdarg.h>
@@ -36,6 +36,7 @@
 #include <isc/file.h>
 #include <isc/print.h>
 #include <isc/result.h>
+#include <isc/strerror.h>
 #include <isc/string.h>
 
 #include <named/main.h>
@@ -133,6 +134,7 @@ static void
 linux_setcaps(unsigned int caps) {
        struct __user_cap_header_struct caphead;
        struct __user_cap_data_struct cap;
+       char strbuf[ISC_STRERRORSIZE];
 
        if ((getuid() != 0 && !non_root_caps) || non_root)
                return;
@@ -144,8 +146,10 @@ linux_setcaps(unsigned int caps) {
        cap.effective = caps;
        cap.permitted = caps;
        cap.inheritable = caps;
-       if (syscall(SYS_capset, &caphead, &cap) < 0)
-               ns_main_earlyfatal("capset failed: %s", strerror(errno));
+       if (syscall(SYS_capset, &caphead, &cap) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               ns_main_earlyfatal("capset failed: %s", strbuf);
+       }
 }
 
 static void
@@ -233,15 +237,17 @@ linux_minprivs(void) {
 #ifdef HAVE_SYS_PRCTL_H
 static void
 linux_keepcaps(void) {
+       char strbuf[ISC_STRERRORSIZE];
        /*
         * Ask the kernel to allow us to keep our capabilities after we
         * setuid().
         */
 
        if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) {
-               if (errno != EINVAL)
-                       ns_main_earlyfatal("prctl() failed: %s",
-                                          strerror(errno));
+               if (errno != EINVAL) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       ns_main_earlyfatal("prctl() failed: %s", strbuf);
+               }
        } else {
                non_root_caps = ISC_TRUE;
                if (getuid() != 0)
@@ -280,10 +286,13 @@ void
 ns_os_daemonize(void) {
        pid_t pid;
        int fd;
+       char strbuf[ISC_STRERRORSIZE];
 
        pid = fork();
-       if (pid == -1)
-               ns_main_earlyfatal("fork(): %s", strerror(errno));
+       if (pid == -1) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               ns_main_earlyfatal("fork(): %s", strbuf);
+       }
        if (pid != 0)
                _exit(0);
 
@@ -295,8 +304,10 @@ ns_os_daemonize(void) {
        mainpid = getpid();
 #endif
 
-        if (setsid() == -1)
-               ns_main_earlyfatal("setsid(): %s", strerror(errno));
+        if (setsid() == -1) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               ns_main_earlyfatal("setsid(): %s", strbuf);
+       }
 
        /*
         * Try to set stdin, stdout, and stderr to /dev/null, but press
@@ -337,16 +348,22 @@ all_digits(const char *s) {
 
 void
 ns_os_chroot(const char *root) {
+       char strbuf[ISC_STRERRORSIZE];
        if (root != NULL) {
-               if (chroot(root) < 0)
-                       ns_main_earlyfatal("chroot(): %s", strerror(errno));
-               if (chdir("/") < 0)
-                       ns_main_earlyfatal("chdir(/): %s", strerror(errno));
+               if (chroot(root) < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       ns_main_earlyfatal("chroot(): %s", strbuf);
+               }
+               if (chdir("/") < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       ns_main_earlyfatal("chdir(/): %s", strbuf);
+               }
        }
 }
 
 void
 ns_os_inituserinfo(const char *username) {
+       char strbuf[ISC_STRERRORSIZE];
        if (username == NULL)
                return;
 
@@ -360,14 +377,17 @@ ns_os_inituserinfo(const char *username) {
                ns_main_earlyfatal("user '%s' unknown", username);
 
        if (getuid() == 0) {
-               if (initgroups(runas_pw->pw_name, runas_pw->pw_gid) < 0)
-                       ns_main_earlyfatal("initgroups(): %s", strerror(errno));
+               if (initgroups(runas_pw->pw_name, runas_pw->pw_gid) < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       ns_main_earlyfatal("initgroups(): %s", strbuf);
+               }
        }
 
 }
 
 void
 ns_os_changeuser(void) {
+       char strbuf[ISC_STRERRORSIZE];
        if (runas_pw == NULL || done_setuid)
                return;
 
@@ -382,11 +402,15 @@ ns_os_changeuser(void) {
                   "2.3.99-pre3 or 2.2.18 when using threads");
 #endif
 
-       if (setgid(runas_pw->pw_gid) < 0)
-               ns_main_earlyfatal("setgid(): %s", strerror(errno));
+       if (setgid(runas_pw->pw_gid) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               ns_main_earlyfatal("setgid(): %s", strbuf);
+       }
 
-       if (setuid(runas_pw->pw_uid) < 0)
-               ns_main_earlyfatal("setuid(): %s", strerror(errno));
+       if (setuid(runas_pw->pw_uid) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               ns_main_earlyfatal("setuid(): %s", strbuf);
+       }
 
 #if defined(HAVE_LINUX_CAPABILITY_H) && !defined(HAVE_LINUXTHREADS)
        linux_minprivs();
@@ -447,6 +471,7 @@ ns_os_writepidfile(const char *filename) {
        FILE *lockfile;
        size_t len;
        pid_t pid;
+       char strbuf[ISC_STRERRORSIZE];
 
        /*
         * The caller must ensure any required synchronization.
@@ -456,20 +481,26 @@ ns_os_writepidfile(const char *filename) {
 
        len = strlen(filename);
        pidfile = malloc(len + 1);
-       if (pidfile == NULL)
+       if (pidfile == NULL) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                 ns_main_earlyfatal("couldn't malloc '%s': %s",
-                                  filename, strerror(errno));
+                                  filename, strbuf);
+       }
        /* This is safe. */
        strcpy(pidfile, filename);
 
         fd = safe_open(filename, ISC_FALSE);
-        if (fd < 0)
+        if (fd < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                 ns_main_earlyfatal("couldn't open pid file '%s': %s",
-                                  filename, strerror(errno));
+                                  filename, strbuf);
+       }
         lockfile = fdopen(fd, "w");
-        if (lockfile == NULL)
+        if (lockfile == NULL) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                ns_main_earlyfatal("could not fdopen() pid file '%s': %s",
-                                  filename, strerror(errno));
+                                  filename, strbuf);
+       }
 #ifdef HAVE_LINUXTHREADS
        pid = mainpid;
 #else
index ef1ea35db14fb89a976e2f1d018b6cfc5b60358b..98cc14ade5a0b5329c08272545057bb7fecac852 100644 (file)
@@ -16,7 +16,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: config.h.in,v 1.47 2001/08/16 06:19:56 marka Exp $ */
+/* $Id: config.h.in,v 1.47.2.1 2001/10/22 23:28:08 gson Exp $ */
 
 /***
  *** This file is not to be included by any public header files, because
@@ -32,9 +32,6 @@
 /* Define to `unsigned' if <sys/types.h> doesn't define.  */
 #undef size_t
 
-/* Define to `int' if <sys/types.h> doesn't define.  */
-#undef ssize_t
-
 /* Define if you have the ANSI C header files.  */
 #undef STDC_HEADERS
 
@@ -45,6 +42,9 @@
    byte first (like Motorola and SPARC, unlike Intel and VAX).  */
 #undef WORDS_BIGENDIAN
 
+/* define to `int' if <sys/types.h> doesn't define.  */
+#undef ssize_t
+
 /* define on DEC OSF to enable 4.4BSD style sa_len support */
 #undef _SOCKADDR_LEN
 
@@ -138,6 +138,9 @@ int sigwait(const unsigned int *set, int *sig);
 /* define if pthread_attr_getstacksize() is available */
 #undef HAVE_PTHREAD_ATTR_GETSTACKSIZE
 
+/* define if you have strerror in the C library. */
+#undef HAVE_STRERROR
+
 /* Define if you have the <dlfcn.h> header file.  */
 #undef HAVE_DLFCN_H
 
@@ -153,12 +156,12 @@ int sigwait(const unsigned int *set, int *sig);
 /* Define if you have the <sys/select.h> header file.  */
 #undef HAVE_SYS_SELECT_H
 
-/* Define if you have the <sys/sysctl.h> header file.  */
-#undef HAVE_SYS_SYSCTL_H
-
 /* Define if you have the <sys/sockio.h> header file.  */
 #undef HAVE_SYS_SOCKIO_H
 
+/* Define if you have the <sys/sysctl.h> header file.  */
+#undef HAVE_SYS_SYSCTL_H
+
 /* Define if you have the <sys/time.h> header file.  */
 #undef HAVE_SYS_TIME_H
 
index 272865ff8c84cba3f96798d0d7a2c10097c56ecd..00ec4acd2a1091b8e6436dcbc2b0a8d50fdc8a46 100644 (file)
@@ -18,7 +18,7 @@ AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
 esyscmd([sed "s/^/# /" COPYRIGHT])dnl
 AC_DIVERT_POP()dnl
 
-AC_REVISION($Revision: 1.294.2.2 $)
+AC_REVISION($Revision: 1.294.2.3 $)
 
 AC_INIT(lib/dns/name.c)
 AC_PREREQ(2.13)
@@ -198,7 +198,7 @@ AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h sys/sockio.h sys/select.h sys/sysct
 
 AC_C_CONST
 AC_C_INLINE
-AC_CHECK_FUNC(sysctlbyname, AC_DEFINE(HAVE_SYSCTLBYNAME),)
+AC_CHECK_FUNC(sysctlbyname, AC_DEFINE(HAVE_SYSCTLBYNAME))
 
 #
 # UnixWare 7.1.1 with the feature supplement to the UDK compiler
@@ -1223,8 +1223,7 @@ AC_TRY_COMPILE([
 #include <netdb.h>],
 [struct rrsetinfo r; return (0);],
        [AC_MSG_RESULT(yes)
-       ISC_LWRES_NEEDRRSETINFO="#undef ISC_LWRES_NEEDRRSETINFO"
-       AC_DEFINE(HAVE_RRSETINFO)],
+       ISC_LWRES_NEEDRRSETINFO="#undef ISC_LWRES_NEEDRRSETINFO"],
        [AC_MSG_RESULT(no)
        ISC_LWRES_NEEDRRSETINFO="#define ISC_LWRES_NEEDRRSETINFO 1"])
 AC_SUBST(ISC_LWRES_NEEDRRSETINFO)
@@ -1345,6 +1344,7 @@ AC_CHECK_FUNC(vsnprintf,
         ISC_PLATFORM_NEEDVSNPRINTF="#define ISC_PLATFORM_NEEDVSNPRINTF 1"])
 AC_SUBST(ISC_PLATFORM_NEEDSTRSEP)
 AC_SUBST(ISC_PLATFORM_NEEDVSNPRINTF)
+AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR))
 
 AC_SUBST(ISC_EXTRA_OBJS)
 AC_SUBST(ISC_EXTRA_SRCS)
index 65b0735255e50583f09808cd68d5b211623184f3..40a2ee6ebb90b432b839802e001588416f99b82b 100644 (file)
@@ -13,7 +13,7 @@
 # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: Makefile.in,v 1.71 2001/03/02 19:25:15 bwelling Exp $
+# $Id: Makefile.in,v 1.71.2.1 2001/10/22 23:28:13 gson Exp $
 
 srcdir =       @srcdir@
 VPATH =                @srcdir@
@@ -36,7 +36,7 @@ UNIXOBJS =    @ISC_ISCIPV6_O@ \
                unix/errno2result.@O@ unix/file.@O@ unix/fsaccess.@O@ \
                unix/interfaceiter.@O@ unix/keyboard.@O@ unix/net.@O@ \
                unix/os.@O@ unix/resource.@O@ unix/socket.@O@ unix/stdio.@O@ \
-               unix/stdtime.@O@ unix/syslog.@O@ unix/time.@O@
+               unix/stdtime.@O@ unix/strerror.@O@ unix/syslog.@O@ unix/time.@O@
 
 
 NLSOBJS =      nls/msgcat.@O@
index fb3bdffe68a93e8f900310e3d11f58d351952e56..49b92ac5d3a74f68ec20928d26be70933c1032d9 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: condition.c,v 1.30 2001/01/23 02:27:19 bwelling Exp $ */
+/* $Id: condition.c,v 1.30.2.1 2001/10/22 23:28:14 gson Exp $ */
 
 #include <config.h>
 
@@ -23,6 +23,7 @@
 
 #include <isc/condition.h>
 #include <isc/msgs.h>
+#include <isc/strerror.h>
 #include <isc/string.h>
 #include <isc/time.h>
 #include <isc/util.h>
@@ -32,6 +33,7 @@ isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t *t) {
        int presult;
        isc_result_t result;
        struct timespec ts;
+       char strbuf[ISC_STRERRORSIZE];
 
        REQUIRE(c != NULL && m != NULL && t != NULL);
 
@@ -60,10 +62,11 @@ isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t *t) {
                        return (ISC_R_TIMEDOUT);
        } while (presult == EINTR);
 
+       isc__strerror(presult, strbuf, sizeof(strbuf));
        UNEXPECTED_ERROR(__FILE__, __LINE__,
                         "pthread_cond_timedwait() %s %s",
                         isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
                                        ISC_MSG_RETURNED, "returned"),
-                        strerror(presult));
+                        strbuf);
        return (ISC_R_UNEXPECTED);
 }
index 7dc2fb827be80954ac961903097cf03c41470fac..82928194ad3a9b063d17e4d5e49e2456bd95a1e9 100644 (file)
@@ -13,7 +13,7 @@
 # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: Makefile.in,v 1.35 2001/03/02 19:25:16 bwelling Exp $
+# $Id: Makefile.in,v 1.35.2.1 2001/10/22 23:28:16 gson Exp $
 
 srcdir =       @srcdir@
 VPATH =                @srcdir@
@@ -33,14 +33,14 @@ OBJS =              @ISC_IPV6_O@ \
                app.@O@ dir.@O@ entropy.@O@ errno2result.@O@ file.@O@ \
                fsaccess.@O@ interfaceiter.@O@ keyboard.@O@ net.@O@ \
                os.@O@ resource.@O@ socket.@O@ stdio.@O@ stdtime.@O@ \
-               syslog.@O@ time.@O@
+               strerror.@O@ syslog.@O@ time.@O@
 
 # Alphabetically
 SRCS =         @ISC_IPV6_C@ \
                app.c dir.c entropy.c errno2result.c file.c \
                fsaccess.c interfaceiter.c keyboard.c net.c \
                os.c resource.c socket.c stdio.c stdtime.c \
-               syslog.c time.c
+               strerror.c syslog.c time.c
 
 SUBDIRS =      include
 TARGETS =      ${OBJS}
index a9f7359bb13c53eb1c8c5968b4d913efb28c7fab..4eb7020a9bd27555eb18cfdcc27ebed1caa92eba 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: app.c,v 1.43 2001/07/09 21:05:57 gson Exp $ */
+/* $Id: app.c,v 1.43.2.1 2001/10/22 23:28:17 gson Exp $ */
 
 #include <config.h>
 
@@ -35,6 +35,7 @@
 #include <isc/mutex.h>
 #include <isc/event.h>
 #include <isc/platform.h>
+#include <isc/strerror.h>
 #include <isc/string.h>
 #include <isc/task.h>
 #include <isc/time.h>
@@ -97,17 +98,19 @@ reload_action(int arg) {
 static isc_result_t
 handle_signal(int sig, void (*handler)(int)) {
        struct sigaction sa;
+       char strbuf[ISC_STRERRORSIZE];
 
        memset(&sa, 0, sizeof sa);
        sa.sa_handler = handler;
 
        if (sigfillset(&sa.sa_mask) != 0 ||
            sigaction(sig, &sa, NULL) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
                                 isc_msgcat_get(isc_msgcat, ISC_MSGSET_APP,
                                               ISC_MSG_SIGNALSETUP,
                                               "handle_signal() %d setup: %s"),
-                                sig, strerror(errno));
+                                sig, strbuf);
                return (ISC_R_UNEXPECTED);
        }
 
@@ -119,6 +122,7 @@ isc_app_start(void) {
        isc_result_t result;
        int presult;
        sigset_t sset;
+       char strbuf[ISC_STRERRORSIZE];
 
        /*
         * Start an ISC library application.
@@ -130,9 +134,9 @@ isc_app_start(void) {
         */
        presult = pthread_init();
        if (presult != 0) {
+               isc__strerror(presult, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "isc_app_start() pthread_init: %s",
-                                strerror(presult));
+                                "isc_app_start() pthread_init: %s", strbuf);
                return (ISC_R_UNEXPECTED);
        }
 #endif
@@ -204,16 +208,17 @@ isc_app_start(void) {
            sigaddset(&sset, SIGHUP) != 0 ||
            sigaddset(&sset, SIGINT) != 0 ||
            sigaddset(&sset, SIGTERM) != 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "isc_app_start() sigsetops: %s",
-                                strerror(errno));
+                                "isc_app_start() sigsetops: %s", strbuf);
                return (ISC_R_UNEXPECTED);
        }
        presult = pthread_sigmask(SIG_BLOCK, &sset, NULL);
        if (presult != 0) {
+               isc__strerror(presult, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
                                 "isc_app_start() pthread_sigmask: %s",
-                                strerror(presult));
+                                strbuf);
                return (ISC_R_UNEXPECTED);
        }
 #else /* ISC_PLATFORM_USETHREADS */
@@ -228,16 +233,16 @@ isc_app_start(void) {
            sigaddset(&sset, SIGHUP) != 0 ||
            sigaddset(&sset, SIGINT) != 0 ||
            sigaddset(&sset, SIGTERM) != 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "isc_app_start() sigsetops: %s",
-                                strerror(errno));
+                                "isc_app_start() sigsetops: %s", strbuf);
                return (ISC_R_UNEXPECTED);
        }
        presult = sigprocmask(SIG_UNBLOCK, &sset, NULL);
        if (presult != 0) {
+               isc__strerror(presult, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "isc_app_start() sigprocmask: %s",
-                                strerror(presult));
+                                "isc_app_start() sigprocmask: %s", strbuf);
                return (ISC_R_UNEXPECTED);
        }
 #endif /* ISC_PLATFORM_USETHREADS */
@@ -405,6 +410,7 @@ isc_app_run(void) {
        isc_task_t *task;
 #ifdef ISC_PLATFORM_USETHREADS
        sigset_t sset;
+       char strbuf[ISC_STRERRORSIZE];
 #endif /* ISC_PLATFORM_USETHREADS */
 #ifdef HAVE_SIGWAIT
        int sig;
@@ -464,9 +470,9 @@ isc_app_run(void) {
                    sigaddset(&sset, SIGHUP) != 0 ||
                    sigaddset(&sset, SIGINT) != 0 ||
                    sigaddset(&sset, SIGTERM) != 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_app_run() sigsetops: %s",
-                                        strerror(errno));
+                                        "isc_app_run() sigsetops: %s", strbuf);
                        return (ISC_R_UNEXPECTED);
                }
 
@@ -496,9 +502,9 @@ isc_app_run(void) {
                 * Listen for all signals.
                 */
                if (sigemptyset(&sset) != 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_app_run() sigsetops: %s",
-                                        strerror(errno));
+                                        "isc_app_run() sigsetops: %s", strbuf);
                        return (ISC_R_UNEXPECTED);
                }
                result = sigsuspend(&sset);
@@ -532,6 +538,7 @@ isc_app_run(void) {
 isc_result_t
 isc_app_shutdown(void) {
        isc_boolean_t want_kill = ISC_TRUE;
+       char strbuf[ISC_STRERRORSIZE];
 
        LOCK(&lock);
 
@@ -550,16 +557,17 @@ isc_app_shutdown(void) {
 
                result = pthread_kill(main_thread, SIGTERM);
                if (result != 0) {
+                       isc__strerror(result, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                         "isc_app_shutdown() pthread_kill: %s",
-                                        strerror(result));
+                                        strbuf);
                        return (ISC_R_UNEXPECTED);
                }
 #else
                if (kill(getpid(), SIGTERM) < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_app_shutdown() kill: %s",
-                                        strerror(errno));
+                                        "isc_app_shutdown() kill: %s", strbuf);
                        return (ISC_R_UNEXPECTED);
                }
 #endif
@@ -571,6 +579,7 @@ isc_app_shutdown(void) {
 isc_result_t
 isc_app_reload(void) {
        isc_boolean_t want_kill = ISC_TRUE;
+       char strbuf[ISC_STRERRORSIZE];
 
        LOCK(&lock);
 
@@ -590,16 +599,17 @@ isc_app_reload(void) {
 
                result = pthread_kill(main_thread, SIGHUP);
                if (result != 0) {
+                       isc__strerror(result, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                         "isc_app_reload() pthread_kill: %s",
-                                        strerror(result));
+                                        strbuf);
                        return (ISC_R_UNEXPECTED);
                }
 #else
                if (kill(getpid(), SIGHUP) < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_app_reload() kill: %s",
-                                        strerror(errno));
+                                        "isc_app_reload() kill: %s", strbuf);
                        return (ISC_R_UNEXPECTED);
                }
 #endif
@@ -651,4 +661,3 @@ isc_app_unblock(void) {
        RUNTIME_CHECK(pthread_sigmask(SIG_BLOCK, &sset, NULL) == 0);
 #endif /* ISC_PLATFORM_USETHREADS */
 }
-
index c1c48b0bfe95656976e0d6f7990d0122422eb2d5..8c552f6f30196bf67b8eda10be40e000e9e35e7e 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: entropy.c,v 1.60 2001/07/18 01:31:13 gson Exp $ */
+/* $Id: entropy.c,v 1.60.2.1 2001/10/22 23:28:18 gson Exp $ */
 
 /*
  * This is the system depenedent part of the ISC entropy API.
@@ -29,6 +29,7 @@
 #include <unistd.h>
 
 #include <isc/platform.h>
+#include <isc/strerror.h>
 
 #ifdef ISC_PLATFORM_NEEDSYSSELECTH
 #include <sys/select.h>
@@ -267,15 +268,17 @@ static isc_result_t
 make_nonblock(int fd) {
        int ret;
        int flags;
+       char strbuf[ISC_STRERRORSIZE];
 
        flags = fcntl(fd, F_GETFL, 0);
        flags |= O_NONBLOCK;
        ret = fcntl(fd, F_SETFL, flags);
 
        if (ret == -1) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
                                 "fcntl(%d, F_SETFL, %d): %s",
-                                fd, flags, strerror(errno));
+                                fd, flags, strbuf);
 
                return (ISC_R_UNEXPECTED);
        }
index 33bfabca77d9605ad70c065e54905fa7ffd54206..2c8fddfb5df9006027b3099a6e52d75b136b34ef 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: ifiter_ioctl.c,v 1.19 2001/07/09 21:05:58 gson Exp $ */
+/* $Id: ifiter_ioctl.c,v 1.19.2.1 2001/10/22 23:28:19 gson Exp $ */
 
 /*
  * Obtain the list of network interfaces using the SIOCGLIFCONF ioctl.
@@ -73,6 +73,7 @@ isc_result_t
 isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
        isc_interfaceiter_t *iter;
        isc_result_t result;
+       char strbuf[ISC_STRERRORSIZE];
 
        REQUIRE(mctx != NULL);
        REQUIRE(iterp != NULL);
@@ -89,13 +90,14 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
         * Create an unbound datagram socket to do the SIOCGLIFADDR ioctl on.
         */
        if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
                                 isc_msgcat_get(isc_msgcat,
                                                ISC_MSGSET_IFITERIOCTL,
                                                ISC_MSG_MAKESCANSOCKET,
                                                "making interface "
                                                "scan socket: %s"),
-                                strerror(errno));
+                                strbuf);
                result = ISC_R_UNEXPECTED;
                goto socket_failure;
        }
@@ -130,13 +132,14 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
                if (ioctl(iter->socket, SIOCGLIFCONF, (char *)&iter->ifc)
                    == -1) {
                        if (errno != EINVAL) {
+                               isc__strerror(errno, strbuf, sizeof(strbuf));
                                UNEXPECTED_ERROR(__FILE__, __LINE__,
                                                 isc_msgcat_get(isc_msgcat,
                                                        ISC_MSGSET_IFITERIOCTL,
                                                        ISC_MSG_GETIFCONFIG,
                                                        "get interface "
                                                        "configuration: %s"),
-                                                strerror(errno));
+                                                strbuf);
                                result = ISC_R_UNEXPECTED;
                                goto ioctl_failure;
                        }
@@ -209,6 +212,7 @@ internal_current(isc_interfaceiter_t *iter) {
        struct lifreq *ifrp;
        struct lifreq lifreq;
        int family;
+       char strbuf[ISC_STRERRORSIZE];
 
        REQUIRE(VALID_IFITER(iter));
        REQUIRE (iter->pos < (unsigned int) iter->ifc.lifc_len);
@@ -244,10 +248,10 @@ internal_current(isc_interfaceiter_t *iter) {
         * and is really hard to shut up.
         */
        if (ioctl(iter->socket, SIOCGLIFFLAGS, (char *) &lifreq) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
                                 "%s: getting interface flags: %s",
-                                lifreq.lifr_name,
-                                strerror(errno));
+                                lifreq.lifr_name, strbuf);
                return (ISC_R_IGNORE);
        }
 
@@ -271,14 +275,14 @@ internal_current(isc_interfaceiter_t *iter) {
                 */
                if (ioctl(iter->socket, SIOCGLIFDSTADDR, (char *)&lifreq)
                    < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                isc_msgcat_get(isc_msgcat,
                                               ISC_MSGSET_IFITERIOCTL,
                                               ISC_MSG_GETDESTADDR,
                                               "%s: getting "
                                               "destination address: %s"),
-                                        lifreq.lifr_name,
-                                        strerror(errno));
+                                        lifreq.lifr_name, strbuf);
                        return (ISC_R_IGNORE);
                }
                get_addr(family, &iter->current.dstaddress,
@@ -299,13 +303,13 @@ internal_current(isc_interfaceiter_t *iter) {
                 */
                if (ioctl(iter->socket, SIOCGLIFNETMASK, (char *)&lifreq)
                    < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                isc_msgcat_get(isc_msgcat,
                                               ISC_MSGSET_IFITERIOCTL,
                                               ISC_MSG_GETNETMASK,
                                               "%s: getting netmask: %s"),
-                                        lifreq.lifr_name,
-                                        strerror(errno));
+                                        lifreq.lifr_name, strbuf);
                        return (ISC_R_IGNORE);
                }
                get_addr(family, &iter->current.netmask,
index 0e3fe92ddee19b8c120621d23234f090dd78b8b2..3883ff5fe59493c55dcad41db138813cccab855e 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: interfaceiter.c,v 1.22 2001/06/05 06:34:11 bwelling Exp $ */
+/* $Id: interfaceiter.c,v 1.22.2.1 2001/10/22 23:28:21 gson Exp $ */
 
 #include <config.h>
 
@@ -35,6 +35,7 @@
 #include <isc/msgs.h>
 #include <isc/net.h>
 #include <isc/result.h>
+#include <isc/strerror.h>
 #include <isc/string.h>
 #include <isc/types.h>
 #include <isc/interfaceiter.h>
index 6de3143ccfa3e9a151ab29399bc5a2a46770bead..ba2eb419b5e8b9fa42bb7ccc956dd35161dd4e65 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: net.c,v 1.22 2001/07/09 21:05:59 gson Exp $ */
+/* $Id: net.c,v 1.22.2.1 2001/10/22 23:28:22 gson Exp $ */
 
 #include <config.h>
 
@@ -26,6 +26,7 @@
 #include <isc/msgs.h>
 #include <isc/net.h>
 #include <isc/once.h>
+#include <isc/strerror.h>
 #include <isc/string.h>
 #include <isc/util.h>
 
@@ -42,6 +43,7 @@ static isc_result_t
 try_proto(int domain) {
        int s;
        isc_result_t result = ISC_R_SUCCESS;
+       char strbuf[ISC_STRERRORSIZE];
 
        s = socket(domain, SOCK_STREAM, 0);
        if (s == -1) {
@@ -57,13 +59,14 @@ try_proto(int domain) {
 #endif
                        return (ISC_R_NOTFOUND);
                default:
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                         "socket() %s: %s",
                                         isc_msgcat_get(isc_msgcat,
                                                        ISC_MSGSET_GENERAL,
                                                        ISC_MSG_FAILED,
                                                        "failed"),
-                                        strerror(errno));
+                                        strbuf);
                        return (ISC_R_UNEXPECTED);
                }
        }
index 88e1ea38c3cbfc395bcffade2a1e2ace5f31c3a9..d1e7e2cab90c1a4a3edf1babf59118222fa69e4b 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.c,v 1.207.2.1 2001/09/19 02:37:21 marka Exp $ */
+/* $Id: socket.c,v 1.207.2.2 2001/10/22 23:28:23 gson Exp $ */
 
 #include <config.h>
 
@@ -46,6 +46,7 @@
 #include <isc/print.h>
 #include <isc/region.h>
 #include <isc/socket.h>
+#include <isc/strerror.h>
 #include <isc/task.h>
 #include <isc/thread.h>
 #include <isc/util.h>
@@ -372,6 +373,7 @@ static void
 select_poke(isc_socketmgr_t *mgr, int fd, int msg) {
        int cc;
        int buf[2];
+       char strbuf[ISC_STRERRORSIZE];
 
        buf[0] = fd;
        buf[1] = msg;
@@ -380,13 +382,15 @@ select_poke(isc_socketmgr_t *mgr, int fd, int msg) {
                cc = write(mgr->pipe_fds[1], buf, sizeof(buf));
        } while (cc < 0 && SOFT_ERROR(errno));
                                
-       if (cc < 0)
+       if (cc < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                FATAL_ERROR(__FILE__, __LINE__,
                            isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET,
                                           ISC_MSG_WRITEFAILED,
                                           "write() failed "
                                           "during watcher poke: %s"),
-                           strerror(errno));
+                           strbuf);
+       }
 
        INSIST(cc == sizeof(buf));
 }
@@ -398,6 +402,7 @@ static void
 select_readmsg(isc_socketmgr_t *mgr, int *fd, int *msg) {
        int buf[2];
        int cc;
+       char strbuf[ISC_STRERRORSIZE];
 
        cc = read(mgr->pipe_fds[0], buf, sizeof(buf));
        if (cc < 0) {
@@ -405,12 +410,13 @@ select_readmsg(isc_socketmgr_t *mgr, int *fd, int *msg) {
                if (SOFT_ERROR(errno))
                        return;
 
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                FATAL_ERROR(__FILE__, __LINE__,
                            isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET,
                                           ISC_MSG_READFAILED,
                                           "read() failed "
                                           "during watcher poke: %s"),
-                           strerror(errno));
+                           strbuf);
                
                return;
        }
@@ -440,15 +446,17 @@ static isc_result_t
 make_nonblock(int fd) {
        int ret;
        int flags;
+       char strbuf[ISC_STRERRORSIZE];
 
        flags = fcntl(fd, F_GETFL, 0);
        flags |= O_NONBLOCK;
        ret = fcntl(fd, F_SETFL, flags);
 
        if (ret == -1) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
                                 "fcntl(%d, F_SETFL, %d): %s",
-                                fd, flags, strerror(errno));
+                                fd, flags, strbuf);
 
                return (ISC_R_UNEXPECTED);
        }
@@ -879,6 +887,7 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) {
 #else
        char *cmsg = NULL;
 #endif
+       char strbuf[ISC_STRERRORSIZE];
 
        build_msghdr_recv(sock, dev, &msghdr, cmsg, iov, &read_count);
 
@@ -893,13 +902,14 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) {
                if (SOFT_ERROR(recv_errno))
                        return (DOIO_SOFT);
 
-               if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL))
+               if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) {
+                       isc__strerror(recv_errno, strbuf, sizeof(strbuf));
                        socket_log(sock, NULL, IOEVENT,
                                   isc_msgcat, ISC_MSGSET_SOCKET,
                                   ISC_MSG_DOIORECV, 
                                  "doio_recv: recvmsg(%d) %d bytes, err %d/%s",
-                                  sock->fd, cc, recv_errno,
-                                  strerror(recv_errno));
+                                  sock->fd, cc, recv_errno, strbuf);
+               }
 
 #define SOFT_OR_HARD(_system, _isc) \
        if (recv_errno == _system) { \
@@ -1026,6 +1036,7 @@ doio_send(isc_socket_t *sock, isc_socketevent_t *dev) {
 #endif
        int attempts = 0;
        int send_errno;
+       char strbuf[ISC_STRERRORSIZE];
 
        build_msghdr_send(sock, dev, &msghdr, cmsg, iov, &write_count);
 
@@ -1083,9 +1094,9 @@ doio_send(isc_socket_t *sock, isc_socketevent_t *dev) {
                 * a status.
                 */
                isc_sockaddr_format(&dev->address, addrbuf, sizeof(addrbuf));
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "internal_send: %s: %s",
-                                addrbuf, strerror(send_errno));
+               isc__strerror(send_errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__, "internal_send: %s: %s",
+                                addrbuf, strbuf);
                dev->result = isc__errno2result(send_errno);
                return (DOIO_HARD);
        }
@@ -1273,6 +1284,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
 #if defined(USE_CMSG) || defined(SO_BSDCOMPAT)
        int on = 1;
 #endif
+       char strbuf[ISC_STRERRORSIZE];
 
        REQUIRE(VALID_MANAGER(manager));
        REQUIRE(socketp != NULL && *socketp == NULL);
@@ -1324,13 +1336,14 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
                        return (ISC_R_FAMILYNOSUPPORT);
 
                default:
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                         "socket() %s: %s",
                                         isc_msgcat_get(isc_msgcat,
                                                        ISC_MSGSET_GENERAL,
                                                        ISC_MSG_FAILED,
                                                        "failed"),
-                                        strerror(errno));
+                                        strbuf);
                        return (ISC_R_UNEXPECTED);
                }
        }
@@ -1343,12 +1356,13 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
 #ifdef SO_BSDCOMPAT
        if (setsockopt(sock->fd, SOL_SOCKET, SO_BSDCOMPAT,
                       (void *)&on, sizeof on) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
                                 "setsockopt(%d, SO_BSDCOMPAT) %s: %s",
                                 sock->fd,
                                 isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
                                                ISC_MSG_FAILED, "failed"),
-                                strerror(errno));
+                                strbuf);
                /* Press on... */
        }
 #endif
@@ -1360,6 +1374,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
                if (setsockopt(sock->fd, SOL_SOCKET, SO_TIMESTAMP,
                               (void *)&on, sizeof on) < 0
                    && errno != ENOPROTOOPT) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                         "setsockopt(%d, SO_TIMESTAMP) %s: %s",
                                         sock->fd, 
@@ -1367,7 +1382,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
                                                        ISC_MSGSET_GENERAL,
                                                        ISC_MSG_FAILED,
                                                        "failed"),
-                                        strerror(errno));
+                                        strbuf);
                        /* Press on... */
                }
 #endif /* SO_TIMESTAMP */
@@ -1378,6 +1393,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
                if ((pf == AF_INET6)
                    && (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO,
                                   (void *)&on, sizeof (on)) < 0)) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                         "setsockopt(%d, IPV6_RECVPKTINFO) "
                                         "%s: %s", sock->fd,
@@ -1385,13 +1401,14 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
                                                        ISC_MSGSET_GENERAL,
                                                        ISC_MSG_FAILED,
                                                        "failed"),
-                                        strerror(errno));
+                                        strbuf);
                }
 #else
                /* 2292 */
                if ((pf == AF_INET6)
                    && (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_PKTINFO,
                                   (void *)&on, sizeof (on)) < 0)) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                         "setsockopt(%d, IPV6_PKTINFO) %s: %s",
                                         sock->fd,
@@ -1399,7 +1416,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
                                                        ISC_MSGSET_GENERAL,
                                                        ISC_MSG_FAILED,
                                                        "failed"),
-                                        strerror(errno));
+                                        strbuf);
                }
 #endif /* IPV6_RECVPKTINFO */
 #ifdef IPV6_USE_MIN_MTU        /*2292bis, not too common yet*/
@@ -1659,6 +1676,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
        ISC_SOCKADDR_LEN_T addrlen;
        int fd;
        isc_result_t result = ISC_R_SUCCESS;
+       char strbuf[ISC_STRERRORSIZE];
 
        UNUSED(me);
 
@@ -1711,13 +1729,14 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
                if (SOFT_ERROR(errno) || errno == ECONNRESET) {
                        goto soft_error;
                } else {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                         "internal_accept: accept() %s: %s",
                                         isc_msgcat_get(isc_msgcat,
                                                        ISC_MSGSET_GENERAL,
                                                        ISC_MSG_FAILED,
                                                        "failed"),
-                                        strerror(errno));
+                                        strbuf);
                        fd = -1;
                        result = ISC_R_UNEXPECTED;
                }
@@ -2034,6 +2053,7 @@ watcher(void *uap) {
        fd_set writefds;
        int msg, fd;
        int maxfd;
+       char strbuf[ISC_STRERRORSIZE];
 
        /*
         * Get the control fd here.  This will never change.
@@ -2052,14 +2072,17 @@ watcher(void *uap) {
 
                        cc = select(maxfd, &readfds, &writefds, NULL, NULL);
                        if (cc < 0) {
-                               if (!SOFT_ERROR(errno))
+                               if (!SOFT_ERROR(errno)) {
+                                       isc__strerror(errno, strbuf,
+                                                     sizeof(strbuf));
                                        FATAL_ERROR(__FILE__, __LINE__,
                                                    "select() %s: %s",
                                                    isc_msgcat_get(isc_msgcat,
                                                            ISC_MSGSET_GENERAL,
                                                            ISC_MSG_FAILED,
                                                            "failed"),
-                                                   strerror(errno));
+                                                   strbuf);
+                               }
                        }
 
                        LOCK(&manager->lock);
@@ -2126,6 +2149,9 @@ watcher(void *uap) {
 isc_result_t
 isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
        isc_socketmgr_t *manager;
+#ifdef ISC_PLATFORM_USETHREADS
+       char strbuf[ISC_STRERRORSIZE];
+#endif
 
        REQUIRE(managerp != NULL && *managerp == NULL);
 
@@ -2171,11 +2197,12 @@ isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
        if (pipe(manager->pipe_fds) != 0) {
                DESTROYLOCK(&manager->lock);
                isc_mem_put(mctx, manager, sizeof *manager);
+               isc__strerror(errno, strbuf, sizeof(strbuf));
                UNEXPECTED_ERROR(__FILE__, __LINE__,
                                 "pipe() %s: %s",
                                 isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
                                                ISC_MSG_FAILED, "failed"),
-                                strerror(errno));
+                                strbuf);
 
                return (ISC_R_UNEXPECTED);
        }
@@ -2691,6 +2718,7 @@ isc_socket_sendto2(isc_socket_t *sock, isc_region_t *region,
 
 isc_result_t
 isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) {
+       char strbuf[ISC_STRERRORSIZE];
        int on = 1;
 
        LOCK(&sock->lock);
@@ -2721,8 +2749,9 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) {
                case EINVAL:
                        return (ISC_R_BOUND);
                default:
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "bind: %s", strerror(errno));
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       UNEXPECTED_ERROR(__FILE__, __LINE__, "bind: %s",
+                                        strbuf);
                        return (ISC_R_UNEXPECTED);
                }
        }
@@ -2747,6 +2776,8 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) {
  */
 isc_result_t
 isc_socket_listen(isc_socket_t *sock, unsigned int backlog) {
+       char strbuf[ISC_STRERRORSIZE];
+
        REQUIRE(VALID_SOCKET(sock));
 
        LOCK(&sock->lock);
@@ -2760,8 +2791,9 @@ isc_socket_listen(isc_socket_t *sock, unsigned int backlog) {
 
        if (listen(sock->fd, (int)backlog) < 0) {
                UNLOCK(&sock->lock);
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "listen: %s",
-                                strerror(errno));
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+
+               UNEXPECTED_ERROR(__FILE__, __LINE__, "listen: %s", strbuf);
 
                return (ISC_R_UNEXPECTED);
        }
@@ -2849,6 +2881,7 @@ isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr,
        isc_task_t *ntask = NULL;
        isc_socketmgr_t *manager;
        int cc;
+       char strbuf[ISC_STRERRORSIZE];
 
        REQUIRE(VALID_SOCKET(sock));
        REQUIRE(addr != NULL);
@@ -2905,8 +2938,8 @@ isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr,
 
                sock->connected = 0;
 
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "%d/%s",
-                                errno, strerror(errno));
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__, "%d/%s", errno, strbuf);
 
                UNLOCK(&sock->lock);
                isc_event_free((isc_event_t **)&dev);
@@ -2968,6 +3001,7 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
        isc_task_t *task;
        int cc;
        ISC_SOCKADDR_LEN_T optlen;
+       char strbuf[ISC_STRERRORSIZE];
 
        UNUSED(me);
        INSIST(ev->ev_type == ISC_SOCKEVENT_INTW);
@@ -3047,9 +3081,10 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
 #undef ERROR_MATCH
                default:
                        dev->result = ISC_R_UNEXPECTED;
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                         "internal_connect: connect() %s",
-                                        strerror(errno));
+                                        strbuf);
                }
        } else {
                dev->result = ISC_R_SUCCESS;
@@ -3091,6 +3126,7 @@ isc_result_t
 isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
        ISC_SOCKADDR_LEN_T len;
        isc_result_t ret;
+       char strbuf[ISC_STRERRORSIZE];
 
        REQUIRE(VALID_SOCKET(sock));
        REQUIRE(addressp != NULL);
@@ -3106,8 +3142,9 @@ isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
 
        len = sizeof addressp->type;
        if (getsockname(sock->fd, &addressp->type.sa, (void *)&len) < 0) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "getsockname: %s", strerror(errno));
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__, "getsockname: %s",
+                                strbuf);
                ret = ISC_R_UNEXPECTED;
                goto out;
        }
index c749cbc2aa9e6de6bd782ab8115b029029801508..697004aa5a805437a83d9a4c7549d23a8490bb8b 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: strerror.c,v 1.1 2001/08/30 04:33:19 marka Exp $ */
+/* $Id: strerror.c,v 1.1.2.1 2001/10/22 23:28:25 gson Exp $ */
 
 #include <config.h>
 
@@ -62,9 +62,7 @@ isc__strerror(int num, char *buf, size_t size) {
        return (buf);
 #else
        unsigned int unum = num;
-       isc_once_t once = ISC_ONCE_INIT;
-       static lock;
-       
+
        REQUIRE(buf != NULL);
 
        if (num >= 0 && num < sys_nerr)
index 8a5f1a1008e0670eb646094f66ca85b9add1c03f..328f72b727ec84670c804740ab7cfcfa9509002f 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: time.c,v 1.34.2.4 2001/09/06 00:34:06 marka Exp $ */
+/* $Id: time.c,v 1.34.2.5 2001/10/22 23:28:26 gson Exp $ */
 
 #include <config.h>
 
@@ -28,6 +28,7 @@
 
 #include <isc/log.h>
 #include <isc/print.h>
+#include <isc/strerror.h>
 #include <isc/string.h>
 #include <isc/time.h>
 #include <isc/util.h>
@@ -142,11 +143,13 @@ isc_time_isepoch(isc_time_t *t) {
 isc_result_t
 isc_time_now(isc_time_t *t) {
        struct timeval tv;
+       char strbuf[ISC_STRERRORSIZE];
 
        REQUIRE(t != NULL);
 
        if (gettimeofday(&tv, NULL) == -1) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strerror(errno));
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strbuf);
                return (ISC_R_UNEXPECTED);
        }
 
@@ -182,13 +185,15 @@ isc_time_now(isc_time_t *t) {
 isc_result_t
 isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i) {
        struct timeval tv;
+       char strbuf[ISC_STRERRORSIZE];
 
        REQUIRE(t != NULL);
        REQUIRE(i != NULL);
        INSIST(i->nanoseconds < NS_PER_S);
 
        if (gettimeofday(&tv, NULL) == -1) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strerror(errno));
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strbuf);
                return (ISC_R_UNEXPECTED);
        }