Debian Codegraph @

src/connection.c

raw symbols SCIP
1 /*
2 * Copyright (c) 2013-2022 Joris Vink <[email protected]>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #include <sys/param.h>
18 #include <sys/socket.h>
19
20 #include <netinet/tcp.h>
21
22 #include <inttypes.h>
23 #include <fcntl.h>
24
25 #include "kore.h"cxx . . $ `<file>/include/kore/kore.h`/
26 #include "http.h"cxx . . $ `<file>/include/kore/http.h`/
27
28 struct kore_poolcxx . . $ kore_pool# connection_poolcxx . . $ connection_pool.;
29 struct connection_listcxx . . $ connection_list# connectionscxx . . $ connections.;
30 struct connection_listcxx . . $ connection_list# disconnectedcxx . . $ disconnected.;
31
32 void
33 kore_connection_initcxx . . $ kore_connection_init(49f6e7a06ebc5aa8).(void)
34 {
35 u_int32_tcxx . . $ u_int32_t# elm;
36
37 TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&connections);
38 TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&disconnected);
39
40 /* Add some overhead so we don't rollover for internal items. */
41 elm = worker_max_connectionscxx . . $ worker_max_connections. + 10;
42
43 kore_pool_initcxx . . $ kore_pool_init(19b74537ff42c712).(&connection_poolcxx . . $ connection_pool., "connection_pool",
44 sizeof(struct connectioncxx . . $ connection#), elm);
45 }
46
47 void
48 kore_connection_cleanupcxx . . $ kore_connection_cleanup(49f6e7a06ebc5aa8).(void)
49 {
50 /* Drop all connections */
51 kore_connection_prunecxx . . $ kore_connection_prune(d4f767463ce0a6b3).(KORE_CONNECTION_PRUNE_ALLcxx . . $ `include/kore/kore.h:215:9`!);
52 kore_pool_cleanupcxx . . $ kore_pool_cleanup(68cee620b8bd445e).(&connection_poolcxx . . $ connection_pool.);
53 }
54
55 struct connectioncxx . . $ connection# *
56 kore_connection_newcxx . . $ kore_connection_new(c7160e4f828b920c).(void *owner)
57 {
58 struct connectioncxx . . $ connection# *c;
59
60 c = kore_pool_getcxx . . $ kore_pool_get(f5c578167d321b17).(&connection_poolcxx . . $ connection_pool.);
61
62 c->flagscxx . . $ connection#flags. = 0;
63 c->rnbcxx . . $ connection#rnb. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
64 c->snbcxx . . $ connection#snb. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
65 c->ownercxx . . $ connection#owner. = owner;
66 c->handlecxx . . $ connection#handle. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
67
68 c->tlscxx . . $ connection#tls. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
69 c->tls_certcxx . . $ connection#tls_cert. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
70 c->tls_renegcxx . . $ connection#tls_reneg. = 0;
71 c->tls_snicxx . . $ connection#tls_sni. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
72
73 c->disconnectcxx . . $ connection#disconnect. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
74 c->hdlr_extracxx . . $ connection#hdlr_extra. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
75 c->protocxx . . $ connection#proto. = CONN_PROTO_UNKNOWNcxx . . $ `include/kore/kore.h:181:9`!;
76 c->idle_timercxx . . $ connection#idle_timer..startcxx . . $ connection#$anonymous_type_3#start. = 0;
77 c->idle_timercxx . . $ connection#idle_timer..lengthcxx . . $ connection#$anonymous_type_3#length. = KORE_IDLE_TIMER_MAXcxx . . $ `include/kore/kore.h:199:9`!;
78
79 c->evtcxx . . $ connection#evt..typecxx . . $ kore_event#type. = KORE_TYPE_CONNECTIONcxx . . $ `include/kore/kore.h:170:9`!;
80 c->evtcxx . . $ connection#evt..handlecxx . . $ kore_event#handle. = kore_connection_eventcxx . . $ kore_connection_event(d0320739773070f2).;
81
82 #if !defined(KORE_NO_HTTP)
83 c->ws_connectcxx . . $ connection#ws_connect. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
84 c->ws_messagecxx . . $ connection#ws_message. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
85 c->ws_disconnectcxx . . $ connection#ws_disconnect. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
86 c->http_startcxx . . $ connection#http_start. = kore_time_mscxx . . $ kore_time_ms(f708dce9a8856c70).();
87 c->http_timeoutcxx . . $ connection#http_timeout. = http_header_timeoutcxx . . $ http_header_timeout. * 1000;
88 TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&(c->http_requests));
89 #endif
90
91 TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&(c->send_queue));
92
93 return (c);
94 }
95
96 int
97 kore_connection_acceptcxx . . $ kore_connection_accept(39e429f7003ed54f).(struct listenercxx . . $ listener# *listener, struct connectioncxx . . $ connection# **out)
98 {
99 struct connectioncxx . . $ connection# *c;
100 struct sockaddrcxx . . $ sockaddr# *s;
101 socklen_tcxx . . $ socklen_t# len;
102
103 *out = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
104 c = kore_connection_newcxx . . $ kore_connection_new(c7160e4f828b920c).(listener);
105
106 c->familycxx . . $ connection#family. = listener->familycxx . . $ listener#family.;
107
108 switch (c->familycxx . . $ connection#family.) {
109 case AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!:
110 len = sizeof(struct sockaddr_incxx . . $ sockaddr_in#);
111 s = (struct sockaddrcxx . . $ sockaddr# *)&(c->addrcxx . . $ connection#addr..ipv4cxx . . $ connection#$anonymous_type_2#ipv4.);
112 break;
113 case AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!:
114 len = sizeof(struct sockaddr_in6cxx . . $ sockaddr_in6#);
115 s = (struct sockaddrcxx . . $ sockaddr# *)&(c->addrcxx . . $ connection#addr..ipv6cxx . . $ connection#$anonymous_type_2#ipv6.);
116 break;
117 case AF_UNIXcxx . . $ `<external>/8962547315054503424/socket.h:95:9`!:
118 len = sizeof(struct sockaddr_uncxx . . $ sockaddr_un#);
119 s = (struct sockaddrcxx . . $ sockaddr# *)&(c->addrcxx . . $ connection#addr..suncxx . . $ connection#$anonymous_type_2#sun.);
120 break;
121 default:
122 fatalcxx . . $ fatal(f6bc48f0426f26ee).("unknown family type %d", c->familycxx . . $ connection#family.);
123 }
124
125 if ((c->fdcxx . . $ connection#fd. = acceptcxx . . $ accept(ff9054838cdf4227).(listener->fdcxx . . $ listener#fd., s, &len)) == -1) {
126 kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&connection_poolcxx . . $ connection_pool., c);
127 return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!);
128 }
129
130 if (!kore_connection_nonblockcxx . . $ kore_connection_nonblock(9b79fb6aee4c0440).(c->fdcxx . . $ connection#fd., listener->familycxx . . $ listener#family. != AF_UNIXcxx . . $ `<external>/8962547315054503424/socket.h:95:9`!)) {
131 closecxx . . $ close(7864480464b09eea).(c->fdcxx . . $ connection#fd.);
132 kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&connection_poolcxx . . $ connection_pool., c);
133 return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!);
134 }
135
136 if (fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(c->fdcxx . . $ connection#fd., F_SETFDcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:167:9`!, FD_CLOEXECcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:219:9`!) == -1) {
137 closecxx . . $ close(7864480464b09eea).(c->fdcxx . . $ connection#fd.);
138 kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&connection_poolcxx . . $ connection_pool., c);
139 return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!);
140 }
141
142 c->handlecxx . . $ connection#handle. = kore_connection_handlecxx . . $ kore_connection_handle(d3ce87d3c6fa6963).;
143 TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&connections, c, list);
144
145 if (listener->servercxx . . $ listener#server.->tlscxx . . $ kore_server#tls.) {
146 c->statecxx . . $ connection#state. = CONN_STATE_TLS_SHAKEcxx . . $ `include/kore/kore.h:177:9`!;
147 c->writecxx . . $ connection#write. = kore_tls_writecxx . . $ kore_tls_write(6baa9a301ab1221c).;
148 c->readcxx . . $ connection#read. = kore_tls_readcxx . . $ kore_tls_read(6a0a663d3dbc77f8).;
149 } else {
150 c->statecxx . . $ connection#state. = CONN_STATE_ESTABLISHEDcxx . . $ `include/kore/kore.h:178:9`!;
151 c->writecxx . . $ connection#write. = net_writecxx . . $ net_write(6baa9a301ab1221c).;
152 c->readcxx . . $ connection#read. = net_readcxx . . $ net_read(6a0a663d3dbc77f8).;
153
154 if (listener->connectcxx . . $ listener#connect. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
155 kore_runtime_connectcxx . . $ kore_runtime_connect(7abb6533877ecf95).(listener->connectcxx . . $ listener#connect., c);
156 } else {
157 #if !defined(KORE_NO_HTTP)
158 c->protocxx . . $ connection#proto. = CONN_PROTO_HTTPcxx . . $ `include/kore/kore.h:182:9`!;
159 if (http_keepalive_timecxx . . $ http_keepalive_time. != 0) {
160 c->idle_timercxx . . $ connection#idle_timer..lengthcxx . . $ connection#$anonymous_type_3#length. =
161 http_keepalive_timecxx . . $ http_keepalive_time. * 1000;
162 }
163 net_recv_queuecxx . . $ net_recv_queue(8cd27e823268687f).(c, http_header_maxcxx . . $ http_header_max.,
164 NETBUF_CALL_CB_ALWAYScxx . . $ `include/kore/kore.h:115:9`!, http_header_recvcxx . . $ http_header_recv(82c4d452dc2a871a).);
165 #endif
166 }
167 }
168
169 kore_connection_start_idletimercxx . . $ kore_connection_start_idletimer(8475afdb72fd1ebb).(c);
170 worker_active_connectionscxx . . $ worker_active_connections.++;
171
172 *out = c;
173 return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!);
174 }
175
176 void
177 kore_connection_check_timeoutcxx . . $ kore_connection_check_timeout(2c44cd906ae4e829).(u_int64_tcxx . . $ u_int64_t# now)
178 {
179 struct connectioncxx . . $ connection# *c, *next;
180
181 for (c = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&connections); c != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; c = next) {
182 next = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(c, list);
183 if (c->protocxx . . $ connection#proto. == CONN_PROTO_MSGcxx . . $ `include/kore/kore.h:184:9`!)
184 continue;
185 #if !defined(KORE_NO_HTTP)
186 if (c->statecxx . . $ connection#state. == CONN_STATE_ESTABLISHEDcxx . . $ `include/kore/kore.h:178:9`! &&
187 c->protocxx . . $ connection#proto. == CONN_PROTO_HTTPcxx . . $ `include/kore/kore.h:182:9`!) {
188 if (!http_check_timeoutcxx . . $ http_check_timeout(3ccd8369e867b578).(c, now))
189 continue;
190 if (!TAILQ_EMPTYcxx . . $ `<external>/2546723208511035544/queue.h:457:9`!(&c->http_requests))
191 continue;
192 }
193 #endif
194 if (c->flagscxx . . $ connection#flags. & CONN_IDLE_TIMER_ACTcxx . . $ `include/kore/kore.h:191:9`!)
195 kore_connection_check_idletimercxx . . $ kore_connection_check_idletimer(982c2c475c54872d).(now, c);
196 }
197 }
198
199 void
200 kore_connection_prunecxx . . $ kore_connection_prune(d4f767463ce0a6b3).(int all)
201 {
202 struct connectioncxx . . $ connection# *c, *cnext;
203
204 if (all) {
205 for (c = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&connections); c != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; c = cnext) {
206 cnext = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(c, list);
207 net_send_flushcxx . . $ net_send_flush(d3ce87d3c6fa6963).(c);
208 kore_connection_disconnectcxx . . $ kore_connection_disconnect(8475afdb72fd1ebb).(c);
209 }
210 }
211
212 for (c = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&disconnected); c != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; c = cnext) {
213 cnext = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(c, list);
214 TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&disconnected, c, list);
215 kore_connection_removecxx . . $ kore_connection_remove(8475afdb72fd1ebb).(c);
216 }
217 }
218
219 void
220 kore_connection_disconnectcxx . . $ kore_connection_disconnect(8475afdb72fd1ebb).(struct connectioncxx . . $ connection# *c)
221 {
222 if (c->statecxx . . $ connection#state. != CONN_STATE_DISCONNECTINGcxx . . $ `include/kore/kore.h:179:9`!) {
223 c->statecxx . . $ connection#state. = CONN_STATE_DISCONNECTINGcxx . . $ `include/kore/kore.h:179:9`!;
224 if (c->disconnectcxx . . $ connection#disconnect.)
225 c->disconnectcxx . . $ connection#disconnect.(c);
226
227 TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&connections, c, list);
228 TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&disconnected, c, list);
229 }
230 }
231
232 void
233 kore_connection_eventcxx . . $ kore_connection_event(d0320739773070f2).(void *arg, int error)
234 {
235 struct connectioncxx . . $ connection# *c = arg;
236
237 if (error) {
238 kore_connection_disconnectcxx . . $ kore_connection_disconnect(8475afdb72fd1ebb).(c);
239 return;
240 }
241
242 if (!c->handlecxx . . $ connection#handle.(c))
243 kore_connection_disconnectcxx . . $ kore_connection_disconnect(8475afdb72fd1ebb).(c);
244 }
245
246 int
247 kore_connection_handlecxx . . $ kore_connection_handle(d3ce87d3c6fa6963).(struct connectioncxx . . $ connection# *c)
248 {
249 struct listenercxx . . $ listener# *listener;
250
251 kore_connection_stop_idletimercxx . . $ kore_connection_stop_idletimer(8475afdb72fd1ebb).(c);
252
253 switch (c->statecxx . . $ connection#state.) {
254 case CONN_STATE_TLS_SHAKEcxx . . $ `include/kore/kore.h:177:9`!:
255 switch (kore_tls_connection_acceptcxx . . $ kore_tls_connection_accept(d3ce87d3c6fa6963).(c)) {
256 case KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!:
257 break;
258 case KORE_RESULT_RETRYcxx . . $ `include/kore/kore.h:89:9`!:
259 return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!);
260 default:
261 return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!);
262 }
263
264 if (c->ownercxx . . $ connection#owner. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
265 listener = (struct listenercxx . . $ listener# *)c->ownercxx . . $ connection#owner.;
266 if (listener->connectcxx . . $ listener#connect. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
267 kore_runtime_connectcxx . . $ kore_runtime_connect(7abb6533877ecf95).(listener->connectcxx . . $ listener#connect., c);
268 kore_connection_start_idletimercxx . . $ kore_connection_start_idletimer(8475afdb72fd1ebb).(c);
269 return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!);
270 }
271 }
272
273 #if !defined(KORE_NO_HTTP)
274 c->protocxx . . $ connection#proto. = CONN_PROTO_HTTPcxx . . $ `include/kore/kore.h:182:9`!;
275 if (http_keepalive_timecxx . . $ http_keepalive_time. != 0) {
276 c->idle_timercxx . . $ connection#idle_timer..lengthcxx . . $ connection#$anonymous_type_3#length. =
277 http_keepalive_timecxx . . $ http_keepalive_time. * 1000;
278 }
279
280 net_recv_queuecxx . . $ net_recv_queue(8cd27e823268687f).(c, http_header_maxcxx . . $ http_header_max.,
281 NETBUF_CALL_CB_ALWAYScxx . . $ `include/kore/kore.h:115:9`!, http_header_recvcxx . . $ http_header_recv(82c4d452dc2a871a).);
282 #endif
283
284 c->statecxx . . $ connection#state. = CONN_STATE_ESTABLISHEDcxx . . $ `include/kore/kore.h:178:9`!;
285 /* FALLTHROUGH */
286 case CONN_STATE_ESTABLISHEDcxx . . $ `include/kore/kore.h:178:9`!:
287 if (c->evtcxx . . $ connection#evt..flagscxx . . $ kore_event#flags. & KORE_EVENT_READcxx . . $ `include/kore/kore.h:187:9`!) {
288 if (!net_recv_flushcxx . . $ net_recv_flush(d3ce87d3c6fa6963).(c))
289 return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!);
290 }
291
292 if (c->evtcxx . . $ connection#evt..flagscxx . . $ kore_event#flags. & KORE_EVENT_WRITEcxx . . $ `include/kore/kore.h:188:9`!) {
293 if (!net_send_flushcxx . . $ net_send_flush(d3ce87d3c6fa6963).(c))
294 return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!);
295 }
296 break;
297 case CONN_STATE_DISCONNECTINGcxx . . $ `include/kore/kore.h:179:9`!:
298 break;
299 default:
300 break;
301 }
302
303 kore_connection_start_idletimercxx . . $ kore_connection_start_idletimer(8475afdb72fd1ebb).(c);
304
305 return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!);
306 }
307
308 void
309 kore_connection_removecxx . . $ kore_connection_remove(8475afdb72fd1ebb).(struct connectioncxx . . $ connection# *c)
310 {
311 struct netbufcxx . . $ netbuf# *nb, *next;
312 #if !defined(KORE_NO_HTTP)
313 struct http_requestcxx . . $ http_request# *req, *rnext;
314 #endif
315
316 kore_tls_connection_cleanupcxx . . $ kore_tls_connection_cleanup(8475afdb72fd1ebb).(c);
317
318 closecxx . . $ close(7864480464b09eea).(c->fdcxx . . $ connection#fd.);
319
320 if (c->hdlr_extracxx . . $ connection#hdlr_extra. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
321 kore_freecxx . . $ kore_free(5d22bdacc48458e8).(c->hdlr_extracxx . . $ connection#hdlr_extra.);
322
323 #if !defined(KORE_NO_HTTP)
324 for (req = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&(c->http_requests));
325 req != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; req = rnext) {
326 rnext = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(req, olist);
327 TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&(c->http_requests), req, olist);
328 req->ownercxx . . $ http_request#owner. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
329 req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!;
330 http_request_wakeupcxx . . $ http_request_wakeup(322c51a23f687f95).(req);
331 }
332
333 kore_freecxx . . $ kore_free(5d22bdacc48458e8).(c->ws_connectcxx . . $ connection#ws_connect.);
334 kore_freecxx . . $ kore_free(5d22bdacc48458e8).(c->ws_messagecxx . . $ connection#ws_message.);
335 kore_freecxx . . $ kore_free(5d22bdacc48458e8).(c->ws_disconnectcxx . . $ connection#ws_disconnect.);
336 #endif
337
338 for (nb = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&(c->send_queue)); nb != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; nb = next) {
339 next = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(nb, list);
340 nb->flagscxx . . $ netbuf#flags. &= ~NETBUF_MUST_RESENDcxx . . $ `include/kore/kore.h:117:9`!;
341 net_remove_netbufcxx . . $ net_remove_netbuf(59f25c31eed43fe1).(c, nb);
342 }
343
344 if (c->rnbcxx . . $ connection#rnb. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
345 kore_freecxx . . $ kore_free(5d22bdacc48458e8).(c->rnbcxx . . $ connection#rnb.->bufcxx . . $ netbuf#buf.);
346 kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&nb_poolcxx . . $ nb_pool., c->rnbcxx . . $ connection#rnb.);
347 }
348
349 kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&connection_poolcxx . . $ connection_pool., c);
350 worker_active_connectionscxx . . $ worker_active_connections.--;
351 }
352
353 void
354 kore_connection_check_idletimercxx . . $ kore_connection_check_idletimer(982c2c475c54872d).(u_int64_tcxx . . $ u_int64_t# now, struct connectioncxx . . $ connection# *c)
355 {
356 u_int64_tcxx . . $ u_int64_t# d;
357
358 if (now > c->idle_timercxx . . $ connection#idle_timer..startcxx . . $ connection#$anonymous_type_3#start.)
359 d = now - c->idle_timercxx . . $ connection#idle_timer..startcxx . . $ connection#$anonymous_type_3#start.;
360 else
361 d = 0;
362
363 if (d >= c->idle_timercxx . . $ connection#idle_timer..lengthcxx . . $ connection#$anonymous_type_3#length.)
364 kore_connection_disconnectcxx . . $ kore_connection_disconnect(8475afdb72fd1ebb).(c);
365 }
366
367 void
368 kore_connection_start_idletimercxx . . $ kore_connection_start_idletimer(8475afdb72fd1ebb).(struct connectioncxx . . $ connection# *c)
369 {
370 c->flagscxx . . $ connection#flags. |= CONN_IDLE_TIMER_ACTcxx . . $ `include/kore/kore.h:191:9`!;
371 c->idle_timercxx . . $ connection#idle_timer..startcxx . . $ connection#$anonymous_type_3#start. = kore_time_mscxx . . $ kore_time_ms(f708dce9a8856c70).();
372 }
373
374 void
375 kore_connection_stop_idletimercxx . . $ kore_connection_stop_idletimer(8475afdb72fd1ebb).(struct connectioncxx . . $ connection# *c)
376 {
377 c->flagscxx . . $ connection#flags. &= ~CONN_IDLE_TIMER_ACTcxx . . $ `include/kore/kore.h:191:9`!;
378 c->idle_timercxx . . $ connection#idle_timer..startcxx . . $ connection#$anonymous_type_3#start. = 0;
379 }
380
381 int
382 kore_connection_nonblockcxx . . $ kore_connection_nonblock(9b79fb6aee4c0440).(int fd, int nodelay)
383 {
384 int flags;
385
386 if ((flags = fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(fd, F_GETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:168:9`!, 0)) == -1)
387 return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!);
388
389 flags |= O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`!;
390 if (fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(fd, F_SETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:169:9`!, flags) == -1)
391 return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!);
392
393 if (nodelay) {
394 if (!kore_sockoptcxx . . $ kore_sockopt(2326284602b0bb2d).(fd, IPPROTO_TCPcxx . . $ `<external>/9581057695539925927/in.h:51:9`!, TCP_NODELAYcxx . . $ `<external>/14446708121216675145/tcp.h:40:9`!)) {
395 kore_logcxx . . $ kore_log(afcfcee7634adf7d).(LOG_NOTICEcxx . . $ `<external>/6168640806541382331/syslog.h:56:9`!,
396 "failed to set TCP_NODELAY on %d", fd);
397 }
398 }
399
400 return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!);
401 }