summaryrefslogtreecommitdiffstats
path: root/src/libknot/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/libknot/control')
-rw-r--r--src/libknot/control/control.c12
-rw-r--r--src/libknot/control/control.h7
2 files changed, 15 insertions, 4 deletions
diff --git a/src/libknot/control/control.c b/src/libknot/control/control.c
index 8656057..671896f 100644
--- a/src/libknot/control/control.c
+++ b/src/libknot/control/control.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2024 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -37,7 +37,7 @@
#endif
/*! Listen backlog size. */
-#define LISTEN_BACKLOG 5
+#define DEFAULT_LISTEN_BACKLOG 5
/*! Default socket operations timeout in milliseconds. */
#define DEFAULT_TIMEOUT (30 * 1000)
@@ -196,6 +196,12 @@ void knot_ctl_set_timeout(knot_ctl_t *ctx, int timeout_ms)
_public_
int knot_ctl_bind(knot_ctl_t *ctx, const char *path)
{
+ return knot_ctl_bind2(ctx, path, DEFAULT_LISTEN_BACKLOG);
+}
+
+_public_
+int knot_ctl_bind2(knot_ctl_t *ctx, const char *path, unsigned backlog)
+{
if (ctx == NULL || path == NULL) {
return KNOT_EINVAL;
}
@@ -215,7 +221,7 @@ int knot_ctl_bind(knot_ctl_t *ctx, const char *path)
}
// Start listening.
- if (listen(ctx->listen_sock, LISTEN_BACKLOG) != 0) {
+ if (listen(ctx->listen_sock, backlog) != 0) {
close_sock(&ctx->listen_sock);
return knot_map_errno();
}
diff --git a/src/libknot/control/control.h b/src/libknot/control/control.h
index 1d3dcd1..8ab1e10 100644
--- a/src/libknot/control/control.h
+++ b/src/libknot/control/control.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2024 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -94,6 +94,11 @@ void knot_ctl_set_timeout(knot_ctl_t *ctx, int timeout_ms);
int knot_ctl_bind(knot_ctl_t *ctx, const char *path);
/*!
+ * Same as knot_ctl_bind() with socket backlog specification.
+ */
+int knot_ctl_bind2(knot_ctl_t *ctx, const char *path, unsigned backlog);
+
+/*!
* Unbinds a control socket.
*
* \note Server operation.