mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-25 11:15:54 +08:00
Add set_tcp_nodelay option to disable Nagle's algorithm.
Bug: https://github.com/eclipse/mosquitto/issues/433
This commit is contained in:
@@ -60,6 +60,8 @@ Broker:
|
||||
- Fix upgrade_outgoing_qos for retained message. Closes #534.
|
||||
- Fix CONNACK message not being sent for unauthorised connect on websockets.
|
||||
Closes #8.
|
||||
- Add set_tcp_nodelay option to allow Nagle's algorithm to be disabled on
|
||||
client sockets. Closes #433.
|
||||
|
||||
Client library:
|
||||
- Outgoing messages with QoS>1 are no longer retried after a timeout period.
|
||||
|
||||
@@ -585,6 +585,17 @@
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>set_tcp_nodelay</option> [ true | false ]</term>
|
||||
<listitem>
|
||||
<para>If set to true, the TCP_NODELAY option will be set on
|
||||
client sockets to disable Nagle's algorithm. This
|
||||
has the effect of reducing latency of some messages
|
||||
at potentially increasing the number of TCP packets
|
||||
being sent. Defaults to false.</para>
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>store_clean_interval</option> <replaceable>seconds</replaceable></term>
|
||||
<listitem>
|
||||
|
||||
@@ -131,6 +131,11 @@
|
||||
# This is a non-standard option explicitly disallowed by the spec.
|
||||
#upgrade_outgoing_qos false
|
||||
|
||||
# Disable Nagle's algorithm on client sockets. This has the effect of reducing
|
||||
# latency of individual messages at the potential cost of increasing the number
|
||||
# of packets being sent.
|
||||
#set_tcp_nodelay false
|
||||
|
||||
# =================================================================
|
||||
# Default listener
|
||||
# =================================================================
|
||||
|
||||
@@ -188,6 +188,7 @@ static void config__init_reload(struct mosquitto__config *config)
|
||||
mosquitto__free(config->psk_file);
|
||||
config->psk_file = NULL;
|
||||
config->queue_qos0_messages = false;
|
||||
config->set_tcp_nodelay = false;
|
||||
config->sys_interval = 10;
|
||||
config->upgrade_outgoing_qos = false;
|
||||
if(config->auth_plugins){
|
||||
@@ -1575,6 +1576,8 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, const
|
||||
#else
|
||||
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
|
||||
#endif
|
||||
}else if(!strcmp(token, "set_tcp_nodelay")){
|
||||
if(conf__parse_bool(&token, "set_tcp_nodelay", &config->set_tcp_nodelay, saveptr)) return MOSQ_ERR_INVAL;
|
||||
}else if(!strcmp(token, "start_type")){
|
||||
#ifdef WITH_BRIDGE
|
||||
if(reload) continue; // FIXME
|
||||
|
||||
@@ -210,6 +210,7 @@ struct mosquitto__config {
|
||||
char *pid_file;
|
||||
char *psk_file;
|
||||
bool queue_qos0_messages;
|
||||
bool set_tcp_nodelay;
|
||||
int sys_interval;
|
||||
bool upgrade_outgoing_qos;
|
||||
char *user;
|
||||
|
||||
@@ -21,6 +21,7 @@ Contributors:
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/tcp.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
@@ -120,6 +121,12 @@ int net__socket_accept(struct mosquitto_db *db, mosq_sock_t listensock)
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(db->config->set_tcp_nodelay){
|
||||
int flag = 1;
|
||||
setsockopt(new_sock, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int));
|
||||
}
|
||||
|
||||
new_context = context__init(db, new_sock);
|
||||
if(!new_context){
|
||||
COMPAT_CLOSE(new_sock);
|
||||
|
||||
Reference in New Issue
Block a user