Mercurial > hg > nginx
comparison auto/unix @ 7784:8cc5b0365ee5
Improved maximum errno detection.
Previously, systems without sys_nerr (or _sys_nerr) were handled with an
assumption that errors start at 0 and continuous. This is, however, not
something POSIX requires, and not true on some platforms.
Notably, on Linux, where sys_nerr is no longer available for newly linked
binaries starting with glibc 2.32, there are gaps in error list, which
used to stop us from properly detecting maximum errno. Further, on
GNU/Hurd errors start at 0x40000001.
With this change, maximum errno detection is moved to the runtime code,
now able to ignore gaps, and also detects the first error if needed.
This fixes observed "Unknown error" messages as seen on Linux with
glibc 2.32 and on GNU/Hurd.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 01 Mar 2021 20:00:43 +0300 |
parents | efd71d49bde0 |
children | c43a2e8fdf7e |
comparison
equal
deleted
inserted
replaced
7783:171682010da4 | 7784:8cc5b0365ee5 |
---|---|
751 ngx_feature_test='printf("%d", _sys_nerr);' | 751 ngx_feature_test='printf("%d", _sys_nerr);' |
752 . auto/feature | 752 . auto/feature |
753 fi | 753 fi |
754 | 754 |
755 | 755 |
756 if [ $ngx_found = no ]; then | |
757 | |
758 # Solaris has no sys_nerr | |
759 ngx_feature='maximum errno' | |
760 ngx_feature_name=NGX_SYS_NERR | |
761 ngx_feature_run=value | |
762 ngx_feature_incs='#include <errno.h> | |
763 #include <string.h> | |
764 #include <stdio.h>' | |
765 ngx_feature_path= | |
766 ngx_feature_libs= | |
767 ngx_feature_test='int n; | |
768 char *p; | |
769 for (n = 1; n < 1000; n++) { | |
770 errno = 0; | |
771 p = strerror(n); | |
772 if (errno == EINVAL | |
773 || p == NULL | |
774 || strncmp(p, "Unknown error", 13) == 0) | |
775 { | |
776 break; | |
777 } | |
778 } | |
779 printf("%d", n);' | |
780 . auto/feature | |
781 fi | |
782 | |
783 | |
784 ngx_feature="localtime_r()" | 756 ngx_feature="localtime_r()" |
785 ngx_feature_name="NGX_HAVE_LOCALTIME_R" | 757 ngx_feature_name="NGX_HAVE_LOCALTIME_R" |
786 ngx_feature_run=no | 758 ngx_feature_run=no |
787 ngx_feature_incs="#include <time.h>" | 759 ngx_feature_incs="#include <time.h>" |
788 ngx_feature_path= | 760 ngx_feature_path= |