daemon_add_conn.h (4275B)
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) 2014-2024 Evgeny Grin (Karlson2k) 5 Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff 6 7 GNU libmicrohttpd is free software; you can redistribute it and/or 8 modify it under the terms of the GNU Lesser General Public 9 License as published by the Free Software Foundation; either 10 version 2.1 of the License, or (at your option) any later version. 11 12 GNU libmicrohttpd is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Lesser General Public License for more details. 16 17 Alternatively, you can redistribute GNU libmicrohttpd and/or 18 modify it under the terms of the GNU General Public License as 19 published by the Free Software Foundation; either version 2 of 20 the License, or (at your option) any later version, together 21 with the eCos exception, as follows: 22 23 As a special exception, if other files instantiate templates or 24 use macros or inline functions from this file, or you compile this 25 file and link it with other works to produce a work based on this 26 file, this file does not by itself cause the resulting work to be 27 covered by the GNU General Public License. However the source code 28 for this file must still be made available in accordance with 29 section (3) of the GNU General Public License v2. 30 31 This exception does not invalidate any other reasons why a work 32 based on this file might be covered by the GNU General Public 33 License. 34 35 You should have received copies of the GNU Lesser General Public 36 License and the GNU General Public License along with this library; 37 if not, see <https://www.gnu.org/licenses/>. 38 */ 39 40 /** 41 * @file src/mhd2/daemon_add_conn.h 42 * @brief The declaration of internal functions for adding new connections 43 * @author Karlson2k (Evgeny Grin) 44 * @author Daniel Pittman 45 * @author Christian Grothoff 46 */ 47 48 #ifndef MHD_DAEMON_ADD_CONN 49 #define MHD_DAEMON_ADD_CONN 1 50 51 #include "mhd_sys_options.h" 52 53 #include "sys_bool_type.h" 54 55 struct MHD_Daemon; /* Forward declaration */ 56 struct MHD_Connection; /* Forward declaration */ 57 58 /** 59 * The result of the accepting of the new connection 60 */ 61 enum mhd_DaemonAcceptResult 62 { 63 /** 64 * New connection has been accepted successfully. 65 * Probably more connections are pending to be accepted. 66 */ 67 mhd_DAEMON_ACCEPT_SUCCESS = 0 68 , 69 /** 70 * New connection has been skipped for some reason. 71 * It is OK to try to accept more connections right now. 72 */ 73 mhd_DAEMON_ACCEPT_SKIPPED = 1 << 0 74 , 75 /** 76 * No more new connections are pending, the listen backlog is empty 77 */ 78 mhd_DAEMON_ACCEPT_NO_MORE_PENDING = 1 << 1 79 , 80 /** 81 * Connection accept failed, but the listen backlog could be not empty. 82 * Do not try to accept more connection right now. 83 */ 84 mhd_DAEMON_ACCEPT_FAILED = 1 << 2 85 }; 86 87 88 /** 89 * Accept an incoming connection and create the MHD_Connection object for 90 * it. This function also enforces policy by way of checking with the 91 * accept policy callback. 92 * @remark To be called only from thread that process 93 * daemon's select()/poll()/etc. 94 * 95 * @param daemon handle with the listen socket 96 * @return a #mhd_DaemonAcceptResult value 97 */ 98 MHD_INTERNAL enum mhd_DaemonAcceptResult 99 mhd_daemon_accept_connection (struct MHD_Daemon *restrict daemon); 100 101 102 /** 103 * Remove all referenced to the connection from the daemon. 104 * Must be performed only when connection thread (for thread-per-connection) 105 * has stopped. 106 * @param c the connection to remove 107 */ 108 MHD_INTERNAL void 109 mhd_conn_remove_from_daemon (struct MHD_Connection *restrict c) 110 MHD_FN_PAR_NONNULL_ALL_; 111 112 113 /** 114 * Finally close and deallocate connection. 115 * Must be performed only when connection thread (for thread-per-connection) 116 * has stopped. 117 * The connection data deallocated by this function and cannot be used anymore. 118 * This function must be the last function called for connection object. 119 * @param c the connection to close 120 */ 121 MHD_INTERNAL void 122 mhd_conn_close_final (struct MHD_Connection *restrict c) 123 MHD_FN_PAR_NONNULL_ALL_; 124 125 126 #endif /* ! MHD_DAEMON_ADD_CONN */