docs(shared): clarify authorized_root accessor contracts
Document on utils_get_authorized_root_path() that the returned pointer is borrowed and invalidated by the next authorized-root setter, that the fd and path are not read atomically (non-reentrant), and that the fd remains caller-owned. Add a matching single-threaded/set-before-threads note at the accessor definitions in utils.c. In server.c, drop the redundant utils_set_authorized_root(-1, NULL) after a failed utils_set_authorized_root(): the setter already fail-closes the state on allocation failure. The following close(root_fd) is unchanged.
This commit is contained in:
@@ -36,6 +36,9 @@ void utils_set_authorized_root_fd(int fd) {
|
||||
(void)utils_set_authorized_root(fd, NULL);
|
||||
}
|
||||
|
||||
/* Accessors for the process-global authorized root. The path pointer is
|
||||
* borrowed and valid until the next setter call; the root is a single-threaded,
|
||||
* set-before-worker-threads value (see server.c), so these carry no locking. */
|
||||
int utils_get_authorized_root_fd(void) {
|
||||
return authorized_root_fd;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user