conn_timeout.h (3761B)
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) 2025 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_timeout.h 41 * @brief The declarations of connection timeout handling functions 42 * @author Karlson2k (Evgeny Grin) 43 */ 44 45 #ifndef MHD_CONN_TIMEOUT_H 46 #define MHD_CONN_TIMEOUT_H 1 47 48 #include "mhd_sys_options.h" 49 50 #include "sys_bool_type.h" 51 #include "sys_base_types.h" 52 53 struct MHD_Connection; /* Forward declaration */ 54 55 56 /** 57 * Get number of milliseconds before connection will time out. 58 * @param c the connection to check 59 * @return zero if connection is timed out already, 60 * number of millisecond left before connection will time out, 61 * #UINT64_MAX if connection has no time out 62 */ 63 MHD_INTERNAL uint_fast64_t 64 mhd_conn_get_timeout_left (const struct MHD_Connection *restrict c, 65 uint_fast64_t cur_milsec) 66 MHD_FN_PAR_NONNULL_ALL_; 67 68 69 /** 70 * Check whether connection's timeout is expired. 71 * @param c the connection to check 72 * @return 'true' if connection timeout expired and the connection needs to be 73 * closed, 74 * 'false' otherwise 75 */ 76 MHD_INTERNAL bool 77 mhd_conn_is_timeout_expired (struct MHD_Connection *restrict c) 78 MHD_FN_PAR_NONNULL_ALL_; 79 80 /** 81 * Initialise activity timeout data. 82 * Add connection to the timeouts list if needed; set activity mark, if needed. 83 * @param c the connection to initialise 84 * @param timeout the connection timeout value to use 85 */ 86 MHD_INTERNAL void 87 mhd_conn_init_activity_timeout (struct MHD_Connection *restrict c, 88 uint_fast32_t timeout) 89 MHD_FN_PAR_NONNULL_ALL_; 90 91 92 /** 93 * Remove connection from time-out lists 94 * @param c the connection to process 95 */ 96 MHD_INTERNAL void 97 mhd_conn_deinit_activity_timeout (struct MHD_Connection *restrict c) 98 MHD_FN_PAR_NONNULL_ALL_; 99 100 101 /** 102 * Update last activity mark to the current time. 103 * @param c the connection to update 104 */ 105 MHD_INTERNAL void 106 mhd_conn_update_activity_mark (struct MHD_Connection *restrict c) 107 MHD_FN_PAR_NONNULL_ALL_; 108 109 #endif /* ! MHD_CONN_TIMEOUT_H */