/src/mhd2/src/mhd2/conn_mark_ready.h
Line | Count | Source |
1 | | /* SPDX-License-Identifier: LGPL-2.1-or-later OR (GPL-2.0-or-later WITH eCos-exception-2.0) */ |
2 | | /* |
3 | | This file is part of GNU libmicrohttpd. |
4 | | Copyright (C) 2024 Evgeny Grin (Karlson2k) |
5 | | |
6 | | GNU libmicrohttpd is free software; you can redistribute it and/or |
7 | | modify it under the terms of the GNU Lesser General Public |
8 | | License as published by the Free Software Foundation; either |
9 | | version 2.1 of the License, or (at your option) any later version. |
10 | | |
11 | | GNU libmicrohttpd is distributed in the hope that it will be useful, |
12 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | | Lesser General Public License for more details. |
15 | | |
16 | | Alternatively, you can redistribute GNU libmicrohttpd and/or |
17 | | modify it under the terms of the GNU General Public License as |
18 | | published by the Free Software Foundation; either version 2 of |
19 | | the License, or (at your option) any later version, together |
20 | | with the eCos exception, as follows: |
21 | | |
22 | | As a special exception, if other files instantiate templates or |
23 | | use macros or inline functions from this file, or you compile this |
24 | | file and link it with other works to produce a work based on this |
25 | | file, this file does not by itself cause the resulting work to be |
26 | | covered by the GNU General Public License. However the source code |
27 | | for this file must still be made available in accordance with |
28 | | section (3) of the GNU General Public License v2. |
29 | | |
30 | | This exception does not invalidate any other reasons why a work |
31 | | based on this file might be covered by the GNU General Public |
32 | | License. |
33 | | |
34 | | You should have received copies of the GNU Lesser General Public |
35 | | License and the GNU General Public License along with this library; |
36 | | if not, see <https://www.gnu.org/licenses/>. |
37 | | */ |
38 | | |
39 | | /** |
40 | | * @file src/mhd2/conn_mark_ready.h |
41 | | * @brief The definition of static functions to mark/unmark connection as |
42 | | * "process ready". |
43 | | * @author Karlson2k (Evgeny Grin) |
44 | | */ |
45 | | |
46 | | #ifndef MHD_CONN_MARK_READY_H |
47 | | #define MHD_CONN_MARK_READY_H 1 |
48 | | |
49 | | #include "mhd_sys_options.h" |
50 | | |
51 | | #include "sys_null_macro.h" |
52 | | |
53 | | #include "mhd_assert.h" |
54 | | |
55 | | #include "mhd_connection.h" |
56 | | #include "mhd_daemon.h" |
57 | | #include "mhd_dlinked_list.h" |
58 | | |
59 | | /** |
60 | | * Mark connection as "ready to process" and add it to the end of the |
61 | | * "process ready" list if connection is not in the list. |
62 | | * @param c the connection to mark |
63 | | * @param d the daemon for the connection |
64 | | */ |
65 | | MHD_static_inline_ MHD_FN_PAR_NONNULL_ALL_ void |
66 | | mhd_conn_mark_ready (struct MHD_Connection *restrict c, |
67 | | struct MHD_Daemon *restrict d) |
68 | 0 | { |
69 | 0 | mhd_assert (d == c->daemon); |
70 | 0 | if (c->in_proc_ready) |
71 | 0 | { |
72 | 0 | mhd_assert ((NULL != mhd_DLINKEDL_GET_NEXT (c, proc_ready)) || \ |
73 | 0 | (NULL != mhd_DLINKEDL_GET_PREV (c, proc_ready)) || \ |
74 | 0 | (c == mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready))); |
75 | 0 | return; /* Already marked and in the list */ |
76 | 0 | } |
77 | 0 | mhd_assert (NULL == mhd_DLINKEDL_GET_NEXT (c, proc_ready)); |
78 | 0 | mhd_assert (NULL == mhd_DLINKEDL_GET_PREV (c, proc_ready)); |
79 | 0 | mhd_assert (c != mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready)); |
80 | 0 | mhd_assert (c != mhd_DLINKEDL_GET_LAST (&(d->events), proc_ready)); |
81 | |
|
82 | 0 | mhd_DLINKEDL_INS_LAST (&(d->events), c, proc_ready); |
83 | 0 | c->in_proc_ready = true; |
84 | 0 | } Unexecuted instantiation: stream_funcs.c:mhd_conn_mark_ready Unexecuted instantiation: stream_process_states.c:mhd_conn_mark_ready Unexecuted instantiation: conn_tls_check.c:mhd_conn_mark_ready Unexecuted instantiation: events_process.c:mhd_conn_mark_ready Unexecuted instantiation: daemon_add_conn.c:mhd_conn_mark_ready |
85 | | |
86 | | |
87 | | /** |
88 | | * Mark connection as "not ready to process" and remove it from the "process |
89 | | * ready" list if connection is in the list. |
90 | | * @param c the connection to mark |
91 | | * @param d the daemon for the connection |
92 | | */ |
93 | | MHD_static_inline_ MHD_FN_PAR_NONNULL_ALL_ void |
94 | | mhd_conn_mark_unready (struct MHD_Connection *restrict c, |
95 | | struct MHD_Daemon *restrict d) |
96 | 0 | { |
97 | 0 | mhd_assert (d == c->daemon); |
98 | 0 | if (! c->in_proc_ready) |
99 | 0 | { |
100 | 0 | mhd_assert (NULL == mhd_DLINKEDL_GET_NEXT (c, proc_ready)); |
101 | 0 | mhd_assert (NULL == mhd_DLINKEDL_GET_PREV (c, proc_ready)); |
102 | 0 | mhd_assert (c != mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready)); |
103 | 0 | mhd_assert (c != mhd_DLINKEDL_GET_LAST (&(d->events), proc_ready)); |
104 | 0 | return; /* Already unmarked and not in the list */ |
105 | 0 | } |
106 | 0 | mhd_assert ((NULL != mhd_DLINKEDL_GET_NEXT (c, proc_ready)) || \ |
107 | 0 | (NULL != mhd_DLINKEDL_GET_PREV (c, proc_ready)) || \ |
108 | 0 | (c == mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready))); |
109 | |
|
110 | 0 | mhd_DLINKEDL_DEL (&(d->events), c, proc_ready); |
111 | 0 | c->in_proc_ready = false; |
112 | 0 | } Unexecuted instantiation: stream_funcs.c:mhd_conn_mark_unready Unexecuted instantiation: stream_process_states.c:mhd_conn_mark_unready Unexecuted instantiation: conn_tls_check.c:mhd_conn_mark_unready Unexecuted instantiation: events_process.c:mhd_conn_mark_unready Unexecuted instantiation: daemon_add_conn.c:mhd_conn_mark_unready |
113 | | |
114 | | |
115 | | /** |
116 | | * Update "ready" mark on the connection, remove or add connection to |
117 | | * the "process ready" list if necessary. |
118 | | * @param c the connection to update |
119 | | * @param force_ready ignore network states and mark the connection as "ready" |
120 | | * @param d the daemon for the connection |
121 | | */ |
122 | | MHD_static_inline_ MHD_FN_PAR_NONNULL_ALL_ void |
123 | | mhd_conn_mark_ready_update3 (struct MHD_Connection *restrict c, |
124 | | bool force_ready, |
125 | | struct MHD_Daemon *restrict d) |
126 | 0 | { |
127 | 0 | if (force_ready || |
128 | 0 | (0 != |
129 | 0 | ((((unsigned int) c->sk.ready) | mhd_C_HAS_TLS_DATA_IN (c)) |
130 | 0 | & ((unsigned int) c->event_loop_info) |
131 | 0 | & (MHD_EVENT_LOOP_INFO_RECV | MHD_EVENT_LOOP_INFO_SEND)))) |
132 | 0 | mhd_conn_mark_ready (c, d); |
133 | 0 | else |
134 | 0 | mhd_conn_mark_unready (c, d); |
135 | 0 | } Unexecuted instantiation: stream_funcs.c:mhd_conn_mark_ready_update3 Unexecuted instantiation: stream_process_states.c:mhd_conn_mark_ready_update3 Unexecuted instantiation: conn_tls_check.c:mhd_conn_mark_ready_update3 Unexecuted instantiation: events_process.c:mhd_conn_mark_ready_update3 Unexecuted instantiation: daemon_add_conn.c:mhd_conn_mark_ready_update3 |
136 | | |
137 | | |
138 | | /** |
139 | | * Update "ready" mark on the connection, remove or add connection to |
140 | | * the "process ready" list if necessary. |
141 | | * This function could be used if the "daemon" handle is already extracted |
142 | | * from the connection. |
143 | | * @param c the connection to update |
144 | | * @param d the daemon for the connection |
145 | | */ |
146 | | MHD_static_inline_ MHD_FN_PAR_NONNULL_ALL_ void |
147 | | mhd_conn_mark_ready_update2 (struct MHD_Connection *restrict c, |
148 | | struct MHD_Daemon *restrict d) |
149 | 0 | { |
150 | 0 | mhd_conn_mark_ready_update3 (c, 0, d); |
151 | 0 | } Unexecuted instantiation: stream_funcs.c:mhd_conn_mark_ready_update2 Unexecuted instantiation: stream_process_states.c:mhd_conn_mark_ready_update2 Unexecuted instantiation: conn_tls_check.c:mhd_conn_mark_ready_update2 Unexecuted instantiation: events_process.c:mhd_conn_mark_ready_update2 Unexecuted instantiation: daemon_add_conn.c:mhd_conn_mark_ready_update2 |
152 | | |
153 | | |
154 | | /** |
155 | | * Update "ready" mark on the connection, remove or add connection to |
156 | | * the "process ready" list if necessary. |
157 | | * This function could be used if the "daemon" handle has not been extracted |
158 | | * from the connection. |
159 | | * @param c the connection to update |
160 | | */ |
161 | | MHD_static_inline_ MHD_FN_PAR_NONNULL_ALL_ void |
162 | | mhd_conn_mark_ready_update (struct MHD_Connection *restrict c) |
163 | 0 | { |
164 | 0 | mhd_conn_mark_ready_update2 (c, |
165 | 0 | c->daemon); |
166 | 0 | } Unexecuted instantiation: stream_funcs.c:mhd_conn_mark_ready_update Unexecuted instantiation: stream_process_states.c:mhd_conn_mark_ready_update Unexecuted instantiation: conn_tls_check.c:mhd_conn_mark_ready_update Unexecuted instantiation: events_process.c:mhd_conn_mark_ready_update Unexecuted instantiation: daemon_add_conn.c:mhd_conn_mark_ready_update |
167 | | |
168 | | |
169 | | #endif /* ! MHD_CONN_MARK_READY_H */ |