X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=include%2Fatalk%2Fserver_child.h;h=27ee305c7c85037058c4b04b655bc62a0a497d34;hb=3a84db87064922ad10ac10cc1d6833380e575995;hp=a86a756895b7e63135cc0cd58be8f13d3bca95c3;hpb=5737d08e3c85485df6ad56d7be7423d6309e9b94;p=netatalk.git diff --git a/include/atalk/server_child.h b/include/atalk/server_child.h index a86a7568..27ee305c 100644 --- a/include/atalk/server_child.h +++ b/include/atalk/server_child.h @@ -8,47 +8,50 @@ #include #include +#include /* useful stuff for child processes. most of this is hidden in * server_child.c to ease changes in implementation */ -#define CHILD_NFORKS 2 -#define CHILD_ASPFORK 0 -#define CHILD_PAPFORK 0 -#define CHILD_DSIFORK 1 - -typedef struct server_child { - void *fork; - int count, nsessions, nforks; -} server_child; - -typedef struct server_child_data { - pid_t pid; /* afpd worker process pid (from the worker afpd process )*/ - uid_t uid; /* user id of connected client (from the worker afpd process) */ - int valid; /* 1 if we have a clientid */ - int killed; /* 1 if we already tried to kill the client */ - int disasociated; /* 1 if this is not a child, but a child from a previous afpd master */ - uint32_t time; /* client boot time (from the mac client) */ - uint32_t idlen; /* clientid len (from the Mac client) */ - char *clientid; /* clientid (from the Mac client) */ - int ipc_fds[2]; /* socketpair for IPC bw */ - struct server_child_data **prevp, *next; +#define CHILD_HASHSIZE 32 + +/* One AFP session child process */ +typedef struct afp_child { + pid_t afpch_pid; /* afpd worker process pid (from the worker afpd process )*/ + uid_t afpch_uid; /* user id of connected client (from the worker afpd process) */ + int afpch_valid; /* 1 if we have a clientid */ + int afpch_killed; /* 1 if we already tried to kill the client */ + uint32_t afpch_boottime; /* client boot time (from the mac client) */ + time_t afpch_logintime; /* time the child was added */ + uint32_t afpch_idlen; /* clientid len (from the Mac client) */ + char *afpch_clientid; /* clientid (from the Mac client) */ + int afpch_ipc_fd; /* socket for IPC bw afpd parent and childs */ + int16_t afpch_state; /* state of AFP session (eg active, sleeping, disconnected) */ + char *afpch_volumes; /* mounted volumes */ + struct afp_child **afpch_prevp; + struct afp_child *afpch_next; } afp_child_t; -extern int parent_or_child; +/* Info and table with all AFP session child processes */ +typedef struct { + pthread_mutex_t servch_lock; /* Lock */ + int servch_count; /* Current count of active AFP sessions */ + int servch_nsessions; /* Number of allowed AFP sessions */ + afp_child_t *servch_table[CHILD_HASHSIZE]; /* Hashtable with data of AFP sesssions */ +} server_child_t; /* server_child.c */ -extern server_child *server_child_alloc (const int, const int); -extern afp_child_t *server_child_add (server_child *, int, pid_t, uint ipc_fds[2]); -extern int server_child_remove (server_child *, const int, const pid_t); -extern void server_child_free (server_child *); - -extern void server_child_kill (server_child *, const int, const int); -extern void server_child_kill_one_by_id (server_child *children, const int forkid, const pid_t pid, const uid_t, - const uint32_t len, char *id, uint32_t boottime); -extern int server_child_transfer_session(server_child *children, int forkid, pid_t, uid_t, int, uint16_t); -extern void server_child_setup (server_child *, const int, void (*)(const pid_t)); -extern void server_child_handler (server_child *); -extern void server_reset_signal (void); +extern server_child_t *server_child_alloc(int); +extern afp_child_t *server_child_add(server_child_t *, pid_t, int ipc_fd); +extern int server_child_remove(server_child_t *, pid_t); +extern void server_child_free(server_child_t *); +extern afp_child_t *server_child_resolve(server_child_t *childs, id_t pid); + +extern void server_child_kill(server_child_t *, int); +extern void server_child_kill_one_by_id(server_child_t *children, pid_t pid, uid_t, + uint32_t len, char *id, uint32_t boottime); +extern int server_child_transfer_session(server_child_t *children, pid_t, uid_t, int, uint16_t); +extern void server_child_handler(server_child_t *); +extern void server_reset_signal(void); #endif