aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_sockets.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/mhd_sockets.c')
-rw-r--r--src/microhttpd/mhd_sockets.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/microhttpd/mhd_sockets.c b/src/microhttpd/mhd_sockets.c
index 56a8a852..3504dc26 100644
--- a/src/microhttpd/mhd_sockets.c
+++ b/src/microhttpd/mhd_sockets.c
@@ -462,6 +462,41 @@ MHD_socket_noninheritable_ (MHD_socket sock)
462 462
463 463
464/** 464/**
465 * Change socket buffering mode to default.
466 *
467 * @param sock socket to manipulate
468 * @return non-zero if succeeded, zero otherwise
469 */
470int
471MHD_socket_buffering_reset_ (MHD_socket sock)
472{
473 int res = !0;
474#if defined(TCP_NODELAY) || defined(MHD_TCP_CORK_NOPUSH)
475 const MHD_SCKT_OPT_BOOL_ off_val = 0;
476#if defined(MHD_TCP_CORK_NOPUSH)
477 /* Disable extra buffering */
478 res = (0 == setsockopt (sock,
479 IPPROTO_TCP,
480 MHD_TCP_CORK_NOPUSH,
481 (const void *) &off_val,
482 sizeof (off_val))) && res;
483#endif /* MHD_TCP_CORK_NOPUSH */
484#if defined(TCP_NODELAY)
485 /* Enable Nagle's algorithm for normal buffering */
486 res = (0 == setsockopt (sock,
487 IPPROTO_TCP,
488 TCP_NODELAY,
489 (const void *) &off_val,
490 sizeof (off_val))) && res;
491#endif /* TCP_NODELAY */
492#else /* !TCP_NODELAY && !MHD_TCP_CORK_NOPUSH */
493 (void) sock;
494#endif /* !TCP_NODELAY && !MHD_TCP_CORK_NOPUSH */
495 return res;
496}
497
498
499/**
465 * Create a listen socket, with noninheritable flag if possible. 500 * Create a listen socket, with noninheritable flag if possible.
466 * 501 *
467 * @param pf protocol family to use 502 * @param pf protocol family to use