Refactor #ifndef INETD_DISABLED --> #ifdef INETD_ENABLED

This patch changes the confusing logic in all #ifndef INETD_DISABLED
statements to instead be #ifdef INETD_ENABLED, which is quite a bit
more readable.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-12-30 13:34:31 +01:00
1 parent d9de2717a2
commit f95cd38ddb
5 files changed
+20 -20

No files matched your search

+3 -3
View File
@@ -140,7 +140,7 @@ static int do_start (char *buf, size_t len) { return call(service_unblock, buf,
static int do_pause (char *buf, size_t len) { return call(service_block, buf, len); } static int do_pause (char *buf, size_t len) { return call(service_block, buf, len); }
static int do_restart(char *buf, size_t len) { return call(service_restart, buf, len); } static int do_restart(char *buf, size_t len) { return call(service_restart, buf, len); }
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
static int do_query_inetd(char *buf, size_t len) static int do_query_inetd(char *buf, size_t len)
{ {
int id = 1; int id = 1;
@@ -164,7 +164,7 @@ static int do_query_inetd(char *buf, size_t len)
return inetd_filter_str(&svc->inetd, buf, len); return inetd_filter_str(&svc->inetd, buf, len);
} }
#endif /* !INETD_DISABLED */ #endif /* INETD_ENABLED */
typedef struct { typedef struct {
char *event; char *event;
@@ -305,7 +305,7 @@ static void cb(uev_t *w, void *UNUSED(arg), int UNUSED(events))
result = do_restart(rq.data, sizeof(rq.data)); result = do_restart(rq.data, sizeof(rq.data));
break; break;
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
case INIT_CMD_QUERY_INETD: case INIT_CMD_QUERY_INETD:
result = do_query_inetd(rq.data, sizeof(rq.data)); result = do_query_inetd(rq.data, sizeof(rq.data));
break; break;
+1 -1
View File
@@ -360,7 +360,7 @@ static void parse_dynamic(char *line, time_t mtime)
/* Classic inetd service */ /* Classic inetd service */
if (MATCH_CMD(line, "inetd ", x)) { if (MATCH_CMD(line, "inetd ", x)) {
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
service_register(SVC_TYPE_INETD, x, mtime, NULL); service_register(SVC_TYPE_INETD, x, mtime, NULL);
#else #else
_e("Finit built with inetd support disabled, cannot register service inetd %s!", x); _e("Finit built with inetd support disabled, cannot register service inetd %s!", x);
+3 -3
View File
@@ -141,9 +141,9 @@ AS_IF([test "x$enable_watchdog" = "xyes"], [
AC_DEFINE(BUILTIN_WATCHDOG, 1, [Enable built-in watchdog, kicks on /dev/watchdog])]) AC_DEFINE(BUILTIN_WATCHDOG, 1, [Enable built-in watchdog, kicks on /dev/watchdog])])
### Disable features ########################################################################### ### Disable features ###########################################################################
AS_IF([test "x$enable_inetd" != "xno"], AS_IF([test "x$enable_inetd" != "xno"], [
enable_inetd="yes", [ enable_inetd="yes"
AC_DEFINE(INETD_DISABLED, 1, [Disable built-in inetd])]) AC_DEFINE(INETD_ENABLED, 1, [Enable built-in inetd])])
AS_IF([test "x$enable_quiet" != "xno"], [ AS_IF([test "x$enable_quiet" != "xno"], [
AC_DEFINE(QUIET_MODE, 1, [Silent, after initial boot, no stopping/starting messages. Default: 1]) AC_DEFINE(QUIET_MODE, 1, [Silent, after initial boot, no stopping/starting messages. Default: 1])
+2 -2
View File
@@ -377,7 +377,7 @@ static int show_status(char *arg)
continue; continue;
} }
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
if (svc_is_inetd(svc)) { if (svc_is_inetd(svc)) {
char *info; char *info;
struct init_request rq = { struct init_request rq = {
@@ -401,7 +401,7 @@ static int show_status(char *arg)
printf("%s %s\n", svc->cmd, info); printf("%s %s\n", svc->cmd, info);
} }
else else
#endif /* !INETD_DISABLED */ #endif /* INETD_ENABLED */
{ {
int i; int i;
+11 -11
View File
@@ -174,7 +174,7 @@ static int service_start(svc_t *svc)
print_desc("", svc->desc); print_desc("", svc->desc);
} }
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
if (svc_is_inetd(svc)) { if (svc_is_inetd(svc)) {
result = inetd_start(&svc->inetd); result = inetd_start(&svc->inetd);
if (!silent) if (!silent)
@@ -221,7 +221,7 @@ static int service_start(svc_t *svc)
args[i] = NULL; args[i] = NULL;
/* Redirect inetd socket to stdin for connection */ /* Redirect inetd socket to stdin for connection */
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
if (svc_is_inetd_conn(svc)) { if (svc_is_inetd_conn(svc)) {
dup2(svc->stdin_fd, STDIN_FILENO); dup2(svc->stdin_fd, STDIN_FILENO);
close(svc->stdin_fd); close(svc->stdin_fd);
@@ -287,7 +287,7 @@ static int service_start(svc_t *svc)
else else
status = execv(svc->cmd, args); /* XXX: Maybe use execve() to be able to launch scripts? */ status = execv(svc->cmd, args); /* XXX: Maybe use execve() to be able to launch scripts? */
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
if (svc_is_inetd_conn(svc)) { if (svc_is_inetd_conn(svc)) {
if (svc->inetd.type == SOCK_STREAM) { if (svc->inetd.type == SOCK_STREAM) {
close(STDIN_FILENO); close(STDIN_FILENO);
@@ -315,7 +315,7 @@ static int service_start(svc_t *svc)
svc->pid = pid; svc->pid = pid;
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
if (svc_is_inetd_conn(svc) && svc->inetd.type == SOCK_STREAM) if (svc_is_inetd_conn(svc) && svc->inetd.type == SOCK_STREAM)
close(svc->stdin_fd); close(svc->stdin_fd);
#endif #endif
@@ -370,7 +370,7 @@ static int service_stop(svc_t *svc)
if (!svc) if (!svc)
return 1; return 1;
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
if (svc_is_inetd(svc)) { if (svc_is_inetd(svc)) {
int do_print = runlevel != 1 && !silent && !svc_is_busy(svc); int do_print = runlevel != 1 && !silent && !svc_is_busy(svc);
@@ -542,7 +542,7 @@ int service_register(int type, char *line, time_t mtime, char *username)
{ {
int i = 0; int i = 0;
int id = 1; /* Default to ID:1 */ int id = 1; /* Default to ID:1 */
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
int forking = 0; int forking = 0;
#endif #endif
int log = 0; int log = 0;
@@ -581,7 +581,7 @@ int service_register(int type, char *line, time_t mtime, char *username)
cond = &cmd[1]; cond = &cmd[1];
else if (cmd[0] == ':') /* :ID */ else if (cmd[0] == ':') /* :ID */
id = atoi(&cmd[1]); id = atoi(&cmd[1]);
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
else if (!strncasecmp(cmd, "nowait", 6)) else if (!strncasecmp(cmd, "nowait", 6))
forking = 1; forking = 1;
else if (!strncasecmp(cmd, "wait", 4)) else if (!strncasecmp(cmd, "wait", 4))
@@ -612,7 +612,7 @@ int service_register(int type, char *line, time_t mtime, char *username)
*proto++ = 0; *proto++ = 0;
} }
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
/* Find plugin that provides a callback for this inetd service */ /* Find plugin that provides a callback for this inetd service */
if (type == SVC_TYPE_INETD) { if (type == SVC_TYPE_INETD) {
if (!strncasecmp(cmd, "internal", 8)) { if (!strncasecmp(cmd, "internal", 8)) {
@@ -651,7 +651,7 @@ recreate:
return errno = ENOMEM; return errno = ENOMEM;
} }
} }
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
else { else {
if (svc_is_inetd(svc) && type != SVC_TYPE_INETD) { if (svc_is_inetd(svc) && type != SVC_TYPE_INETD) {
_d("Service was previously inetd, deregistering ..."); _d("Service was previously inetd, deregistering ...");
@@ -692,7 +692,7 @@ recreate:
conf_parse_cond(svc, cond); conf_parse_cond(svc, cond);
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
if (svc_is_inetd(svc)) { if (svc_is_inetd(svc)) {
char *iface, *name = service; char *iface, *name = service;
@@ -839,7 +839,7 @@ restart:
break; break;
case SVC_DONE_STATE: case SVC_DONE_STATE:
#ifndef INETD_DISABLED #ifdef INETD_ENABLED
if (svc_is_inetd_conn(svc)) { if (svc_is_inetd_conn(svc)) {
if (svc_is_busy(svc->inetd.svc)) { if (svc_is_busy(svc->inetd.svc)) {
svc_unblock(svc->inetd.svc); svc_unblock(svc->inetd.svc);