netatalk  4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
netatalk.c File Reference
#include <errno.h>
#include <poll.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/wait.h>
#include <bstrlib.h>
#include <event2/event.h>
#include <atalk/adouble.h>
#include <atalk/afp.h>
#include <atalk/compat.h>
#include <atalk/dsi.h>
#include <atalk/errchk.h>
#include <atalk/globals.h>
#include <atalk/iniparser_util.h>
#include <atalk/logger.h>
#include <atalk/netatalk_conf.h>
#include <atalk/server_child.h>
#include <atalk/server_ipc.h>
#include <atalk/util.h>
#include "afp_zeroconf.h"

Macros

#define KILL_GRACETIME   5
 
#define NETATALK_SRV_NEEDED   -1
 
#define NETATALK_SRV_OPTIONAL   0
 
#define NETATALK_SRV_ERROR   NETATALK_SRV_NEEDED
 
#define MYARVSIZE   64
 

Functions

static pid_t run_process (const char *path,...)
 
static void kill_childs (int sig,...)
 
static void netatalk_exit (int ret)
 
static bool service_running (pid_t pid)
 
static void libevent_logmsg_cb (int severity, const char *msg)
 
static void sigterm_impl (void)
 
static void sigquit_impl (void)
 
static void sighup_impl (void)
 
static bool sigchld_impl (void)
 
static void timer_impl (void)
 
static void sigterm_cb (evutil_socket_t fd, short what, void *arg)
 
static void sigquit_cb (evutil_socket_t fd, short what, void *arg)
 
static void sighup_cb (evutil_socket_t fd, short what, void *arg)
 
static void sigchld_cb (evutil_socket_t fd, short what, void *arg)
 
static void timer_cb (evutil_socket_t fd, short what, void *arg)
 
static void show_netatalk_version (void)
 
static void show_netatalk_paths (void)
 
static void usage (void)
 
int main (int argc, char **argv)
 

Variables

static AFPObj obj
 
static pid_t afpd_pid = NETATALK_SRV_NEEDED
 
static pid_t cnid_metad_pid = NETATALK_SRV_OPTIONAL
 
static pid_t dbus_pid = NETATALK_SRV_OPTIONAL
 
static uint afpd_restarts
 
static uint cnid_metad_restarts
 
static uint dbus_restarts
 
static struct event_base * base
 
struct event * sigterm_ev
 
struct event * sigquit_ev
 
struct event * sigchld_ev
 
struct event * sighup_ev
 
struct event * timer_ev
 
static int in_shutdown
 
static const char * dbus_path
 

Macro Definition Documentation

◆ KILL_GRACETIME

#define KILL_GRACETIME   5

how many seconds we wait to shutdown from SIGTERM before we send SIGKILL

◆ MYARVSIZE

#define MYARVSIZE   64

◆ NETATALK_SRV_ERROR

#define NETATALK_SRV_ERROR   NETATALK_SRV_NEEDED

◆ NETATALK_SRV_NEEDED

#define NETATALK_SRV_NEEDED   -1

◆ NETATALK_SRV_OPTIONAL

#define NETATALK_SRV_OPTIONAL   0

Function Documentation

◆ kill_childs()

static void kill_childs ( int  sig,
  ... 
)
static

kill processes passed as varargs of type "pid_t *", terminate list with NULL

◆ libevent_logmsg_cb()

static void libevent_logmsg_cb ( int  severity,
const char *  msg 
)
static

libevent logging callback

◆ main()

int main ( int  argc,
char **  argv 
)

◆ netatalk_exit()

static void netatalk_exit ( int  ret)
static

this get called when error conditions are met that require us to exit gracefully

◆ run_process()

static pid_t run_process ( const char *  path,
  ... 
)
static

this forks() and exec() "path" with varags as argc[]

◆ service_running()

static bool service_running ( pid_t  pid)
static

◆ show_netatalk_paths()

static void show_netatalk_paths ( void  )
static

◆ show_netatalk_version()

static void show_netatalk_version ( void  )
static

◆ sigchld_cb()

static void sigchld_cb ( evutil_socket_t  fd,
short  what,
void *  arg 
)
static

◆ sigchld_impl()

static bool sigchld_impl ( void  )
static

SIGCHLD implementation, returns true if all services have exited during shutdown

◆ sighup_cb()

static void sighup_cb ( evutil_socket_t  fd,
short  what,
void *  arg 
)
static

◆ sighup_impl()

static void sighup_impl ( void  )
static

SIGHUP implementation

◆ sigquit_cb()

static void sigquit_cb ( evutil_socket_t  fd,
short  what,
void *  arg 
)
static

◆ sigquit_impl()

static void sigquit_impl ( void  )
static

SIGQUIT implementation

◆ sigterm_cb()

static void sigterm_cb ( evutil_socket_t  fd,
short  what,
void *  arg 
)
static

◆ sigterm_impl()

static void sigterm_impl ( void  )
static

SIGTERM implementation — caller must check in_shutdown before calling

◆ timer_cb()

static void timer_cb ( evutil_socket_t  fd,
short  what,
void *  arg 
)
static

◆ timer_impl()

static void timer_impl ( void  )
static

timer implementation

◆ usage()

static void usage ( void  )
static

Variable Documentation

◆ afpd_pid

pid_t afpd_pid = NETATALK_SRV_NEEDED
static

◆ afpd_restarts

uint afpd_restarts
static

◆ base

struct event_base* base
static

◆ cnid_metad_pid

pid_t cnid_metad_pid = NETATALK_SRV_OPTIONAL
static

◆ cnid_metad_restarts

uint cnid_metad_restarts
static

◆ dbus_path

const char* dbus_path
static

◆ dbus_pid

pid_t dbus_pid = NETATALK_SRV_OPTIONAL
static

◆ dbus_restarts

uint dbus_restarts
static

◆ in_shutdown

int in_shutdown
static

◆ obj

AFPObj obj
static

◆ sigchld_ev

struct event * sigchld_ev

◆ sighup_ev

struct event * sighup_ev

◆ sigquit_ev

struct event * sigquit_ev

◆ sigterm_ev

struct event* sigterm_ev

◆ timer_ev

struct event * timer_ev