Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_tcp.h"
...
...
_nx_tcp_deferred_cleanup_check(NX_IP *)
Files
loading...
CodeScopeSTM32 Libraries and Samplesnetxduocommon/src/nx_tcp_deferred_cleanup_check.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** NetX Component */ /** */ /** Transmission Control Protocol (TCP) */ /** */... /**************************************************************************/ /**************************************************************************/ #define NX_SOURCE_CODE /* Include necessary system files. */ #include "nx_api.h" #include "nx_ip.h" #include "nx_tcp.h" ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_tcp_deferred_cleanup_check PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function checks for deferred cleanup processing, which is the */ /* case for all TCP socket timeout processing. This is done so that */ /* mutex protection can be obtained prior to processing the timeout. */ /* */ /* INPUT */ /* */ /* ip_ptr Pointer to IP control block */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* _nx_tcp_client_bind_cleanup Bind cleanup */ /* _nx_tcp_connect_cleanup Connect cleanup */ /* _nx_tcp_disconnect_cleanup Disconnect cleanup */ /* _nx_tcp_receive_cleanup Receive cleanup */ /* _nx_tcp_transmit_cleanup Transmit cleanup */ /* */ /* CALLED BY */ /* */ /* _nx_ip_thread_entry IP helper thread */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ /* */... /**************************************************************************/ VOID _nx_tcp_deferred_cleanup_check(NX_IP *ip_ptr) { ULONG created_sockets; ULONG suspended_threads; NX_TCP_SOCKET *socket_ptr; TX_THREAD *thread_ptr; /* Pickup the first socket and the created count. */ socket_ptr = ip_ptr -> nx_ip_tcp_created_sockets_ptr; created_sockets = ip_ptr -> nx_ip_tcp_created_sockets_count; /* Loop through all created TCP sockets on the IP instance. */ while (created_sockets--) { /* Check the socket for deferred bind cleanup. */ suspended_threads = socket_ptr -> nx_tcp_socket_bind_suspended_count; if (suspended_threads) { /* Pickup the socket pointer. */ thread_ptr = socket_ptr -> nx_tcp_socket_bind_suspension_list; /* Loop through the suspended threads for the bind operation to determine if there is a timeout. *//* ... */ do { /* Determine if this thread has deferred the timeout processing. */ if (thread_ptr -> tx_thread_suspend_cleanup == _nx_tcp_cleanup_deferred) { /* Yes, call the cleanup routine again! */ _nx_tcp_client_bind_cleanup(thread_ptr NX_CLEANUP_ARGUMENT); }if (thread_ptr -> tx_thread_suspend_cleanup == _nx_tcp_cleanup_deferred) { ... } /* Move to next suspended thread. */ thread_ptr = thread_ptr -> tx_thread_suspended_next; ...} while (--suspended_threads); }if (suspended_threads) { ... } /* Check the socket for deferred connect cleanup. */ thread_ptr = socket_ptr -> nx_tcp_socket_connect_suspended_thread; if (thread_ptr) { /* Determine if this thread has deferred the timeout processing. */ if (thread_ptr -> tx_thread_suspend_cleanup == _nx_tcp_cleanup_deferred) { /* Yes, call the cleanup routine again! */ _nx_tcp_connect_cleanup(thread_ptr NX_CLEANUP_ARGUMENT); }if (thread_ptr -> tx_thread_suspend_cleanup == _nx_tcp_cleanup_deferred) { ... } }if (thread_ptr) { ... } /* Check the socket for deferred disconnect cleanup. */ thread_ptr = socket_ptr -> nx_tcp_socket_disconnect_suspended_thread; if (thread_ptr) { /* Determine if this thread has deferred the timeout processing. */ if (thread_ptr -> tx_thread_suspend_cleanup == _nx_tcp_cleanup_deferred) { /* Yes, call the cleanup routine again! */ _nx_tcp_disconnect_cleanup(thread_ptr NX_CLEANUP_ARGUMENT); }if (thread_ptr -> tx_thread_suspend_cleanup == _nx_tcp_cleanup_deferred) { ... } }if (thread_ptr) { ... } /* Check the socket for deferred receive cleanup. */ suspended_threads = socket_ptr -> nx_tcp_socket_receive_suspended_count; if (suspended_threads) { /* Pickup the socket pointer. */ thread_ptr = socket_ptr -> nx_tcp_socket_receive_suspension_list; /* Loop through the suspended threads for the receive operation to determine if there is a timeout. *//* ... */ do { /* Determine if this thread has deferred the timeout processing. */ if (thread_ptr -> tx_thread_suspend_cleanup == _nx_tcp_cleanup_deferred) { /* Yes, call the cleanup routine again! */ _nx_tcp_receive_cleanup(thread_ptr NX_CLEANUP_ARGUMENT); }if (thread_ptr -> tx_thread_suspend_cleanup == _nx_tcp_cleanup_deferred) { ... } /* Move to next suspended thread. */ thread_ptr = thread_ptr -> tx_thread_suspended_next; ...} while (--suspended_threads); }if (suspended_threads) { ... } /* Check the socket for deferred transmit cleanup. */ suspended_threads = socket_ptr -> nx_tcp_socket_transmit_suspended_count; if (suspended_threads) { /* Pickup the socket pointer. */ thread_ptr = socket_ptr -> nx_tcp_socket_transmit_suspension_list; /* Loop through the suspended threads for the transmit operation to determine if there is a timeout. *//* ... */ do { /* Determine if this thread has deferred the timeout processing. */ if (thread_ptr -> tx_thread_suspend_cleanup == _nx_tcp_cleanup_deferred) { /* Yes, call the cleanup routine again! */ _nx_tcp_transmit_cleanup(thread_ptr NX_CLEANUP_ARGUMENT); }if (thread_ptr -> tx_thread_suspend_cleanup == _nx_tcp_cleanup_deferred) { ... } /* Move to next suspended thread. */ thread_ptr = thread_ptr -> tx_thread_suspended_next; ...} while (--suspended_threads); }if (suspended_threads) { ... } /* Move to next created TCP socket. */ socket_ptr = socket_ptr -> nx_tcp_socket_created_next; }while (created_sockets--) { ... } }{ ... }