From 2e9685221a5ada01f2c74951779b55b6428ac748 Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Fri, 15 Mar 2019 15:04:37 +0100 Subject: [PATCH] Recheck WHC for unacked data just before blocking A writer blocking on a full WHC will still send out whatever it has buffered but not sent yet. For this, the writer lock must be released, but that means an ACK can sneak in between sending out the packet and relocking the writer (not likely if there's a real network in between, but over a loopback interface it is definitely possible). Therefore, the amount of unacknowledged data that controls the blocking and triggering of it must be refreshed before deciding to block, otherwise it may hang indefinitely. Signed-off-by: Erik Boasson --- src/core/ddsi/src/q_transmit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/ddsi/src/q_transmit.c b/src/core/ddsi/src/q_transmit.c index c4b7911..1cbad3c 100644 --- a/src/core/ddsi/src/q_transmit.c +++ b/src/core/ddsi/src/q_transmit.c @@ -950,7 +950,7 @@ static os_result throttle_writer (struct nn_xpack *xp, struct writer *wr) nn_mtime_t tnow = now_mt (); const nn_mtime_t abstimeout = add_duration_to_mtime (tnow, nn_from_ddsi_duration (wr->xqos->reliability.max_blocking_time)); struct whc_state whcst; - whc_get_state(wr->whc, &whcst); + whc_get_state (wr->whc, &whcst); { ASSERT_MUTEX_HELD (&wr->e.lock); @@ -976,6 +976,7 @@ static os_result throttle_writer (struct nn_xpack *xp, struct writer *wr) } nn_xpack_send (xp, true); os_mutexLock (&wr->e.lock); + whc_get_state (wr->whc, &whcst); } while (gv.rtps_keepgoing && !writer_may_continue (wr, &whcst))