From: Azat Khuzhin Date: Sun, 29 Jan 2017 20:07:40 +0000 (+0300) Subject: Merge branch 'fix-struct-linger' X-Git-Tag: release-2.1.9-beta^2~207 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8567f2f56e2dc9907980e8fd4127bc01983af177;p=libevent Merge branch 'fix-struct-linger' @jbech "Accidentally disabled by 0dda56a due to confusion between struct linger vs. SO_LINGER and #define vs. AC_DEFINE. Try adding synthetic #error test to confirm." * fix-struct-linger: cmake: check for 'struct linger' existence test/bench*: prefix event-config.h macros after 0dda56a48e94 test/bench_httpclient: restore SO_LINGER usage after 0dda56a48e94 Fixes: #444 (original pull-request) (cherry picked from commit 9d5a4bdc5cfbf2385efc7c58103161b3512c4500) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index dd6bf670..1d6bafc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -578,6 +578,8 @@ if(EVENT__HAVE_STRUCT_SOCKADDR_STORAGE) __ss_family "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY) endif() +CHECK_TYPE_SIZE("struct linger" EVENT__HAVE_STRUCT_LINGER) + # Group the source files. set(HDR_PRIVATE bufferevent-internal.h diff --git a/configure.ac b/configure.ac index 7528d37e..ebb59110 100644 --- a/configure.ac +++ b/configure.ac @@ -715,8 +715,7 @@ AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct s #endif ]) -AC_CHECK_TYPES([struct so_linger], -[#define HAVE_SO_LINGER], , +AC_CHECK_TYPES([struct linger],,, [ #ifdef HAVE_SYS_SOCKET_H #include diff --git a/event-config.h.cmake b/event-config.h.cmake index c1355be9..faa159b7 100644 --- a/event-config.h.cmake +++ b/event-config.h.cmake @@ -313,6 +313,9 @@ /* Define to 1 if `__ss_family' is a member of `struct sockaddr_storage'. */ #cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY +/* Define to 1 if the system has the type `struct linger'. */ +#cmakedefine EVENT__HAVE_STRUCT_LINGER + /* Define to 1 if you have the `sysctl' function. */ #cmakedefine EVENT__HAVE_SYSCTL diff --git a/test/bench.c b/test/bench.c index 214479c1..c2c8983d 100644 --- a/test/bench.c +++ b/test/bench.c @@ -136,7 +136,7 @@ run_once(void) int main(int argc, char **argv) { -#ifdef HAVE_SETRLIMIT +#ifdef EVENT__HAVE_SETRLIMIT struct rlimit rl; #endif int i, c; @@ -167,7 +167,7 @@ main(int argc, char **argv) } } -#ifdef HAVE_SETRLIMIT +#ifdef EVENT__HAVE_SETRLIMIT rl.rlim_cur = rl.rlim_max = num_pipes * 2 + 50; if (setrlimit(RLIMIT_NOFILE, &rl) == -1) { perror("setrlimit"); diff --git a/test/bench_cascade.c b/test/bench_cascade.c index 2d85cc1f..1248835d 100644 --- a/test/bench_cascade.c +++ b/test/bench_cascade.c @@ -139,7 +139,7 @@ run_once(int num_pipes) int main(int argc, char **argv) { -#ifdef HAVE_SETRLIMIT +#ifdef EVENT__HAVE_SETRLIMIT struct rlimit rl; #endif int i, c; @@ -162,7 +162,7 @@ main(int argc, char **argv) } } -#ifdef HAVE_SETRLIMIT +#ifdef EVENT__HAVE_SETRLIMIT rl.rlim_cur = rl.rlim_max = num_pipes * 2 + 50; if (setrlimit(RLIMIT_NOFILE, &rl) == -1) { perror("setrlimit"); diff --git a/test/bench_httpclient.c b/test/bench_httpclient.c index e1592951..7c7ee470 100644 --- a/test/bench_httpclient.c +++ b/test/bench_httpclient.c @@ -113,13 +113,13 @@ errorcb(struct bufferevent *b, short what, void *arg) static void frob_socket(evutil_socket_t sock) { -#ifdef HAVE_SO_LINGER +#ifdef EVENT__HAVE_STRUCT_LINGER struct linger l; #endif int one = 1; if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&one, sizeof(one))<0) perror("setsockopt(SO_REUSEADDR)"); -#ifdef HAVE_SO_LINGER +#ifdef EVENT__HAVE_STRUCT_LINGER l.l_onoff = 1; l.l_linger = 0; if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (void*)&l, sizeof(l))<0)