summaryrefslogtreecommitdiffstats
path: root/src/ipc/ipc-group.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:36:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:36:47 +0000
commit0441d265f2bb9da249c7abf333f0f771fadb4ab5 (patch)
tree3f3789daa2f6db22da6e55e92bee0062a7d613fe /src/ipc/ipc-group.h
parentInitial commit. (diff)
downloaddovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.tar.xz
dovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.zip
Adding upstream version 1:2.3.21+dfsg1.upstream/1%2.3.21+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ipc/ipc-group.h')
-rw-r--r--src/ipc/ipc-group.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/ipc/ipc-group.h b/src/ipc/ipc-group.h
new file mode 100644
index 0000000..c993f5a
--- /dev/null
+++ b/src/ipc/ipc-group.h
@@ -0,0 +1,45 @@
+#ifndef IPC_GROUP_H
+#define IPC_GROUP_H
+
+enum ipc_cmd_status {
+ /* Command received a reply line */
+ IPC_CMD_STATUS_REPLY,
+ /* Command finished successfully */
+ IPC_CMD_STATUS_OK,
+ /* Command finished with errors */
+ IPC_CMD_STATUS_ERROR
+};
+
+struct ipc_group {
+ int listen_fd;
+ char *name;
+
+ /* connections list also acts as a refcount */
+ struct ipc_connection *connections;
+};
+
+/* line is non-NULL only with IPC_CMD_STATUS_REPLY.
+ Each line begins with the connection ID and TAB. */
+typedef void ipc_cmd_callback_t(enum ipc_cmd_status status,
+ const char *line, void *context);
+
+struct ipc_group *ipc_group_alloc(int listen_fd);
+void ipc_group_free(struct ipc_group **group);
+
+struct ipc_group *ipc_group_lookup_listen_fd(int listen_fd);
+struct ipc_group *ipc_group_lookup_name(const char *name);
+
+/* Returns 0 if name is ok, -1 if name doesn't match the existing one. */
+int ipc_group_update_name(struct ipc_group *group, const char *name);
+
+/* Send a command to all connections in a group. All connections are expected
+ to answer something. If there are no connections, callback() is called
+ immediately and FALSE is returned. */
+bool ipc_group_cmd(struct ipc_group *group, const char *cmd,
+ ipc_cmd_callback_t *callback, void *context);
+
+void ipc_groups_init(void);
+void ipc_groups_deinit(void);
+void ipc_groups_disconnect_all(void);
+
+#endif