aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-02-15 03:30:41 +0100
committerChristian Grothoff <christian@grothoff.org>2018-02-15 03:32:31 +0100
commitbca7a709f8129e856d9175ea1081abc0feec883c (patch)
treec11cc18b279430faaf1e088edd5fecb51598c76c
parentb926a975e6633e9d4d1c2ec21f459e55a5ceb5de (diff)
downloadlibmicrohttpd-bca7a709f8129e856d9175ea1081abc0feec883c.tar.gz
libmicrohttpd-bca7a709f8129e856d9175ea1081abc0feec883c.zip
add a few more missing fundamental API functions
-rw-r--r--src/include/microhttpd2.h203
-rw-r--r--src/lib/Makefile.am5
-rw-r--r--src/lib/daemon_add_connection.c63
-rw-r--r--src/lib/daemon_create.c3
-rw-r--r--src/lib/daemon_get_fdset.c107
-rw-r--r--src/lib/daemon_get_timeout.c54
-rw-r--r--src/lib/daemon_quiesce.c3
-rw-r--r--src/lib/daemon_run.c52
-rw-r--r--src/lib/daemon_run_from_select.c59
-rw-r--r--src/lib/daemon_start.c5
-rw-r--r--src/lib/internal.c3
-rw-r--r--src/lib/memorypool.c12
12 files changed, 557 insertions, 12 deletions
diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h
index bb65f534..2fae90b1 100644
--- a/src/include/microhttpd2.h
+++ b/src/include/microhttpd2.h
@@ -1197,6 +1197,209 @@ _MHD_EXTERN void
1197MHD_daemon_destroy (struct MHD_Daemon *daemon); 1197MHD_daemon_destroy (struct MHD_Daemon *daemon);
1198 1198
1199 1199
1200/**
1201 * Add another client connection to the set of connections managed by
1202 * MHD. This API is usually not needed (since MHD will accept inbound
1203 * connections on the server socket). Use this API in special cases,
1204 * for example if your HTTP server is behind NAT and needs to connect
1205 * out to the HTTP client, or if you are building a proxy.
1206 *
1207 * If you use this API in conjunction with a internal select or a
1208 * thread pool, you must set the option #MHD_USE_ITC to ensure that
1209 * the freshly added connection is immediately processed by MHD.
1210 *
1211 * The given client socket will be managed (and closed!) by MHD after
1212 * this call and must no longer be used directly by the application
1213 * afterwards.
1214 *
1215 * @param daemon daemon that manages the connection
1216 * @param client_socket socket to manage (MHD will expect
1217 * to receive an HTTP request from this socket next).
1218 * @param addr IP address of the client
1219 * @param addrlen number of bytes in @a addr
1220 * @return #MHD_SC_OK on success
1221 * The socket will be closed in any case; `errno` is
1222 * set to indicate further details about the error.
1223 * @ingroup specialized
1224 */
1225_MHD_EXTERN enum MHD_StatusCode
1226MHD_daemon_add_connection (struct MHD_Daemon *daemon,
1227 MHD_socket client_socket,
1228 const struct sockaddr *addr,
1229 socklen_t addrlen);
1230
1231
1232/**
1233 * Obtain the `select()` sets for this daemon. Daemon's FDs will be
1234 * added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO
1235 * for each fd_set before calling this function. FD_SETSIZE is assumed
1236 * to be platform's default.
1237 *
1238 * This function should only be called in when MHD is configured to
1239 * use external select with 'select()' or with 'epoll'. In the latter
1240 * case, it will only add the single 'epoll()' file descriptor used by
1241 * MHD to the sets. It's necessary to use #MHD_get_timeout() in
1242 * combination with this function.
1243 *
1244 * This function must be called only for daemon started without
1245 * #MHD_USE_INTERNAL_POLLING_THREAD flag.
1246 *
1247 * @param daemon daemon to get sets from
1248 * @param read_fd_set read set
1249 * @param write_fd_set write set
1250 * @param except_fd_set except set
1251 * @param max_fd increased to largest FD added (if larger
1252 * than existing value); can be NULL
1253 * @return #MHD_SC_OK on success, otherwise error code
1254 * @ingroup event
1255 */
1256_MHD_EXTERN enum MHD_StatusCode
1257MHD_daemon_get_fdset (struct MHD_Daemon *daemon,
1258 fd_set *read_fd_set,
1259 fd_set *write_fd_set,
1260 fd_set *except_fd_set,
1261 MHD_socket *max_fd);
1262
1263
1264/**
1265 * Obtain the `select()` sets for this daemon. Daemon's FDs will be
1266 * added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO
1267 * for each fd_set before calling this function.
1268 *
1269 * Passing custom FD_SETSIZE as @a fd_setsize allow usage of
1270 * larger/smaller than platform's default fd_sets.
1271 *
1272 * This function should only be called in when MHD is configured to
1273 * use external select with 'select()' or with 'epoll'. In the latter
1274 * case, it will only add the single 'epoll' file descriptor used by
1275 * MHD to the sets. It's necessary to use #MHD_get_timeout() in
1276 * combination with this function.
1277 *
1278 * This function must be called only for daemon started
1279 * without #MHD_USE_INTERNAL_POLLING_THREAD flag.
1280 *
1281 * @param daemon daemon to get sets from
1282 * @param read_fd_set read set
1283 * @param write_fd_set write set
1284 * @param except_fd_set except set
1285 * @param max_fd increased to largest FD added (if larger
1286 * than existing value); can be NULL
1287 * @param fd_setsize value of FD_SETSIZE
1288 * @return #MHD_SC_OK on success, otherwise error code
1289 * @ingroup event
1290 */
1291_MHD_EXTERN enum MHD_StatusCode
1292MHD_daemon_get_fdset2 (struct MHD_Daemon *daemon,
1293 fd_set *read_fd_set,
1294 fd_set *write_fd_set,
1295 fd_set *except_fd_set,
1296 MHD_socket *max_fd,
1297 unsigned int fd_setsize);
1298
1299
1300/**
1301 * Obtain the `select()` sets for this daemon. Daemon's FDs will be
1302 * added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO
1303 * for each fd_set before calling this function. Size of fd_set is
1304 * determined by current value of FD_SETSIZE. It's necessary to use
1305 * #MHD_get_timeout() in combination with this function.
1306 *
1307 * This function could be called only for daemon started
1308 * without #MHD_USE_INTERNAL_POLLING_THREAD flag.
1309 *
1310 * @param daemon daemon to get sets from
1311 * @param read_fd_set read set
1312 * @param write_fd_set write set
1313 * @param except_fd_set except set
1314 * @param max_fd increased to largest FD added (if larger
1315 * than existing value); can be NULL
1316 * @return #MHD_YES on success, #MHD_NO if this
1317 * daemon was not started with the right
1318 * options for this call or any FD didn't
1319 * fit fd_set.
1320 * @ingroup event
1321 */
1322#define MHD_daemon_get_fdset(daemon,read_fd_set,write_fd_set,except_fd_set,max_fd) \
1323 MHD_get_fdset2((daemon),(read_fd_set),(write_fd_set),(except_fd_set),(max_fd),FD_SETSIZE)
1324
1325
1326/**
1327 * Obtain timeout value for polling function for this daemon.
1328 * This function set value to amount of milliseconds for which polling
1329 * function (`select()` or `poll()`) should at most block, not the
1330 * timeout value set for connections.
1331 * It is important to always use this function, even if connection
1332 * timeout is not set, as in some cases MHD may already have more
1333 * data to process on next turn (data pending in TLS buffers,
1334 * connections are already ready with epoll etc.) and returned timeout
1335 * will be zero.
1336 *
1337 * @param daemon daemon to query for timeout
1338 * @param timeout set to the timeout (in milliseconds)
1339 * @return #MHD_SC_OK on success, #MHD_SC_NO_TIMEOUT if timeouts are
1340 * not used (or no connections exist that would
1341 * necessitate the use of a timeout right now), otherwise
1342 * an error code
1343 * @ingroup event
1344 */
1345_MHD_EXTERN enum MHD_StatusCode
1346MHD_daemon_get_timeout (struct MHD_Daemon *daemon,
1347 MHD_UNSIGNED_LONG_LONG *timeout);
1348
1349
1350/**
1351 * Run webserver operations (without blocking unless in client
1352 * callbacks). This method should be called by clients in combination
1353 * with #MHD_get_fdset if the client-controlled select method is used
1354 * and #MHD_get_timeout().
1355 *
1356 * This function is a convenience method, which is useful if the
1357 * fd_sets from #MHD_get_fdset were not directly passed to `select()`;
1358 * with this function, MHD will internally do the appropriate `select()`
1359 * call itself again. While it is always safe to call #MHD_run (if
1360 * #MHD_USE_INTERNAL_POLLING_THREAD is not set), you should call
1361 * #MHD_run_from_select if performance is important (as it saves an
1362 * expensive call to `select()`).
1363 *
1364 * @param daemon daemon to run
1365 * @return #MHD_SC_OK on success
1366 * @ingroup event
1367 */
1368_MHD_EXTERN enum MHD_StatusCode
1369MHD_daemon_run (struct MHD_Daemon *daemon);
1370
1371
1372/**
1373 * Run webserver operations. This method should be called by clients
1374 * in combination with #MHD_get_fdset and #MHD_get_timeout() if the
1375 * client-controlled select method is used.
1376 *
1377 * You can use this function instead of #MHD_run if you called
1378 * `select()` on the result from #MHD_get_fdset. File descriptors in
1379 * the sets that are not controlled by MHD will be ignored. Calling
1380 * this function instead of #MHD_run is more efficient as MHD will not
1381 * have to call `select()` again to determine which operations are
1382 * ready.
1383 *
1384 * This function cannot be used with daemon started with
1385 * #MHD_USE_INTERNAL_POLLING_THREAD flag.
1386 *
1387 * @param daemon daemon to run select loop for
1388 * @param read_fd_set read set
1389 * @param write_fd_set write set
1390 * @param except_fd_set except set
1391 * @return #MHD_SC_OK on success
1392 * @ingroup event
1393 */
1394_MHD_EXTERN enum MHD_StatusCode
1395MHD_daemon_run_from_select (struct MHD_Daemon *daemon,
1396 const fd_set *read_fd_set,
1397 const fd_set *write_fd_set,
1398 const fd_set *except_fd_set);
1399
1400
1401
1402
1200/* ********************* daemon options ************** */ 1403/* ********************* daemon options ************** */
1201 1404
1202 1405
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index f982c70a..b527d7e5 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -60,10 +60,15 @@ libmicrohttpd_la_SOURCES = \
60 action_suspend.c \ 60 action_suspend.c \
61 connection_info.c \ 61 connection_info.c \
62 connection_options.c \ 62 connection_options.c \
63 daemon_add_connection.c \
63 daemon_create.c \ 64 daemon_create.c \
64 daemon_destroy.c \ 65 daemon_destroy.c \
66 daemon_get_fdset.c \
67 daemon_get_timeout.c \
65 daemon_info.c \ 68 daemon_info.c \
66 daemon_options.c \ 69 daemon_options.c \
70 daemon_run.c \
71 daemon_run_from_select.c \
67 daemon_start.c \ 72 daemon_start.c \
68 daemon_quiesce.c \ 73 daemon_quiesce.c \
69 init.c init.h \ 74 init.c init.h \
diff --git a/src/lib/daemon_add_connection.c b/src/lib/daemon_add_connection.c
new file mode 100644
index 00000000..30492d7c
--- /dev/null
+++ b/src/lib/daemon_add_connection.c
@@ -0,0 +1,63 @@
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20/**
21 * @file lib/daemon_add_connection.c
22 * @brief main functions to add a connection to be managed by a daemon
23 * @author Christian Grothoff
24 */
25#include "internal.h"
26
27
28/**
29 * Add another client connection to the set of connections managed by
30 * MHD. This API is usually not needed (since MHD will accept inbound
31 * connections on the server socket). Use this API in special cases,
32 * for example if your HTTP server is behind NAT and needs to connect
33 * out to the HTTP client, or if you are building a proxy.
34 *
35 * If you use this API in conjunction with a internal select or a
36 * thread pool, you must set the option
37 * #MHD_USE_ITC to ensure that the freshly added
38 * connection is immediately processed by MHD.
39 *
40 * The given client socket will be managed (and closed!) by MHD after
41 * this call and must no longer be used directly by the application
42 * afterwards.
43 *
44 * @param daemon daemon that manages the connection
45 * @param client_socket socket to manage (MHD will expect
46 * to receive an HTTP request from this socket next).
47 * @param addr IP address of the client
48 * @param addrlen number of bytes in @a addr
49 * @return #MHD_SC_OK on success
50 * The socket will be closed in any case; `errno` is
51 * set to indicate further details about the error.
52 * @ingroup specialized
53 */
54_MHD_EXTERN enum MHD_StatusCode
55MHD_daemon_add_connection (struct MHD_Daemon *daemon,
56 MHD_socket client_socket,
57 const struct sockaddr *addr,
58 socklen_t addrlen)
59{
60 return -1;
61}
62
63/* end of daemon_add_connection.c */
diff --git a/src/lib/daemon_create.c b/src/lib/daemon_create.c
index e124b745..ade51c1e 100644
--- a/src/lib/daemon_create.c
+++ b/src/lib/daemon_create.c
@@ -135,3 +135,6 @@ MHD_daemon_create (MHD_RequestCallback cb,
135#endif 135#endif
136 return daemon; 136 return daemon;
137} 137}
138
139
140/* end of daemon_create.c */
diff --git a/src/lib/daemon_get_fdset.c b/src/lib/daemon_get_fdset.c
new file mode 100644
index 00000000..afbf3d6b
--- /dev/null
+++ b/src/lib/daemon_get_fdset.c
@@ -0,0 +1,107 @@
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20/**
21 * @file lib/daemon_get_fdset.c
22 * @brief function to get select() fdset of a daemon
23 * @author Christian Grothoff
24 */
25#include "internal.h"
26
27/**
28 * We defined a macro with the same name as a function we
29 * are implementing here. Need to undef the macro to avoid
30 * causing a conflict.
31 */
32#undef MHD_daemon_get_fdset
33
34/**
35 * Obtain the `select()` sets for this daemon. Daemon's FDs will be
36 * added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO
37 * for each fd_set before calling this function. FD_SETSIZE is assumed
38 * to be platform's default.
39 *
40 * This function should only be called in when MHD is configured to
41 * use external select with 'select()' or with 'epoll'. In the latter
42 * case, it will only add the single 'epoll()' file descriptor used by
43 * MHD to the sets. It's necessary to use #MHD_get_timeout() in
44 * combination with this function.
45 *
46 * This function must be called only for daemon started without
47 * #MHD_USE_INTERNAL_POLLING_THREAD flag.
48 *
49 * @param daemon daemon to get sets from
50 * @param read_fd_set read set
51 * @param write_fd_set write set
52 * @param except_fd_set except set
53 * @param max_fd increased to largest FD added (if larger
54 * than existing value); can be NULL
55 * @return #MHD_SC_OK on success, otherwise error code
56 * @ingroup event
57 */
58enum MHD_StatusCode
59MHD_daemon_get_fdset (struct MHD_Daemon *daemon,
60 fd_set *read_fd_set,
61 fd_set *write_fd_set,
62 fd_set *except_fd_set,
63 MHD_socket *max_fd)
64{
65 return -1;
66}
67
68
69/**
70 * Obtain the `select()` sets for this daemon. Daemon's FDs will be
71 * added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO
72 * for each fd_set before calling this function.
73 *
74 * Passing custom FD_SETSIZE as @a fd_setsize allow usage of
75 * larger/smaller than platform's default fd_sets.
76 *
77 * This function should only be called in when MHD is configured to
78 * use external select with 'select()' or with 'epoll'. In the latter
79 * case, it will only add the single 'epoll' file descriptor used by
80 * MHD to the sets. It's necessary to use #MHD_get_timeout() in
81 * combination with this function.
82 *
83 * This function must be called only for daemon started
84 * without #MHD_USE_INTERNAL_POLLING_THREAD flag.
85 *
86 * @param daemon daemon to get sets from
87 * @param read_fd_set read set
88 * @param write_fd_set write set
89 * @param except_fd_set except set
90 * @param max_fd increased to largest FD added (if larger
91 * than existing value); can be NULL
92 * @param fd_setsize value of FD_SETSIZE
93 * @return #MHD_SC_OK on success, otherwise error code
94 * @ingroup event
95 */
96enum MHD_StatusCode
97MHD_daemon_get_fdset2 (struct MHD_Daemon *daemon,
98 fd_set *read_fd_set,
99 fd_set *write_fd_set,
100 fd_set *except_fd_set,
101 MHD_socket *max_fd,
102 unsigned int fd_setsize)
103{
104 return -1;
105}
106
107/* end of daemon_get_fdset.c */
diff --git a/src/lib/daemon_get_timeout.c b/src/lib/daemon_get_timeout.c
new file mode 100644
index 00000000..fa3e39f9
--- /dev/null
+++ b/src/lib/daemon_get_timeout.c
@@ -0,0 +1,54 @@
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20/**
21 * @file lib/daemon_get_timeout.c
22 * @brief function to obtain timeout for event loop
23 * @author Christian Grothoff
24 */
25#include "internal.h"
26
27
28/**
29 * Obtain timeout value for polling function for this daemon.
30 * This function set value to amount of milliseconds for which polling
31 * function (`select()` or `poll()`) should at most block, not the
32 * timeout value set for connections.
33 * It is important to always use this function, even if connection
34 * timeout is not set, as in some cases MHD may already have more
35 * data to process on next turn (data pending in TLS buffers,
36 * connections are already ready with epoll etc.) and returned timeout
37 * will be zero.
38 *
39 * @param daemon daemon to query for timeout
40 * @param timeout set to the timeout (in milliseconds)
41 * @return #MHD_SC_OK on success, #MHD_SC_NO_TIMEOUT if timeouts are
42 * not used (or no connections exist that would
43 * necessitate the use of a timeout right now), otherwise
44 * an error code
45 * @ingroup event
46 */
47enum MHD_StatusCode
48MHD_daemon_get_timeout (struct MHD_Daemon *daemon,
49 MHD_UNSIGNED_LONG_LONG *timeout)
50{
51 return -1;
52}
53
54/* end of daemon_get_timeout.c */
diff --git a/src/lib/daemon_quiesce.c b/src/lib/daemon_quiesce.c
index caad0a25..5221b2cb 100644
--- a/src/lib/daemon_quiesce.c
+++ b/src/lib/daemon_quiesce.c
@@ -18,7 +18,7 @@
18*/ 18*/
19 19
20/** 20/**
21 * @file lib/daemon.c 21 * @file lib/daemon_quiesce.c
22 * @brief main functions to quiesce a daemon 22 * @brief main functions to quiesce a daemon
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
@@ -124,4 +124,5 @@ MHD_daemon_quiesce (struct MHD_Daemon *daemon)
124 return listen_socket; 124 return listen_socket;
125} 125}
126 126
127/* end of daemon_quiesce.c */
127 128
diff --git a/src/lib/daemon_run.c b/src/lib/daemon_run.c
new file mode 100644
index 00000000..cf9ab5de
--- /dev/null
+++ b/src/lib/daemon_run.c
@@ -0,0 +1,52 @@
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20/**
21 * @file lib/daemon_run.c
22 * @brief generic function to run event loop of a daemon
23 * @author Christian Grothoff
24 */
25#include "internal.h"
26
27
28/**
29 * Run webserver operations (without blocking unless in client
30 * callbacks). This method should be called by clients in combination
31 * with #MHD_get_fdset if the client-controlled select method is used
32 * and #MHD_get_timeout().
33 *
34 * This function is a convenience method, which is useful if the
35 * fd_sets from #MHD_get_fdset were not directly passed to `select()`;
36 * with this function, MHD will internally do the appropriate `select()`
37 * call itself again. While it is always safe to call #MHD_run (if
38 * #MHD_USE_INTERNAL_POLLING_THREAD is not set), you should call
39 * #MHD_run_from_select if performance is important (as it saves an
40 * expensive call to `select()`).
41 *
42 * @param daemon daemon to run
43 * @return #MHD_SC_OK on success
44 * @ingroup event
45 */
46enum MHD_StatusCode
47MHD_daemon_run (struct MHD_Daemon *daemon)
48{
49 return -1;
50}
51
52/* end of daemon_run.c */
diff --git a/src/lib/daemon_run_from_select.c b/src/lib/daemon_run_from_select.c
new file mode 100644
index 00000000..b8063f79
--- /dev/null
+++ b/src/lib/daemon_run_from_select.c
@@ -0,0 +1,59 @@
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20/**
21 * @file lib/daemon_run_from_select.c
22 * @brief functions to run select-based event loop
23 * @author Christian Grothoff
24 */
25#include "internal.h"
26
27
28/**
29 * Run webserver operations. This method should be called by clients
30 * in combination with #MHD_get_fdset and #MHD_get_timeout() if the
31 * client-controlled select method is used.
32 *
33 * You can use this function instead of #MHD_run if you called
34 * `select()` on the result from #MHD_get_fdset. File descriptors in
35 * the sets that are not controlled by MHD will be ignored. Calling
36 * this function instead of #MHD_run is more efficient as MHD will not
37 * have to call `select()` again to determine which operations are
38 * ready.
39 *
40 * This function cannot be used with daemon started with
41 * #MHD_USE_INTERNAL_POLLING_THREAD flag.
42 *
43 * @param daemon daemon to run select loop for
44 * @param read_fd_set read set
45 * @param write_fd_set write set
46 * @param except_fd_set except set
47 * @return #MHD_SC_OK on success
48 * @ingroup event
49 */
50enum MHD_StatusCode
51MHD_daemon_run_from_select (struct MHD_Daemon *daemon,
52 const fd_set *read_fd_set,
53 const fd_set *write_fd_set,
54 const fd_set *except_fd_set)
55{
56 return -1;
57}
58
59/* end of daemon_run_from_select.c */
diff --git a/src/lib/daemon_start.c b/src/lib/daemon_start.c
index ab4a6dd9..b0b1f3c3 100644
--- a/src/lib/daemon_start.c
+++ b/src/lib/daemon_start.c
@@ -18,7 +18,7 @@
18*/ 18*/
19 19
20/** 20/**
21 * @file lib/daemon.c 21 * @file lib/daemon_start.c
22 * @brief functions to start a daemon 22 * @brief functions to start a daemon
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
@@ -958,5 +958,4 @@ MHD_daemon_start (struct MHD_Daemon *daemon)
958} 958}
959 959
960 960
961 961/* end of daemon_start.c */
962/* end of daemon.c */
diff --git a/src/lib/internal.c b/src/lib/internal.c
index 4ea0503d..ea7600c3 100644
--- a/src/lib/internal.c
+++ b/src/lib/internal.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 Copyright (C) 2007 Daniel Pittman and Christian Grothoff 3 Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
@@ -23,7 +23,6 @@
23 * @author Daniel Pittman 23 * @author Daniel Pittman
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
27#include "internal.h" 26#include "internal.h"
28#include "mhd_str.h" 27#include "mhd_str.h"
29 28
diff --git a/src/lib/memorypool.c b/src/lib/memorypool.c
index bda45e1e..8ef1e2d1 100644
--- a/src/lib/memorypool.c
+++ b/src/lib/memorypool.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 Copyright (C) 2007, 2009, 2010 Daniel Pittman and Christian Grothoff 3 Copyright (C) 2007, 2009, 2010, 2018 Christian Grothoff
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
@@ -71,9 +71,9 @@ struct MemoryPool
71 size_t end; 71 size_t end;
72 72
73 /** 73 /**
74 * #MHD_NO if pool was malloc'ed, #MHD_YES if mmapped (VirtualAlloc'ed for W32). 74 * false if pool was malloc'ed, true if mmapped (VirtualAlloc'ed for W32).
75 */ 75 */
76 int is_mmap; 76 bool is_mmap;
77}; 77};
78 78
79 79
@@ -135,11 +135,11 @@ MHD_pool_create (size_t max)
135 free (pool); 135 free (pool);
136 return NULL; 136 return NULL;
137 } 137 }
138 pool->is_mmap = MHD_NO; 138 pool->is_mmap = false;
139 } 139 }
140 else 140 else
141 { 141 {
142 pool->is_mmap = MHD_YES; 142 pool->is_mmap = true;
143 } 143 }
144 pool->pos = 0; 144 pool->pos = 0;
145 pool->end = max; 145 pool->end = max;
@@ -158,7 +158,7 @@ MHD_pool_destroy (struct MemoryPool *pool)
158{ 158{
159 if (NULL == pool) 159 if (NULL == pool)
160 return; 160 return;
161 if (MHD_NO == pool->is_mmap) 161 if (! pool->is_mmap)
162 free (pool->memory); 162 free (pool->memory);
163 else 163 else
164#if defined(MAP_ANONYMOUS) && !defined(_WIN32) 164#if defined(MAP_ANONYMOUS) && !defined(_WIN32)