Coverage Report

Created: 2026-12-01 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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
131
{
69
131
  mhd_assert (d == c->daemon);
70
131
  if (c->in_proc_ready)
71
20
  {
72
20
    mhd_assert ((NULL != mhd_DLINKEDL_GET_NEXT (c, proc_ready)) \
73
20
                || (NULL != mhd_DLINKEDL_GET_PREV (c, proc_ready)) \
74
20
                || (c == mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready)));
75
20
    return; /* Already marked and in the list */
76
20
  }
77
111
  mhd_assert (NULL == mhd_DLINKEDL_GET_NEXT (c, proc_ready));
78
111
  mhd_assert (NULL == mhd_DLINKEDL_GET_PREV (c, proc_ready));
79
111
  mhd_assert (c != mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready));
80
111
  mhd_assert (c != mhd_DLINKEDL_GET_LAST (&(d->events), proc_ready));
81
82
111
  mhd_DLINKEDL_INS_LAST (&(d->events), c, proc_ready);
83
111
  c->in_proc_ready = true;
84
111
}
Unexecuted instantiation: stream_funcs.c:mhd_conn_mark_ready(MHD_Connection*, MHD_Daemon*)
stream_process_states.c:mhd_conn_mark_ready(MHD_Connection*, MHD_Daemon*)
Line
Count
Source
68
10
{
69
10
  mhd_assert (d == c->daemon);
70
10
  if (c->in_proc_ready)
71
10
  {
72
10
    mhd_assert ((NULL != mhd_DLINKEDL_GET_NEXT (c, proc_ready)) \
73
10
                || (NULL != mhd_DLINKEDL_GET_PREV (c, proc_ready)) \
74
10
                || (c == mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready)));
75
10
    return; /* Already marked and in the list */
76
10
  }
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
  mhd_DLINKEDL_INS_LAST (&(d->events), c, proc_ready);
83
0
  c->in_proc_ready = true;
84
0
}
Unexecuted instantiation: conn_tls_check.c:mhd_conn_mark_ready(MHD_Connection*, MHD_Daemon*)
events_process.c:mhd_conn_mark_ready(MHD_Connection*, MHD_Daemon*)
Line
Count
Source
68
121
{
69
121
  mhd_assert (d == c->daemon);
70
121
  if (c->in_proc_ready)
71
10
  {
72
10
    mhd_assert ((NULL != mhd_DLINKEDL_GET_NEXT (c, proc_ready)) \
73
10
                || (NULL != mhd_DLINKEDL_GET_PREV (c, proc_ready)) \
74
10
                || (c == mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready)));
75
10
    return; /* Already marked and in the list */
76
10
  }
77
111
  mhd_assert (NULL == mhd_DLINKEDL_GET_NEXT (c, proc_ready));
78
111
  mhd_assert (NULL == mhd_DLINKEDL_GET_PREV (c, proc_ready));
79
111
  mhd_assert (c != mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready));
80
111
  mhd_assert (c != mhd_DLINKEDL_GET_LAST (&(d->events), proc_ready));
81
82
  mhd_DLINKEDL_INS_LAST (&(d->events), c, proc_ready);
83
111
  c->in_proc_ready = true;
84
111
}
Unexecuted instantiation: daemon_add_conn.c:mhd_conn_mark_ready(MHD_Connection*, MHD_Daemon*)
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
329
{
97
329
  mhd_assert (d == c->daemon);
98
329
  if (!c->in_proc_ready)
99
218
  {
100
218
    mhd_assert (NULL == mhd_DLINKEDL_GET_NEXT (c, proc_ready));
101
218
    mhd_assert (NULL == mhd_DLINKEDL_GET_PREV (c, proc_ready));
102
218
    mhd_assert (c != mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready));
103
218
    mhd_assert (c != mhd_DLINKEDL_GET_LAST (&(d->events), proc_ready));
104
218
    return; /* Already unmarked and not in the list */
105
218
  }
106
111
  mhd_assert ((NULL != mhd_DLINKEDL_GET_NEXT (c, proc_ready)) \
107
111
              || (NULL != mhd_DLINKEDL_GET_PREV (c, proc_ready)) \
108
111
              || (c == mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready)));
109
110
111
  mhd_DLINKEDL_DEL (&(d->events), c, proc_ready);
111
111
  c->in_proc_ready = false;
112
111
}
stream_funcs.c:mhd_conn_mark_unready(MHD_Connection*, MHD_Daemon*)
Line
Count
Source
96
68
{
97
68
  mhd_assert (d == c->daemon);
98
68
  if (!c->in_proc_ready)
99
12
  {
100
12
    mhd_assert (NULL == mhd_DLINKEDL_GET_NEXT (c, proc_ready));
101
12
    mhd_assert (NULL == mhd_DLINKEDL_GET_PREV (c, proc_ready));
102
12
    mhd_assert (c != mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready));
103
12
    mhd_assert (c != mhd_DLINKEDL_GET_LAST (&(d->events), proc_ready));
104
12
    return; /* Already unmarked and not in the list */
105
12
  }
106
56
  mhd_assert ((NULL != mhd_DLINKEDL_GET_NEXT (c, proc_ready)) \
107
56
              || (NULL != mhd_DLINKEDL_GET_PREV (c, proc_ready)) \
108
56
              || (c == mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready)));
109
110
  mhd_DLINKEDL_DEL (&(d->events), c, proc_ready);
111
56
  c->in_proc_ready = false;
112
56
}
stream_process_states.c:mhd_conn_mark_unready(MHD_Connection*, MHD_Daemon*)
Line
Count
Source
96
80
{
97
80
  mhd_assert (d == c->daemon);
98
80
  if (!c->in_proc_ready)
99
25
  {
100
25
    mhd_assert (NULL == mhd_DLINKEDL_GET_NEXT (c, proc_ready));
101
25
    mhd_assert (NULL == mhd_DLINKEDL_GET_PREV (c, proc_ready));
102
25
    mhd_assert (c != mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready));
103
25
    mhd_assert (c != mhd_DLINKEDL_GET_LAST (&(d->events), proc_ready));
104
25
    return; /* Already unmarked and not in the list */
105
25
  }
106
55
  mhd_assert ((NULL != mhd_DLINKEDL_GET_NEXT (c, proc_ready)) \
107
55
              || (NULL != mhd_DLINKEDL_GET_PREV (c, proc_ready)) \
108
55
              || (c == mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready)));
109
110
  mhd_DLINKEDL_DEL (&(d->events), c, proc_ready);
111
55
  c->in_proc_ready = false;
112
55
}
Unexecuted instantiation: conn_tls_check.c:mhd_conn_mark_unready(MHD_Connection*, MHD_Daemon*)
events_process.c:mhd_conn_mark_unready(MHD_Connection*, MHD_Daemon*)
Line
Count
Source
96
181
{
97
181
  mhd_assert (d == c->daemon);
98
181
  if (!c->in_proc_ready)
99
181
  {
100
181
    mhd_assert (NULL == mhd_DLINKEDL_GET_NEXT (c, proc_ready));
101
181
    mhd_assert (NULL == mhd_DLINKEDL_GET_PREV (c, proc_ready));
102
181
    mhd_assert (c != mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready));
103
181
    mhd_assert (c != mhd_DLINKEDL_GET_LAST (&(d->events), proc_ready));
104
181
    return; /* Already unmarked and not in the list */
105
181
  }
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
  mhd_DLINKEDL_DEL (&(d->events), c, proc_ready);
111
0
  c->in_proc_ready = false;
112
0
}
Unexecuted instantiation: daemon_add_conn.c:mhd_conn_mark_unready(MHD_Connection*, MHD_Daemon*)
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
392
{
127
392
  if (force_ready
128
373
      || (0 !=
129
373
          ((((unsigned int)c->sk.ready) | mhd_C_HAS_TLS_DATA_IN (c))
130
373
           & ((unsigned int)c->event_loop_info)
131
373
           & (MHD_EVENT_LOOP_INFO_RECV | MHD_EVENT_LOOP_INFO_SEND))))
132
131
    mhd_conn_mark_ready (c, d);
133
261
  else
134
261
    mhd_conn_mark_unready (c, d);
135
392
}
Unexecuted instantiation: stream_funcs.c:mhd_conn_mark_ready_update3(MHD_Connection*, bool, MHD_Daemon*)
stream_process_states.c:mhd_conn_mark_ready_update3(MHD_Connection*, bool, MHD_Daemon*)
Line
Count
Source
126
90
{
127
90
  if (force_ready
128
90
      || (0 !=
129
90
          ((((unsigned int)c->sk.ready) | mhd_C_HAS_TLS_DATA_IN (c))
130
90
           & ((unsigned int)c->event_loop_info)
131
90
           & (MHD_EVENT_LOOP_INFO_RECV | MHD_EVENT_LOOP_INFO_SEND))))
132
10
    mhd_conn_mark_ready (c, d);
133
80
  else
134
80
    mhd_conn_mark_unready (c, d);
135
90
}
Unexecuted instantiation: conn_tls_check.c:mhd_conn_mark_ready_update3(MHD_Connection*, bool, MHD_Daemon*)
events_process.c:mhd_conn_mark_ready_update3(MHD_Connection*, bool, MHD_Daemon*)
Line
Count
Source
126
302
{
127
302
  if (force_ready
128
283
      || (0 !=
129
283
          ((((unsigned int)c->sk.ready) | mhd_C_HAS_TLS_DATA_IN (c))
130
283
           & ((unsigned int)c->event_loop_info)
131
283
           & (MHD_EVENT_LOOP_INFO_RECV | MHD_EVENT_LOOP_INFO_SEND))))
132
121
    mhd_conn_mark_ready (c, d);
133
181
  else
134
181
    mhd_conn_mark_unready (c, d);
135
302
}
Unexecuted instantiation: daemon_add_conn.c:mhd_conn_mark_ready_update3(MHD_Connection*, bool, MHD_Daemon*)
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
90
{
150
90
  mhd_conn_mark_ready_update3 (c, 0, d);
151
90
}
Unexecuted instantiation: stream_funcs.c:mhd_conn_mark_ready_update2(MHD_Connection*, MHD_Daemon*)
stream_process_states.c:mhd_conn_mark_ready_update2(MHD_Connection*, MHD_Daemon*)
Line
Count
Source
149
90
{
150
90
  mhd_conn_mark_ready_update3 (c, 0, d);
151
90
}
Unexecuted instantiation: conn_tls_check.c:mhd_conn_mark_ready_update2(MHD_Connection*, MHD_Daemon*)
Unexecuted instantiation: events_process.c:mhd_conn_mark_ready_update2(MHD_Connection*, MHD_Daemon*)
Unexecuted instantiation: daemon_add_conn.c:mhd_conn_mark_ready_update2(MHD_Connection*, MHD_Daemon*)
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
90
{
164
90
  mhd_conn_mark_ready_update2 (c,
165
90
                               c->daemon);
166
90
}
Unexecuted instantiation: stream_funcs.c:mhd_conn_mark_ready_update(MHD_Connection*)
stream_process_states.c:mhd_conn_mark_ready_update(MHD_Connection*)
Line
Count
Source
163
90
{
164
90
  mhd_conn_mark_ready_update2 (c,
165
90
                               c->daemon);
166
90
}
Unexecuted instantiation: conn_tls_check.c:mhd_conn_mark_ready_update(MHD_Connection*)
Unexecuted instantiation: events_process.c:mhd_conn_mark_ready_update(MHD_Connection*)
Unexecuted instantiation: daemon_add_conn.c:mhd_conn_mark_ready_update(MHD_Connection*)
167
168
169
#endif /* ! MHD_CONN_MARK_READY_H */