lib: Reduce min keepalive to 2

This is the lowest value that produces a valid different int value when
multiplied by 3/2.

Speed up associated tests
This commit is contained in:
Roger A. Light
2026-06-13 09:07:30 +01:00
parent b0daaed9b0
commit 345f382fae
6 changed files with 6 additions and 8 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ extern "C" {
* * mosq == NULL
* * host == NULL
* * port < 0
* * keepalive < 5 (keepalive == 0 is allowed, for an infinite keepalive)
* * keepalive < 2 (keepalive == 0 is allowed, for an infinite keepalive)
* MOSQ_ERR_ERRNO - if a system call returned an error. The variable errno
* contains the error code, even on Windows.
* Use strerror_r() where available or FormatMessage() on
+1 -1
View File
@@ -58,7 +58,7 @@ static int mosquitto__connect_init(struct mosquitto *mosq, const char *host, int
if(!host || port < 0 || port > UINT16_MAX){
return MOSQ_ERR_INVAL;
}
if(keepalive != 0 && (keepalive < 5 || keepalive > UINT16_MAX)){
if(keepalive != 0 && (keepalive < 2 || keepalive > UINT16_MAX)){
return MOSQ_ERR_INVAL;
}
+1 -2
View File
@@ -10,7 +10,7 @@
from mosq_test_helper import *
def do_test(conn, data):
keepalive = 5
keepalive = 2
connect_packet = mqtt_packets.gen_connect("01-keepalive-pingreq", keepalive=keepalive)
connack_packet = mqtt_packets.gen_connack(rc=0)
@@ -20,7 +20,6 @@ def do_test(conn, data):
mosq_test.do_receive_send(conn, connect_packet, connack_packet, "connect")
mosq_test.expect_packet(conn, "pingreq", pingreq_packet)
time.sleep(1.0)
conn.send(pingresp_packet)
mosq_test.expect_packet(conn, "pingreq", pingreq_packet)
+1 -2
View File
@@ -8,7 +8,7 @@ from mosq_test_helper import *
def do_test(conn, data):
keepalive = 60
server_keepalive = 4
server_keepalive = 2
connect_packet = mqtt_packets.gen_connect("01-server-keepalive-pingreq", keepalive=keepalive, proto_ver=5)
props = mqtt5_props.gen_uint16_prop(mqtt5_props.SERVER_KEEP_ALIVE, server_keepalive)
@@ -20,7 +20,6 @@ def do_test(conn, data):
mosq_test.do_receive_send(conn, connect_packet, connack_packet, "connect")
mosq_test.expect_packet(conn, "pingreq", pingreq_packet)
time.sleep(1.0)
conn.send(pingresp_packet)
mosq_test.expect_packet(conn, "pingreq", pingreq_packet)
+1 -1
View File
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
}
mosquitto_connect_callback_set(mosq, on_connect);
rc = mosquitto_connect(mosq, "localhost", port, 5);
rc = mosquitto_connect(mosq, "localhost", port, 2);
if(rc != MOSQ_ERR_SUCCESS){
return rc;
}
+1 -1
View File
@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
mosq = new mosquittopp_test("01-keepalive-pingreq");
mosq->connect("localhost", port, 5);
mosq->connect("localhost", port, 2);
while(run == -1){
rc = mosq->loop();