functions to handle child processes More...
#include <errno.h>#include <pthread.h>#include <signal.h>#include <stdlib.h>#include <string.h>#include <sys/time.h>#include <sys/types.h>#include <sys/wait.h>#include <unistd.h>#include <atalk/compat.h>#include <atalk/constant_time.h>#include <atalk/errchk.h>#include <atalk/logger.h>#include <atalk/server_child.h>#include <atalk/util.h>Macros | |
| #define | WEXITSTATUS(stat_val) |
| #define | WIFEXITED(stat_val) |
| #define | WIFSTOPPED(status) |
| #define | WIFSIGNALED(status) |
| #define | WTERMSIG(status) |
| #define | HASH(i) |
Functions | |
| static void | hash_child (afp_child_t **htable, afp_child_t *child) |
| static void | unhash_child (afp_child_t *child) |
| afp_child_t * | server_child_resolve (server_child_t *childs, id_t pid) |
| server_child_t * | server_child_alloc (int connections) |
| afp_child_t * | server_child_add (server_child_t *children, pid_t pid, int ipc_fd, int hint_fd) |
| add a child | |
| int | server_child_remove (server_child_t *children, pid_t pid) |
| void | server_child_free (server_child_t *children) |
| free everything | |
| void | server_child_kill (server_child_t *children, int sig) |
| static int | kill_child (afp_child_t *child) |
| int | server_child_set_session_token (server_child_t *children, pid_t pid, uid_t uid, const void *token, size_t token_len) |
| Store an opaque reconnect token for a child session. | |
| int | server_child_transfer_session (server_child_t *children, uid_t uid, const void *token, size_t token_len, int afp_socket, uint16_t DSI_requestID) |
| Try to find an old session and pass socket. | |
| void | server_child_kill_one_by_id (server_child_t *children, pid_t pid, uid_t uid, uint32_t idlen, char *id, uint32_t boottime) |
| see if there is a process for the same mac | |
| void | server_child_login_done (server_child_t *children, pid_t pid, uid_t uid, const char *client_address) |
| void | server_reset_signal (void) |
functions to handle child processes
handle inserting, removing, and freeing of children. this does it via a hash table. it incurs some overhead over a linear append/remove in total removal and kills, but it makes single-entry removals a fast operation. as total removals occur during child initialization and kills during server shutdown, this is probably a win for a lot of connections and unimportant for a small number of connections.
| #define HASH | ( | i | ) |
| #define WEXITSTATUS | ( | stat_val | ) |
| #define WIFEXITED | ( | stat_val | ) |
| #define WIFSIGNALED | ( | status | ) |
|
inlinestatic |
|
static |
send kill to a child processes
| afp_child_t * server_child_add | ( | server_child_t * | children, |
| pid_t | pid, | ||
| int | ipc_fd, | ||
| int | hint_fd ) |
add a child
| server_child_t * server_child_alloc | ( | int | connections | ) |
initialize server_child structure
| void server_child_free | ( | server_child_t * | children | ) |
free everything
by using a hash table, this increases the cost of this part over a linked list by the size of the hash table
| void server_child_kill | ( | server_child_t * | children, |
| int | sig ) |
send signal to all child processes
| void server_child_kill_one_by_id | ( | server_child_t * | children, |
| pid_t | pid, | ||
| uid_t | uid, | ||
| uint32_t | idlen, | ||
| char * | id, | ||
| uint32_t | boottime ) |
see if there is a process for the same mac
if the times don't match mac has been rebooted
| void server_child_login_done | ( | server_child_t * | children, |
| pid_t | pid, | ||
| uid_t | uid, | ||
| const char * | client_address ) |
| int server_child_remove | ( | server_child_t * | children, |
| pid_t | pid ) |
remove a child and free it
| afp_child_t * server_child_resolve | ( | server_child_t * | childs, |
| id_t | pid ) |
| int server_child_set_session_token | ( | server_child_t * | children, |
| pid_t | pid, | ||
| uid_t | uid, | ||
| const void * | token, | ||
| size_t | token_len ) |
Store an opaque reconnect token for a child session.
| int server_child_transfer_session | ( | server_child_t * | children, |
| uid_t | uid, | ||
| const void * | token, | ||
| size_t | token_len, | ||
| int | afp_socket, | ||
| uint16_t | DSI_requestID ) |
Try to find an old session and pass socket.
| void server_reset_signal | ( | void | ) |
reset children signals
|
inlinestatic |