*/
#include "daemon/defer.h"
-#include "daemon/mmapped.h"
#include "daemon/session2.h"
#include "daemon/udp_queue.h"
#include "lib/kru.h"
+#include "lib/mmapped.h"
#include "lib/utils.h"
#define V4_PREFIXES (uint8_t[]) { 18, 20, 24, 32 }
'ffimodule.c',
'io.c',
'main.c',
- 'mmapped.c',
'network.c',
'proxyv2.c',
'ratelimiting.c',
c_src_lint += kresd_src
unit_tests += [
- ['ratelimiting', files('ratelimiting.test/tests.c', 'mmapped.c') + libkres_src ],
+ ['ratelimiting', files('ratelimiting.test/tests.c') + libkres_src ],
# parallel tests timeouts under valgrind; they checks mainly for race conditions, which is not needed there
- ['ratelimiting-parallel', files('ratelimiting.test/tests-parallel.c', 'mmapped.c') + libkres_src, ['skip_valgrind']]
+ ['ratelimiting-parallel', files('ratelimiting.test/tests-parallel.c') + libkres_src, ['skip_valgrind']]
]
config_tests += [
#include <stdatomic.h>
#include "daemon/ratelimiting.h"
-#include "daemon/mmapped.h"
#include "lib/kru.h"
+#include "lib/mmapped.h"
#include "lib/utils.h"
#include "lib/resolve.h"
'layer/iterate.c',
'layer/validate.c',
'log.c',
+ 'mmapped.c',
'proto.c',
'rules/api.c',
'rules/defaults.c',
'layer.h',
'layer/iterate.h',
'log.h',
+ 'mmapped.h',
'module.h',
'proto.h',
'resolve.h',
#include <errno.h>
#include <string.h>
-#include "daemon/mmapped.h"
+#include "lib/mmapped.h"
#include "lib/utils.h"
static inline bool fcntl_flock_whole(int fd, short int type, bool wait)
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#include <stdbool.h>
+#include "lib/defines.h"
#define MMAPPED_WAS_FIRST 1
* you should finish initialization and call mmapped_init_continue to degrade flock to shared.
* Otherwise, it waits for shared flock, calls mmap, verifies that header is byte-wise identical and returns zero.
* On header mismatch, kr_error(ENOTRECOVERABLE) is returned; on a system error, kr_error(errno) is returned. */
+KR_EXPORT
int mmapped_init(struct mmapped *mmapped, const char *mmap_file, size_t size, void *header, size_t header_size);
/* Degrade flock to shared after getting MMAPPED_WAS_FIRST from mmapped_init.
*
* Returns zero on success and kr_error(errno) on system error. */
+KR_EXPORT
int mmapped_init_continue(struct mmapped *mmapped);
/* Free mmapped memory and, unless the underlying file is used by other processes, truncate it to zero size. */
+KR_EXPORT
void mmapped_deinit(struct mmapped *mmapped);