Skip to content

Commit 2ce3ef9

Browse files
committed
portability: TCP_NOPUSH does not exist on linux
1 parent de81471 commit 2ce3ef9

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

external/libfetch/http.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030

3131
#include "bsd_compat.h"
3232

33+
#if !defined(TCP_NOPUSH) && defined(TCP_CORK)
34+
#define TCP_NOPUSH TCP_CORK
35+
#endif
36+
3337
/*
3438
* The following copyright applies to the base64 code:
3539
*
@@ -1543,8 +1547,10 @@ http_connect(struct url *URL, struct url *purl, const char *flags)
15431547
DEBUGF("reusing cached connection to %s:%d\n",
15441548
URL->host, URL->port);
15451549
val = 1;
1550+
#ifdef TCP_NOPUSH
15461551
setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH,
15471552
&val, sizeof(val));
1553+
#endif
15481554
return (conn);
15491555
}
15501556
/* stale cache — different host */
@@ -1637,7 +1643,9 @@ http_connect(struct url *URL, struct url *purl, const char *flags)
16371643
}
16381644

16391645
val = 1;
1646+
#ifdef TCP_NOPUSH
16401647
setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val, sizeof(val));
1648+
#endif
16411649

16421650
clean_http_headerbuf(&headerbuf);
16431651
return (conn);
@@ -1940,8 +1948,10 @@ http_request_body(struct url *URL, const char *op, struct url_stat *us,
19401948
* options to force the pending data to be written.
19411949
*/
19421950
val = 0;
1951+
#ifdef TCP_NOPUSH
19431952
setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val,
19441953
sizeof(val));
1954+
#endif
19451955
val = 1;
19461956
setsockopt(conn->sd, IPPROTO_TCP, TCP_NODELAY, &val,
19471957
sizeof(val));

0 commit comments

Comments
 (0)