Skip to content

Commit 69e1881

Browse files
committed
fix: pop session after TRANSMIT_COMPLETE_FAIL
Transport service (TS) fails to deliver a fragmented frame it called send_data_callback_func(TRANSMIT_COMPLETE_FAIL), in this case the TS does not pop the falied session. Therefore, subsequent sends appended a fresh frame to the tail while the element in the top stales and stays in the head, causing all following commands to be re-driven through TS. Relates-to: ZGW-3457 Origin: #47 Signed-off-by: Laudin Molina Troconis <laudin.molinatroconis@silabs.com>
1 parent a43baf6 commit 69e1881

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/transport/S2_wrap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ uint8_t S2_send_frame(struct S2* ctxt,const s2_connection_t* conn, uint8_t* buf,
603603
p.snode = conn->l_node;
604604
p.dnode = conn->r_node;
605605
p.tx_flags = conn->zw_tx_options;
606-
LOG_PRINTF(" Sending S2_send_frame %i %d -> %d\n", len, p.snode, p.dnode);
606+
LOG_PRINTF("Sending S2_send_frame %i %d -> %d\n", len, p.snode, p.dnode);
607607
transmit_start_time = clock_time();
608608
return send_data(&p, buf, len,S2_send_frame_callback,ctxt);
609609
}

src/transport/ZW_SendDataAppl.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,25 +288,36 @@ send_data_callback_func(u8_t status, TX_STATUS_TYPE* ts)
288288
return;
289289
}
290290

291-
292-
// if (status == TRANSMIT_COMPLETE_NO_ACK)
291+
// TS and other senders report TRANSMIT_COMPLETE_FAIL. Pop and
292+
// free the session so the queue advances; the original hold-for-retry
293+
// behaviour (previously on NO_ACK) is preserved only when the resend watchdog
294+
// is active.
293295
if (status == TRANSMIT_COMPLETE_FAIL)
294296
{
295297
etimer_stop(&emergency_timer);
296298

297299
if(resend_counter == 0) {
298-
send_data_appl_session_t *s = list_head(send_data_list);
300+
send_data_appl_session_t *s = list_pop(send_data_list);
299301
if (s)
300302
{
301303
if (s->callback)
302304
{
303305
s->callback(status, s->user, ts);
304306
}
307+
zw_frame_buffer_free(s->fb);
308+
309+
char refcount = memb_free(&session_memb, s);
310+
if(refcount == -1) {
311+
ERR_PRINTF("attempt to deallocate illegal memory block\n");
312+
ASSERT(0);
313+
}
305314
}
306315
else
307316
{
317+
DBG_PRINTF("event in the send data list is NULL\n");
308318
ASSERT(0);
309319
}
320+
process_post(&ZW_SendDataAppl_process, SEND_EVENT_SEND_NEXT_LL, NULL);
310321
}
311322

312323
lock_ll = FALSE;

0 commit comments

Comments
 (0)