netatalk  4.6.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
server_ipc.h
Go to the documentation of this file.
1#ifndef ATALK_SERVER_IPC_H
2#define ATALK_SERVER_IPC_H
3
4#include <stdint.h>
5
6#include <atalk/cnid.h>
7#include <atalk/globals.h>
9
10/* IPC wire format constants — moved from server_ipc.c so receivers (Eg dircache.c)
11 * can parse the wire format. 14-byte header: cmd(2) + pid(4) + uid(4) + len(4) */
12#define IPC_HEADERLEN 14
13#define IPC_MAXMSGSIZE 90
14
15/* Remember to add IPC commands to server_ipc.c:ipc_cmd_str[] */
16#define IPC_DISCOLDSESSION 0
17#define IPC_GETSESSION 1
18#define IPC_STATE 2
19#define IPC_VOLUMES 3
20#define IPC_LOGINDONE 4
21#define IPC_CACHE_HINT 5
22#define IPC_SESSIONTOKEN 6
23
24/* Cache hint types — carried in struct ipc_cache_hint_payload.event */
25#define CACHE_HINT_REFRESH 0
26#define CACHE_HINT_DELETE 1
27#define CACHE_HINT_DELETE_CHILDREN 2
28#define CACHE_HINT_VOLUME_RESET 3
29#define CACHE_HINT_COUNT 4
30
31/* Hint payload — sent inside standard IPC wire header framing.
32 * Packed to guarantee sizeof == 8. vid and cnid in network byte order. */
33struct __attribute__((packed)) ipc_cache_hint_payload {
34 uint8_t event; /* Hint type: one of the CACHE_HINT_* values */
35 uint8_t reserved; /* Alignment padding (could be version field in future) */
36 uint16_t vid; /* Volume ID — network byte order (matches vol->v_vid) */
37 cnid_t cnid; /* CNID of affected file/dir — network byte order */
38};
39
40_Static_assert(sizeof(struct ipc_cache_hint_payload) == 8,
41 "Hint payload must be exactly 8 bytes");
42
43/* Every event is validated against CACHE_HINT_COUNT, then used as an index */
48 "CACHE_HINT_COUNT must cover every CACHE_HINT_* value");
49
50/* Hint buffer capacity — main.c checks this to trigger immediate flush
51 * when buffer is full after fd event processing. */
52#define HINT_BUF_SIZE 128
53
54/* Flush interval for poll timeout — main.c uses this to set poll timeout
55 * when hints are buffered. 50ms balances latency vs syscall overhead. */
56#define HINT_FLUSH_INTERVAL_MS 50
57
58extern int ipc_server_read(server_child_t *children, int fd);
59extern int ipc_child_write(AFPObj *obj, uint16_t command, size_t len,
60 void *token);
61extern int ipc_child_state(AFPObj *obj, uint16_t state);
62
63extern int ipc_send_cache_hint(const AFPObj *obj, uint16_t vid, cnid_t cnid,
64 uint8_t event);
65extern unsigned long long ipc_get_hints_sent(void);
66extern unsigned long long ipc_get_hints_dropped(void);
67
68/* Poll-driven hint flush API (parent-side only, single-threaded) */
69extern void hint_flush_pending(server_child_t *children);
70extern int hint_buf_count(void);
71
72#endif /* ATALK_SERVER_IPC_H */
uint32_t cnid_t
Definition adouble.h:157
data structures and utility functions for child processes
int ipc_server_read(server_child_t *children, int fd)
Read a IPC message from a child.
Definition server_ipc.c:543
int ipc_send_cache_hint(const AFPObj *obj, uint16_t vid, cnid_t cnid, uint8_t event)
Send a dircache invalidation hint from child to parent.
Definition server_ipc.c:949
#define CACHE_HINT_REFRESH
Definition server_ipc.h:25
#define CACHE_HINT_COUNT
Definition server_ipc.h:29
int ipc_child_state(AFPObj *obj, uint16_t state)
Definition server_ipc.c:721
#define CACHE_HINT_VOLUME_RESET
Definition server_ipc.h:28
int hint_buf_count(void)
Return current number of buffered hints.
Definition server_ipc.c:737
#define CACHE_HINT_DELETE_CHILDREN
Definition server_ipc.h:27
void hint_flush_pending(server_child_t *children)
Flush all buffered hints to sibling children.
Definition server_ipc.c:760
unsigned long long ipc_get_hints_dropped(void)
Definition server_ipc.c:896
int ipc_child_write(AFPObj *obj, uint16_t command, size_t len, void *token)
Definition server_ipc.c:679
unsigned long long ipc_get_hints_sent(void)
Definition server_ipc.c:891
#define CACHE_HINT_DELETE
Definition server_ipc.h:26
Definition globals.h:190
Definition server_ipc.h:33
uint8_t reserved
Definition server_ipc.h:35
uint8_t event
Definition server_ipc.h:34
cnid_t cnid
Definition server_ipc.h:37
uint16_t vid
Definition server_ipc.h:36
Definition server_child.h:47