mirror of https://github.com/eclipse/paho.mqtt.c
Set TCP_NODELAY by default, CMake option to not use it #530
This commit is contained in:
parent
913ee39d24
commit
fa7c02e9f5
|
|
@ -64,6 +64,7 @@ option(PAHO_ENABLE_TESTING "Build tests and run" TRUE)
|
|||
option(PAHO_ENABLE_CPACK "Enable CPack" TRUE)
|
||||
option(PAHO_HIGH_PERFORMANCE "Disable tracing and heap tracking" FALSE)
|
||||
option(PAHO_USE_SELECT "Revert to select system call instead of poll" FALSE)
|
||||
option(PAHO_NO_TCP_NODELAY "Don't disable Nagle's algorithm on TCP sockets" FALSE)
|
||||
|
||||
if(NOT WIN32)
|
||||
option(PAHO_WITH_UNIX_SOCKETS "Flag that defines whether to enable Unix-domain sockets" FALSE)
|
||||
|
|
@ -85,6 +86,10 @@ if(PAHO_WITH_LIBUUID)
|
|||
add_definitions(-DUSE_LIBUUID=1)
|
||||
endif()
|
||||
|
||||
if(PAHO_NO_TCP_NODELAY)
|
||||
add_definitions(-DNO_TCP_NODELAY=1)
|
||||
endif()
|
||||
|
||||
if(NOT PAHO_BUILD_SHARED AND NOT PAHO_BUILD_STATIC)
|
||||
message(FATAL_ERROR "You must set either PAHO_BUILD_SHARED, PAHO_BUILD_STATIC, or both")
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -1462,6 +1462,15 @@ int Socket_new(const char* addr, size_t addr_len, int port, SOCKET* sock)
|
|||
if (setsockopt(*sock, SOL_SOCKET, SO_NOSIGPIPE, (void*)&opt, sizeof(opt)) != 0)
|
||||
Log(LOG_ERROR, -1, "Could not set SO_NOSIGPIPE for socket %d", *sock);
|
||||
#endif
|
||||
#if !defined(NO_TCP_NODELAY)
|
||||
{
|
||||
int opt = 1;
|
||||
socklen_t opt_size = sizeof(opt);
|
||||
|
||||
if (setsockopt(*sock, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt)) != 0)
|
||||
Log(LOG_ERROR, -1, "Could not set TCP_NODELAY for socket %d", *sock);
|
||||
}
|
||||
#endif
|
||||
/*#define SMALL_TCP_BUFFER_TESTING
|
||||
This section sets the TCP send buffer to a small amount to provoke TCPSOCKET_INTERRUPTED
|
||||
return codes from send, for testing only!
|
||||
|
|
|
|||
Loading…
Reference in New Issue