From 585c099f0f554905e720ce558bb1c6343847542b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 5 Nov 2017 13:42:05 +0100 Subject: document sleep workaround --- bin/mqtt-multipub | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/mqtt-multipub b/bin/mqtt-multipub index 0502b20..40eba91 100755 --- a/bin/mqtt-multipub +++ b/bin/mqtt-multipub @@ -9,6 +9,7 @@ our $VERSION = '0.00'; use File::Slurp qw(read_file); use Getopt::Long; use Net::MQTT::Simple; +use Time::HiRes qw(usleep); my $mqtt_host; @@ -53,6 +54,16 @@ for my $arg (@ARGV) { } } +# XXX Net::MQTT::Simple passes data to the socket layer, but does not wait for +# it to be successfully sent. So (especially on fast systems, e.g. modern +# Core i5/i7 CPUs) we might terminate before all data was transmitted, leading +# to loss of some messages. +# +# Fixing this probably requires a dive into Net::MQTT::Simple and possibly +# changes in its API, so let's dance the workaround dance for now. + +usleep(100_000); + __END__ =head1 NAME -- cgit v1.2.3