@@ -100,19 +100,16 @@ static struct tcp_backlog_entry {
100
100
u32_t send_seq ;
101
101
u32_t send_ack ;
102
102
struct k_delayed_work ack_timer ;
103
- bool cancelled ;
104
103
} tcp_backlog [CONFIG_NET_TCP_BACKLOG_SIZE ];
105
104
106
105
static void backlog_ack_timeout (struct k_work * work )
107
106
{
108
107
struct tcp_backlog_entry * backlog =
109
108
CONTAINER_OF (work , struct tcp_backlog_entry , ack_timer );
110
109
111
- if (!backlog -> cancelled ) {
112
- NET_DBG ("Did not receive ACK in %dms" , ACK_TIMEOUT );
110
+ NET_DBG ("Did not receive ACK in %dms" , ACK_TIMEOUT );
113
111
114
- send_reset (backlog -> tcp -> context , & backlog -> remote );
115
- }
112
+ send_reset (backlog -> tcp -> context , & backlog -> remote );
116
113
117
114
memset (backlog , 0 , sizeof (struct tcp_backlog_entry ));
118
115
}
@@ -265,17 +262,8 @@ static int tcp_backlog_ack(struct net_pkt *pkt, struct net_context *context)
265
262
context -> tcp -> send_seq = tcp_backlog [r ].send_seq ;
266
263
context -> tcp -> send_ack = tcp_backlog [r ].send_ack ;
267
264
268
- if (k_delayed_work_cancel (& tcp_backlog [r ].ack_timer ) < 0 ) {
269
- /* Too late to cancel - just set flag for worker.
270
- * TODO: Note that in this case, we can be preempted
271
- * anytime (could have been preempted even before we did
272
- * the check), so access to tcp_backlog should be synchronized
273
- * between this function and worker.
274
- */
275
- tcp_backlog [r ].cancelled = true;
276
- } else {
277
- memset (& tcp_backlog [r ], 0 , sizeof (struct tcp_backlog_entry ));
278
- }
265
+ k_delayed_work_cancel (& tcp_backlog [r ].ack_timer );
266
+ memset (& tcp_backlog [r ], 0 , sizeof (struct tcp_backlog_entry ));
279
267
280
268
return 0 ;
281
269
}
@@ -300,17 +288,8 @@ static int tcp_backlog_rst(struct net_pkt *pkt)
300
288
return - EINVAL ;
301
289
}
302
290
303
- if (k_delayed_work_cancel (& tcp_backlog [r ].ack_timer ) < 0 ) {
304
- /* Too late to cancel - just set flag for worker.
305
- * TODO: Note that in this case, we can be preempted
306
- * anytime (could have been preempted even before we did
307
- * the check), so access to tcp_backlog should be synchronized
308
- * between this function and worker.
309
- */
310
- tcp_backlog [r ].cancelled = true;
311
- } else {
312
- memset (& tcp_backlog [r ], 0 , sizeof (struct tcp_backlog_entry ));
313
- }
291
+ k_delayed_work_cancel (& tcp_backlog [r ].ack_timer );
292
+ memset (& tcp_backlog [r ], 0 , sizeof (struct tcp_backlog_entry ));
314
293
315
294
return 0 ;
316
295
}
@@ -320,22 +299,16 @@ static void handle_fin_timeout(struct k_work *work)
320
299
struct net_tcp * tcp =
321
300
CONTAINER_OF (work , struct net_tcp , fin_timer );
322
301
323
- if (!tcp -> fin_timer_cancelled ) {
324
- NET_DBG ("Did not receive FIN in %dms" , FIN_TIMEOUT );
302
+ NET_DBG ("Did not receive FIN in %dms" , FIN_TIMEOUT );
325
303
326
- net_context_unref (tcp -> context );
327
- }
304
+ net_context_unref (tcp -> context );
328
305
}
329
306
330
307
static void handle_ack_timeout (struct k_work * work )
331
308
{
332
309
/* This means that we did not receive ACK response in time. */
333
310
struct net_tcp * tcp = CONTAINER_OF (work , struct net_tcp , ack_timer );
334
311
335
- if (tcp -> ack_timer_cancelled ) {
336
- return ;
337
- }
338
-
339
312
NET_DBG ("Did not receive ACK in %dms while in %s" , ACK_TIMEOUT ,
340
313
net_tcp_state_str (net_tcp_get_state (tcp )));
341
314
@@ -641,13 +614,8 @@ int net_context_unref(struct net_context *context)
641
614
continue ;
642
615
}
643
616
644
- if (k_delayed_work_cancel (& tcp_backlog [i ].ack_timer ) ==
645
- - EINPROGRESS ) {
646
- tcp_backlog [i ].cancelled = true;
647
- } else {
648
- memset (& tcp_backlog [i ], 0 ,
649
- sizeof (struct tcp_backlog_entry ));
650
- }
617
+ k_delayed_work_cancel (& tcp_backlog [i ].ack_timer );
618
+ memset (& tcp_backlog [i ], 0 , sizeof (tcp_backlog [i ]));
651
619
}
652
620
653
621
net_tcp_release (context -> tcp );
@@ -701,7 +669,6 @@ int net_context_put(struct net_context *context)
701
669
"disposing yet (waiting %dms)" , FIN_TIMEOUT );
702
670
k_delayed_work_submit (& context -> tcp -> fin_timer ,
703
671
FIN_TIMEOUT );
704
- context -> tcp -> fin_timer_cancelled = false;
705
672
queue_fin (context );
706
673
return 0 ;
707
674
}
@@ -1247,7 +1214,6 @@ NET_CONN_CB(tcp_established)
1247
1214
* would be stuck forever.
1248
1215
*/
1249
1216
k_delayed_work_submit (& context -> tcp -> ack_timer , ACK_TIMEOUT );
1250
- context -> tcp -> ack_timer_cancelled = false;
1251
1217
}
1252
1218
1253
1219
send_ack (context , & conn -> remote_addr , false);
0 commit comments