Commits


use memset(3) rather than bzero(3) There's no difference, but bzero(3) says STANDARDS The bzero() function conforms to the X/Open System Interfaces option of the IEEE Std 1003.1-2004 (“POSIX.1”) specification. It was removed from the standard in IEEE Std 1003.1-2008 (“POSIX.1”), which recommends using memset(3) instead. so here we are.


don't crash if -n is given without -c If -n is given without -c, config_path is still NULL and it would crash due to a NULL deference.


unbreak configless mode An un-initialized field in the configless code path leads to a crash on the first request.


move parse_portno to gmid.c it's used only to parse the -p flag. While there add check_port_num to check the range for the port.


style(9)-ify


initialize the logger early Initialize the logger as soon as possible and log by default to stderr. With this, some (common?) errors are printed early instead of ending up in syslog. # NB: this is in configless mode % ./gmid -p 80 [2021-07-07 11:05:57] bind: Address already in use % ./gmid -p 81 [2021-07-07 11:13:53] bind: Permission denied %


gracefully shut down fastcgi backends we need to delete the events associated with the backends, otherwise the server process won't ever quit. Here, we add a pending counter to every backend and shut down immediately if they aren't handling any client; otherwise we try to close them as soon as possible (i.e. when they close the connection to the last connected client.)


reset fcgi array in free_config otherwise path, port and/or prog could become an invalid pointer.


add -D to define macros from the cmd line


sync the usage; while there also change order and capitalize


define GMID_STRING and reuse-it GMID_VERSION follows the CGI/FastCGI style, i.e. project_name/version. Define GMID_STRING with a more "human" variant "project_name version", and reuse that in the --help and --version codepath.


add version in usage


use getprogname() in usage()


use getopt_long, add --help as synonym of -h and -V/--version


allow sending fd to log on to the logger process the logger process now can receive a file descriptor to write logs to. At the moment the logic is simple, if it receives a file it logs there, otherwise it logs to syslog. This will allow to log on custom log files.