]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
mmapped_* nit: move from daemon/ to lib/ docs-develop-rrl-8r8r8r/deployments/5488
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 4 Nov 2024 14:54:48 +0000 (15:54 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 4 Nov 2024 15:08:02 +0000 (16:08 +0100)
We'll utilize this for cache, so this will be an easy way for GC
to access the mmapped_* symbols.

In lib/ we usually prefix symbols by kr_ but I don't think it's worth
the hassle in this case, as mmapped_ seems like a good enough prefix.

daemon/defer.c
daemon/meson.build
daemon/ratelimiting.c
lib/meson.build
lib/mmapped.c [moved from daemon/mmapped.c with 99% similarity]
lib/mmapped.h [moved from daemon/mmapped.h with 95% similarity]

index 59af3e68932d08454e4f1ce7984c48a48c44d4a3..32b0358c02b0df09f66fa771b18445df60a11f4d 100644 (file)
@@ -3,10 +3,10 @@
  */
 
 #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 }
index a3f95480b2bb7a535564e0aa1abb6ab9fd4d9210..62ac983b761555058f7917557db89edf4d9b08e2 100644 (file)
@@ -13,7 +13,6 @@ kresd_src = files([
   'ffimodule.c',
   'io.c',
   'main.c',
-  'mmapped.c',
   'network.c',
   'proxyv2.c',
   'ratelimiting.c',
@@ -33,10 +32,10 @@ endif
 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 += [
index 528608cf9c7910bbefe938db58ffabe0dbc8acff..29d4c82a0ebba8beabac6ad58429eb93f18ae9ce 100644 (file)
@@ -4,8 +4,8 @@
 
 #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"
 
index e369a4526956cff21ecec9f29f5e9034fc68f04f..94bb80c7313371fbef327083263a563bc3908124 100644 (file)
@@ -25,6 +25,7 @@ libkres_src = files([
   'layer/iterate.c',
   'layer/validate.c',
   'log.c',
+  'mmapped.c',
   'proto.c',
   'rules/api.c',
   'rules/defaults.c',
@@ -63,6 +64,7 @@ libkres_headers = files([
   'layer.h',
   'layer/iterate.h',
   'log.h',
+  'mmapped.h',
   'module.h',
   'proto.h',
   'resolve.h',
similarity index 99%
rename from daemon/mmapped.c
rename to lib/mmapped.c
index 7c6ba099f5c3e2fcfbea87d02e12b5e9872758b5..f37748b78c2b4b8c17e003167dcaa3ec1d18c595 100644 (file)
@@ -7,7 +7,7 @@
 #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)
similarity index 95%
rename from daemon/mmapped.h
rename to lib/mmapped.h
index 2f810376ea12acd44f3095e06417bdf0d160913a..eb542096d28b48fb0f52349396e36558a3af3b48 100644 (file)
@@ -2,7 +2,7 @@
  *  SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#include <stdbool.h>
+#include "lib/defines.h"
 
 #define MMAPPED_WAS_FIRST 1
 
@@ -19,12 +19,15 @@ struct mmapped {
  * 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);