aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjgeboski <jgeboski@gmail.com>2015-01-17 13:15:27 -0500
committerjgeboski <jgeboski@gmail.com>2015-01-17 13:15:27 -0500
commit3ec4eca3a75255de6ee36793d665d5b0e0ff5d7e (patch)
tree0a606de23ed62e324fc6599fad5a2e8d554cf02d
parent0b5eebec7ad0f8d731ddc70b68c902d3f795c6f1 (diff)
downloadbitlbee-facebook-3ec4eca3a75255de6ee36793d665d5b0e0ff5d7e.tar.gz
bitlbee-facebook-3ec4eca3a75255de6ee36793d665d5b0e0ff5d7e.tar.bz2
bitlbee-facebook-3ec4eca3a75255de6ee36793d665d5b0e0ff5d7e.tar.xz
facebook-mqtt: fixed preemptive connection timeouts
As it stands, a connection is declared as being timed out if it has not heard back from the server with a ping response in one keep-alive time interval. However, the MQTT specification states that a connection is only declared timed out after one and a half time intervals. While the effects of this oversight may not be immediately present, over a period uptime, the connection may fall victim to preemptive timeouts.
-rw-r--r--facebook/facebook-mqtt.c4
-rw-r--r--facebook/facebook-mqtt.h14
2 files changed, 10 insertions, 8 deletions
diff --git a/facebook/facebook-mqtt.c b/facebook/facebook-mqtt.c
index 88f9c94..46af995 100644
--- a/facebook/facebook-mqtt.c
+++ b/facebook/facebook-mqtt.c
@@ -194,7 +194,7 @@ static void fb_mqtt_timeout(fb_mqtt_t *mqtt)
g_return_if_fail(mqtt != NULL);
fb_mqtt_timeout_clear(mqtt);
- mqtt->tev = b_timeout_add(FB_MQTT_TIMEOUT, fb_mqtt_cb_timeout, mqtt);
+ mqtt->tev = b_timeout_add(FB_MQTT_TIMEOUT_CONN, fb_mqtt_cb_timeout, mqtt);
}
/**
@@ -232,7 +232,7 @@ static void fb_mqtt_ping(fb_mqtt_t *mqtt)
g_return_if_fail(mqtt != NULL);
fb_mqtt_timeout_clear(mqtt);
- mqtt->tev = b_timeout_add(FB_MQTT_TIMEOUT, fb_mqtt_cb_ping, mqtt);
+ mqtt->tev = b_timeout_add(FB_MQTT_TIMEOUT_PING, fb_mqtt_cb_ping, mqtt);
}
/**
diff --git a/facebook/facebook-mqtt.h b/facebook/facebook-mqtt.h
index 0d9b3f9..e279240 100644
--- a/facebook/facebook-mqtt.h
+++ b/facebook/facebook-mqtt.h
@@ -25,12 +25,14 @@
#include "facebook-util.h"
-#define FB_MQTT_NAME "MQIsdp"
-#define FB_MQTT_VERS 3
-#define FB_MQTT_KA 60
-#define FB_MQTT_HOST "mqtt.facebook.com"
-#define FB_MQTT_PORT 443
-#define FB_MQTT_TIMEOUT (FB_MQTT_KA * 1000)
+#define FB_MQTT_NAME "MQIsdp"
+#define FB_MQTT_VERS 3
+#define FB_MQTT_KA 60
+#define FB_MQTT_HOST "mqtt.facebook.com"
+#define FB_MQTT_PORT 443
+
+#define FB_MQTT_TIMEOUT_CONN (FB_MQTT_KA * 1500)
+#define FB_MQTT_TIMEOUT_PING (FB_MQTT_KA * 1000)
/**
* Executes one of the #fb_mqtt_funcs.