Repository : ssh://git@open-mesh.org/alfred
On branch : master
commit abdf1505beeb0d59af2ae984d258e24cb4f6f91b Author: Sven Eckelmann sven@narfation.org Date: Sun May 31 13:35:57 2015 +0200
alfred: Don't push data when nothing is available
The push data code currently sends packets with MAX_PAYLOAD. This allows some checks to be dropped. For example, the check if data must be send out is just a check if the current data still can be copied to the output buffer. But this would also mean that data with a size larger than (MAX_PAYLOAD - sizeof(struct alfred_push_data_v0)) may trigger an empty packet.
This is not a problem by itself because currently the data + header in the dataset cannot be larger than (MAX_PAYLOAD - sizeof(struct alfred_push_data_v0)).
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
abdf1505beeb0d59af2ae984d258e24cb4f6f91b send.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/send.c b/send.c index 5a92132..43c10f4 100644 --- a/send.c +++ b/send.c @@ -82,6 +82,10 @@ int push_data(struct globals *globals, struct interface *interface, * first */ if (total_length + dataset->data.header.length + sizeof(*data) > MAX_PAYLOAD - sizeof(*push)) { + /* is there any data to send? */ + if (total_length == 0) + continue; + tlv_length = total_length; tlv_length += sizeof(*push) - sizeof(push->header); push->header.length = htons(tlv_length);