summaryrefslogtreecommitdiffhomepage
path: root/src/os/unix
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-02-10 16:23:38 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-02-10 16:23:38 +0000
commitc7a2f6860669f45f5abe342163de5bc68e344816 (patch)
tree08755593cd5f7537d0b63cf2a6c8b835e1082792 /src/os/unix
parente9b2cb1b9d286cffa8053e41c87b12ce265c4f25 (diff)
downloadnginx-c7a2f6860669f45f5abe342163de5bc68e344816.tar.gz
nginx-c7a2f6860669f45f5abe342163de5bc68e344816.tar.bz2
nginx-0.0.2-2004-02-10-19:23:38 import
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/ngx_errno.c30
-rw-r--r--src/os/unix/ngx_errno.h6
-rw-r--r--src/os/unix/ngx_freebsd_config.h2
-rw-r--r--src/os/unix/ngx_linux_config.h3
-rw-r--r--src/os/unix/ngx_recv.c2
-rw-r--r--src/os/unix/ngx_solaris_config.h3
6 files changed, 40 insertions, 6 deletions
diff --git a/src/os/unix/ngx_errno.c b/src/os/unix/ngx_errno.c
index c50da8251..410cfde5c 100644
--- a/src/os/unix/ngx_errno.c
+++ b/src/os/unix/ngx_errno.c
@@ -25,4 +25,34 @@ ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size)
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 208faa244..7ead602f7 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 @@ typedef int ngx_err_t;
#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 2e14831ea..3d53d2026 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 fca68f622..76b0dd04c 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 60e2d099f..3c454e98c 100644
--- a/src/os/unix/ngx_recv.c
+++ b/src/os/unix/ngx_recv.c
@@ -32,7 +32,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size)
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 920aaf904..f4f8df2af 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>