Repository : ssh://git@open-mesh.org/alfred
On branch : master
---------------------------------------------------------------
commit 12a478c09c4c6811e5a056ab80996dde024c956a
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Sat Nov 12 10:25:24 2016 +0100
alfred: Allow TXEND to start new transaction
A TXEND which comes before all other PUSH_DATA packets also has to create
its own transaction. Otherwise it cannot store the number of expected
packets for this transaction.
The PUSH_DATA packets can then trigger the finish of the transaction. Or
the transaction will timeout automatically.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
---------------------------------------------------------------
12a478c09c4c6811e5a056ab80996dde024c956a
recv.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/recv.c b/recv.c
index 9fabfa4..bd208fd 100644
--- a/recv.c
+++ b/recv.c
@@ -359,13 +359,28 @@ static int process_alfred_status_txend(struct globals *globals,
search.id = ntohs(request->tx.id);
head = hash_find(globals->transaction_hash, &search);
- if (!head)
- return -1;
+ if (!head) {
+ /* slave must create the transactions to be able to correctly
+ * wait for it */
+ if (globals->opmode != OPMODE_MASTER)
+ goto err;
+
+ /* 0-packet txend for unknown transaction */
+ if (ntohs(request->tx.seqno) == 0)
+ goto err;
+
+ head = transaction_add(globals, mac, ntohs(request->tx.id));
+ if (!head)
+ goto err;
+ }
+ clock_gettime(CLOCK_MONOTONIC, &head->last_rx_time);
head->txend_packets = ntohs(request->tx.seqno);
finish_alfred_transaction(globals, head, mac);
return 0;
+err:
+ return -1;
}
int recv_alfred_packet(struct globals *globals, struct interface *interface,