aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile2
-rw-r--r--src/librc.c26
-rw-r--r--src/rc.c3
3 files changed, 23 insertions, 8 deletions
diff --git a/src/Makefile b/src/Makefile
index 58f4032e..54660a42 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -80,7 +80,7 @@ RC_BINLINKS = einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
RC_SBINLINKS = mark_service_starting mark_service_started \
mark_service_stopping mark_service_stopped \
mark_service_inactive mark_service_wasinactive \
- mark_service_coldplugged \
+ mark_service_coldplugged mark_service_failed \
rc-abort
BINLINKS = rc-status
SBINLINKS = env-update rc-update runscript start-stop-daemon
diff --git a/src/librc.c b/src/librc.c
index 43809e2a..0995d3d6 100644
--- a/src/librc.c
+++ b/src/librc.c
@@ -10,8 +10,10 @@
/* usecs to wait while we poll the fifo */
#define WAIT_INTERVAL 20000000
-/* max nsecs to wait until a service comes up */
-#define WAIT_MAX 60000000000
+/* max secs to wait until a service comes up */
+#define WAIT_MAX 300
+
+#define ONE_SECOND 1000000000
#define SOFTLEVEL RC_SVCDIR "/softlevel"
@@ -393,7 +395,7 @@ bool rc_service_mark (const char *service, const rc_service_state_t state)
skip_state = state;
}
- if (state == RC_SERVICE_COLDPLUGGED) {
+ if (state == RC_SERVICE_COLDPLUGGED || state == RC_SERVICE_FAILED) {
free (init);
free (svc);
return (true);
@@ -604,7 +606,12 @@ static pid_t _exec_service (const char *service, const char *arg)
pid_t rc_service_stop (const char *service)
{
- if (rc_service_state (service) & RC_SERVICE_STOPPED)
+ rc_service_state_t state = rc_service_state (service);
+
+ if (state & RC_SERVICE_FAILED)
+ return (-1);
+
+ if (state & RC_SERVICE_STOPPED)
return (0);
return (_exec_service (service, "stop"));
@@ -613,7 +620,12 @@ librc_hidden_def(rc_service_stop)
pid_t rc_service_start (const char *service)
{
- if (! rc_service_state (service) & RC_SERVICE_STOPPED)
+ rc_service_state_t state = rc_service_state (service);
+
+ if (state & RC_SERVICE_FAILED)
+ return (-1);
+
+ if (! state & RC_SERVICE_STOPPED)
return (0);
return (_exec_service (service, "start"));
@@ -676,7 +688,7 @@ bool rc_service_wait (const char *service)
char *base;
char *fifo;
struct timespec ts;
- int nloops = WAIT_MAX / WAIT_INTERVAL;
+ int nloops = WAIT_MAX * (ONE_SECOND / WAIT_INTERVAL);
bool retval = false;
bool forever = false;
@@ -710,6 +722,8 @@ bool rc_service_wait (const char *service)
nloops --;
}
+ if (! exists (fifo))
+ retval = true;
free (fifo);
return (retval);
}
diff --git a/src/rc.c b/src/rc.c
index 7058be15..c236bd50 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -317,6 +317,8 @@ static int do_mark_service (int argc, char **argv)
ok = rc_service_mark (argv[0], RC_SERVICE_STOPPING);
else if (strcmp (applet, "mark_service_coldplugged") == 0)
ok = rc_service_mark (argv[0], RC_SERVICE_COLDPLUGGED);
+ else if (strcmp (applet, "mark_service_failed") == 0)
+ ok = rc_service_mark (argv[0], RC_SERVICE_FAILED);
else
eerrorx ("%s: unknown applet", applet);
@@ -1057,7 +1059,6 @@ int main (int argc, char **argv)
}
}
closedir (dp);
- rmdir (RC_SVCDIR "/failed");
}
mkdir (RC_STOPPING, 0755);