diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-07-25 20:23:57 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-07-25 20:23:57 +0200 |
commit | 68721add43db814d1bc69e6901684177c549dbbd (patch) | |
tree | ed03cfab7fe517f089f09833d5672e4361421ea1 /src/microhttpd/mhd_send.c | |
parent | 497c1d68bee5b9acac92b8d92b12d6a284cc8399 (diff) | |
download | libmicrohttpd-68721add43db814d1bc69e6901684177c549dbbd.tar.gz libmicrohttpd-68721add43db814d1bc69e6901684177c549dbbd.zip |
simplify
Diffstat (limited to 'src/microhttpd/mhd_send.c')
-rw-r--r-- | src/microhttpd/mhd_send.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index 111fdcfe..656a4b5c 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c | |||
@@ -47,7 +47,19 @@ post_cork_setsockopt (struct MHD_Connection *connection, | |||
47 | const MHD_SCKT_OPT_BOOL_ off_val = 0; | 47 | const MHD_SCKT_OPT_BOOL_ off_val = 0; |
48 | const MHD_SCKT_OPT_BOOL_ on_val = 1; | 48 | const MHD_SCKT_OPT_BOOL_ on_val = 1; |
49 | 49 | ||
50 | if (connection->sk_cork_on == want_cork) | ||
51 | { | ||
52 | /* nothing to do, success! */ | ||
53 | return 0; | ||
54 | } | ||
55 | ret = -1; | ||
50 | #if TCP_CORK | 56 | #if TCP_CORK |
57 | if (! want_cork) | ||
58 | ret = setsockopt (connection->socket_fd, | ||
59 | IPPROTO_TCP, | ||
60 | TCP_CORK, | ||
61 | &off_val, | ||
62 | sizeof (off_val)); | ||
51 | #elif TCP_NODELAY | 63 | #elif TCP_NODELAY |
52 | ret = setsockopt (connection->socket_fd, | 64 | ret = setsockopt (connection->socket_fd, |
53 | IPPROTO_TCP, | 65 | IPPROTO_TCP, |
@@ -60,12 +72,10 @@ post_cork_setsockopt (struct MHD_Connection *connection, | |||
60 | TCP_NOPUSH, | 72 | TCP_NOPUSH, |
61 | (const void *) &on_val, | 73 | (const void *) &on_val, |
62 | sizeof (on_val)); | 74 | sizeof (on_val)); |
63 | #else | ||
64 | ret = -1; | ||
65 | #endif | 75 | #endif |
66 | if (0 == ret) | 76 | if (0 == ret) |
67 | { | 77 | { |
68 | connection->sk_tcp_nodelay_on = false; | 78 | connection->sk_cork_on = want_cork; |
69 | } | 79 | } |
70 | return ret; | 80 | return ret; |
71 | } | 81 | } |
@@ -80,18 +90,20 @@ pre_cork_setsockopt (struct MHD_Connection *connection, | |||
80 | const MHD_SCKT_OPT_BOOL_ on_val = 1; | 90 | const MHD_SCKT_OPT_BOOL_ on_val = 1; |
81 | 91 | ||
82 | // if sk_tcp_nodelay_on is already what we pass in, return. | 92 | // if sk_tcp_nodelay_on is already what we pass in, return. |
83 | if (connection->sk_tcp_nodelay_on == want_cork) | 93 | if (connection->sk_cork_on == want_cork) |
84 | { | 94 | { |
85 | return 0; // return type error | 95 | /* nothing to do, success! */ |
96 | return 0; | ||
86 | } | 97 | } |
87 | 98 | ||
88 | ret = -1; | 99 | ret = -1; |
89 | #if TCP_CORK | 100 | #if TCP_CORK |
90 | ret = setsockopt (connection->socket_fd, | 101 | if (want_cork) |
91 | IPPROTO_TCP, | 102 | ret = setsockopt (connection->socket_fd, |
92 | TCP_CORK, | 103 | IPPROTO_TCP, |
93 | (const void *) want_cork ? &on_val : &off_val, | 104 | TCP_CORK, |
94 | sizeof (on_val)); | 105 | (const void *) &on_val, |
106 | sizeof (on_val)); | ||
95 | #elif TCP_NODELAY | 107 | #elif TCP_NODELAY |
96 | ret = setsockopt (connection->socket_fd, | 108 | ret = setsockopt (connection->socket_fd, |
97 | IPPROTO_TCP, | 109 | IPPROTO_TCP, |
@@ -108,11 +120,7 @@ pre_cork_setsockopt (struct MHD_Connection *connection, | |||
108 | 120 | ||
109 | if (0 == ret) | 121 | if (0 == ret) |
110 | { | 122 | { |
111 | #if TCP_CORK || TCP_NODELAY | 123 | connection->sk_cork_on = want_cork; |
112 | connection->sk_tcp_nodelay_on = true; | ||
113 | #elif TCP_NOPUSH | ||
114 | connection->sk_tcp_nodelay_on = false; | ||
115 | #endif | ||
116 | } | 124 | } |
117 | return ret; | 125 | return ret; |
118 | } | 126 | } |