diff options
Diffstat (limited to 'src/pies.h')
-rw-r--r-- | src/pies.h | 60 |
1 files changed, 48 insertions, 12 deletions
@@ -1,5 +1,5 @@ /* This file is part of GNU Pies. - Copyright (C) 2008-2020 Sergey Poznyakoff + Copyright (C) 2008-2023 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -58,6 +58,7 @@ #include "libpies.h" #include "envop.h" #include "grecs/json.h" +#include "pies_syslog.h" #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) @@ -98,10 +99,15 @@ enum return_action #define STATUS_SIG_BIT 0x80000000 #define STATUS_CODE(c) ((c) & ~STATUS_SIG_BIT) +struct status_cond +{ + unsigned status; + int neg; +}; + struct action { - size_t nstat; - unsigned *status; + struct grecs_list *cond_list; /* List of status conditions. */ enum return_action act; /* Action to take when the component terminates */ char *addr; /* Addresses to notify about it. */ char *message; /* Notification mail. */ @@ -209,6 +215,8 @@ enum pies_comp_mode #define CF_SIGGROUP 0x100 /* Send signals to the process group */ #define CF_NULLINPUT 0x200 /* Provide null input stream */ #define CF_SHELL 0x400 /* Invoke via sh -c */ +#define CF_EXPANDENV 0x800 /* Expand environment variables in the command + line */ #define CF_REMOVE 0xf000 /* Marked for removal */ @@ -241,6 +249,8 @@ struct component struct pies_privs privs; /* UID/GIDS+groups to run as */ mode_t umask; /* Umask to install before starting */ limits_record_t limits; /* System limits */ + int sigterm; /* Signal to terminate the process */ + unsigned long shutdown_seqno; /* Shutdown sequence number */ /* For exec (init) components */ char *runlevels; @@ -267,7 +277,6 @@ struct component char *max_ip_connections_message; /* Redirectors: */ - int facility; /* Syslog facility. */ struct redirector redir[2]; /* Repeaters for stdout and stderr */ /* Actions to execute on various exit codes: */ struct grecs_list *act_list; @@ -294,8 +303,6 @@ enum pies_action { }; extern char *instance; -extern char *log_tag; -extern int log_facility; extern unsigned long shutdown_timeout; extern struct component default_component; extern pies_acl_t pies_acl; @@ -336,7 +343,8 @@ void config_file_remove_all (void); void free_redirector (struct redirector *rp); void pies_schedule_action (int act); -void free_action (struct action *act); + +void listel_dispose (void *el); void argv_free (char **argv); @@ -358,7 +366,11 @@ void progman_start (void); void progman_gc (void); void progman_wake_sleeping (int); void progman_stop (void); -void progman_cleanup (int expect_term); + +#define CLEANUP_DEFAULT 0 +#define CLEANUP_EXPECT_TERM 1 + +void progman_cleanup (int flags); void progman_filter (int (*filter) (struct component *, void *data), void *data); int progman_accept (int socket, void *data); @@ -378,8 +390,8 @@ int check_acl (pies_acl_t acl, struct sockaddr *s, socklen_t salen, pies_identity_t identity); void log_setup (int want_stderr); -void signal_setup (RETSIGTYPE (*sf)(int)); -void setsigvhan (RETSIGTYPE (*handler) (int signo), int *sigv, int sigc); +void signal_setup (void (*sf)(int)); +void setsigvhan (void (*handler) (int signo), int *sigv, int sigc); void add_extra_sigv (int *sigv, int sigc); typedef struct pies_depmap *pies_depmap_t; @@ -392,6 +404,8 @@ enum pies_depmap_direction pies_depmap_t depmap_alloc (size_t count); pies_depmap_t depmap_copy (pies_depmap_t dpm); +size_t depmap_dim (struct pies_depmap *dmap); +void depmap_free (pies_depmap_t dmap); void depmap_set (pies_depmap_t dmap, size_t row, size_t col); int depmap_isset (pies_depmap_t dmap, size_t row, size_t col); void depmap_clear (pies_depmap_t dmap, size_t row, size_t col); @@ -403,6 +417,23 @@ size_t depmap_first (pies_depmap_t dmap, enum pies_depmap_direction dir, size_t depmap_next (pies_depmap_t dmap, pies_depmap_pos_t pos); void depmap_end (pies_depmap_pos_t pos); + +struct depmap_path_elem +{ + int idx; + struct depmap_path_elem *next; +}; + +struct depmap_path +{ + size_t len; + struct depmap_path_elem *head, *tail; + struct depmap_path *next; +}; + +void depmap_path_free (struct depmap_path *path); +struct depmap_path *depmap_cycle_detect (pies_depmap_t dmap); + int assert_grecs_value_type (grecs_locus_t *locus, const grecs_value_t *value, int type); @@ -429,6 +460,8 @@ int component_foreach (int (*filter) (struct component *, void *), void components_dump_depmap (void); void components_trace (char **argv, enum pies_depmap_direction dir); +void components_list_shutdown_sequence (void); +size_t components_shutdown_sequence_numbers (unsigned long **ret); struct component *component_depmap_first (enum pies_depmap_direction dir, size_t idx, pies_depmap_pos_t *ppos); @@ -452,11 +485,13 @@ void *register_socket (int fd, socket_handler_t rd, socket_handler_t wr, socket_handler_t ex, - void *data); + void *data, + void (*free_data)(void*)); void deregister_socket (int fd); void update_socket (int fd, int evt, socket_handler_t f); -int register_program_socket (int socktype, int fd, void *data); +int register_program_socket (int socktype, int fd, void *data, + void (*free_data)(void*)); int pass_fd (const char *socket, int fd, unsigned time_out); int create_socket (struct pies_url *url, int socket_type, const char *user, mode_t umask); @@ -501,6 +536,7 @@ void diag_setup (int flags); void diagmsg (int logf, int prio, const char *fmt, ...) PIES_PRINTFLIKE(3,4); +void vlogmsg (int prio, const char *fmt, va_list ap); void logmsg (int prio, const char *fmt, ...) PIES_PRINTFLIKE(2,3); void logmsg_printf (int prio, const char *fmt, ...) PIES_PRINTFLIKE(2,3); void logmsg_vprintf (int prio, const char *fmt, va_list ap); |