nginx-0.0.2-2004-02-10-19:23:38 import
diff --git a/src/os/unix/ngx_errno.c b/src/os/unix/ngx_errno.c index c50da82..410cfde 100644 --- a/src/os/unix/ngx_errno.c +++ b/src/os/unix/ngx_errno.c
@@ -25,4 +25,34 @@ return len; } +#elif (HAVE_GNU_STRERROR_R) + +/* Linux strerror_r() */ + +ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size) +{ + char *str; + size_t len; + + if (size == 0) { + return 0; + } + + errstr[0] = '\0'; + + str = strerror_r(err, errstr, size); + + if (str != errstr) { + return ngx_cpystrn(errstr, str, size) - errstr; + } + + for (len = 0; len < size; len++) { + if (errstr[len] == '\0') { + break; + } + } + + return len; +} + #endif
diff --git a/src/os/unix/ngx_errno.h b/src/os/unix/ngx_errno.h index 208faa2..7ead602 100644 --- a/src/os/unix/ngx_errno.h +++ b/src/os/unix/ngx_errno.h
@@ -2,8 +2,8 @@ #define _NGX_ERRNO_H_INCLUDED_ -#include <errno.h> -#include <string.h> +#include <ngx_config.h> +#include <ngx_core.h> typedef int ngx_err_t; @@ -34,7 +34,7 @@ #define ngx_set_socket_errno(err) errno = err -#if (HAVE_STRERROR_R) +#if (HAVE_STRERROR_R || HAVE_GNU_STRERROR_R) ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size);
diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h index 2e14831..3d53d20 100644 --- a/src/os/unix/ngx_freebsd_config.h +++ b/src/os/unix/ngx_freebsd_config.h
@@ -7,7 +7,9 @@ #include <stdlib.h> #include <stdarg.h> #include <stdio.h> +#include <errno.h> #include <fcntl.h> +#include <string.h> #include <signal.h> #include <sys/types.h> #include <sys/stat.h>
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h index fca68f6..76b0dd0 100644 --- a/src/os/unix/ngx_linux_config.h +++ b/src/os/unix/ngx_linux_config.h
@@ -13,10 +13,11 @@ #include <stdlib.h> #include <stdarg.h> #include <stdio.h> +#include <errno.h> #include <fcntl.h> +#include <string.h> #include <signal.h> #include <time.h> -#include <string.h> #include <sys/types.h> #include <sys/time.h> #include <sys/select.h>
diff --git a/src/os/unix/ngx_recv.c b/src/os/unix/ngx_recv.c index 60e2d09..3c454e9 100644 --- a/src/os/unix/ngx_recv.c +++ b/src/os/unix/ngx_recv.c
@@ -32,7 +32,7 @@ ngx_set_socket_errno(rev->kq_errno); if (rev->kq_errno == NGX_ECONNRESET - && rev->log_error == NGX_ERROR_IGNORE_ECONNRESET) + && c->log_error == NGX_ERROR_IGNORE_ECONNRESET) { return 0; }
diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h index 920aaf9..f4f8df2 100644 --- a/src/os/unix/ngx_solaris_config.h +++ b/src/os/unix/ngx_solaris_config.h
@@ -14,9 +14,10 @@ #include <stdlib.h> #include <stdarg.h> #include <stdio.h> +#include <errno.h> #include <fcntl.h> +#include <string.h> #include <signal.h> -#include <strings.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h>