Compare commits

...
Sign in to create a new pull request.

10 commits

Author SHA1 Message Date
Fedora Release Engineering
89b6df58f4 dist-git conversion 2010-07-29 14:46:24 +00:00
Bill Nottingham
7c486efccb Fix typo that causes a failure to update the common directory. (releng
#2781)
2009-11-26 01:15:34 +00:00
Casey Dahlin
15744e8f1f Fix Bug #450488 2009-01-24 00:59:44 +00:00
Bill Nottingham
41ef2769b2 add changelog 2009-01-13 00:48:29 +00:00
Casey Dahlin
1615f48b3a Rev bumps for previous change 2009-01-10 21:48:21 +00:00
Casey Dahlin
83eaeff2d6 Remove telinit u support since its broken 2009-01-10 21:45:51 +00:00
Bill Nottingham
c46c21eb63 move the obsoletes/provides for sysvinit here 2008-04-25 21:22:21 +00:00
Bill Nottingham
7b0ac5f671 more typos 2008-04-24 20:34:54 +00:00
Bill Nottingham
429f612fa7 - fix some man page typos (#444008, <archimerged@gmail.com>) 2008-04-24 18:15:04 +00:00
Jesse Keating
6cac9e2a53 Initialize branch F-9 for upstart 2008-04-22 00:10:49 +00:00
6 changed files with 484 additions and 25 deletions

View file

View file

@ -1,21 +0,0 @@
# Makefile for source rpm: upstart
# $Id$
NAME := upstart
SPECFILE = $(firstword $(wildcard *.spec))
define find-makefile-common
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
endef
MAKEFILE_COMMON := $(shell $(find-makefile-common))
ifeq ($(MAKEFILE_COMMON),)
# attept a checkout
define checkout-makefile-common
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
endef
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
endif
include $(MAKEFILE_COMMON)

View file

@ -109,7 +109,7 @@ fork in the background and that its PID needs to be obtained.
.TP
.BI respawn
This sets the daemon, service, and respawn falgs for the job.
This sets the daemon, service, and respawn flags for the job.
The respawn flag means that the process will be restarted when
it ends.
@ -146,7 +146,7 @@ Sets the time to wait between sending TERM and KILL signals to
.TP
.BI "normal exit <status>"
When used with \fBespawn\fR any exit codes denoted in \fIstatus\fR will
When used with \fBrespawn\fR any exit codes denoted in \fIstatus\fR will
prevent a respawn of the process.
.TP

20
upstart-initctl-man.patch Normal file
View file

@ -0,0 +1,20 @@
--- upstart-0.3.9/util/man/initctl.8-orig 2008-04-09 16:52:23.000000000 -0400
+++ upstart-0.3.9/util/man/initctl.8 2008-04-24 01:42:57.000000000 -0400
@@ -4,7 +4,7 @@
initctl \- init daemon control utility
.\"
.SH SYNOPSIS
-\fBinitctl\fR [\fIOPTION\fR]... \fICOMMAND\fR [\fIOPTION\fR]... \fIARG...\fR
+\fBinitctl\fR [\fIOPTION\fR]... \fICOMMAND\fR [\fIOPTION\fR]... \fIARG\fR...
.\"
.SH DESCRIPTION
.B initctl
@@ -14,7 +14,7 @@
.IR COMMAND .
Normally it is invoked directly with the command specified as the first
-non-option argument, however symbolic or hard links may be used so that
+non-option argument; however, symbolic or hard links may be used so that
it is invoked as the name of a command, in which case it behaves
accordingly.
.\"

View file

@ -0,0 +1,442 @@
diff -uNr upstart-0.3.9.orig/init/main.c upstart-0.3.9/init/main.c
--- upstart-0.3.9.orig/init/main.c 2009-01-23 13:44:32.000000000 -0500
+++ upstart-0.3.9/init/main.c 2009-01-23 13:44:54.000000000 -0500
@@ -59,6 +59,7 @@
#include "cfgfile.h"
#include "paths.h"
#include "tty.h"
+#include "restore.h"
/* Prototypes for static functions */
@@ -278,6 +279,10 @@
exit (1);
}
+ /* Restore the state of previously active jobs, if re-exec'd by
+ * a previously running init. */
+
+ if (restart) restore_configuration(args);
/* Generate and run the startup event or read the state from the
* init daemon that exec'd us
@@ -534,6 +539,8 @@
NihError *err;
const char *loglevel;
sigset_t mask, oldmask;
+ char **args;
+ size_t len;
nih_assert (argv0 != NULL);
nih_assert (signal != NULL);
@@ -559,7 +566,20 @@
} else {
loglevel = NULL;
}
- execl (argv0, argv0, "--restart", loglevel, NULL);
+ args = nih_str_array_new(NULL);
+ len = 0;
+ if (args) args = nih_str_array_add(&args, NULL, &len, argv0);
+ if (args) args = nih_str_array_add(&args, NULL, &len, "--restart");
+ if (args && loglevel)
+ args = nih_str_array_add(&args, NULL, &len, loglevel);
+ if (args) save_current_configuration(&args, NULL, &len);
+ if (args) {
+ execv (argv0, args);
+ nih_free(args);
+ } else {
+ nih_warn (_("Unable to save list of currently running jobs"));
+ execl(argv0, argv0, "--restart", loglevel, NULL);
+ }
nih_error_raise_system ();
err = nih_error_get ();
diff -uNr upstart-0.3.9.orig/init/Makefile.am upstart-0.3.9/init/Makefile.am
--- upstart-0.3.9.orig/init/Makefile.am 2009-01-23 13:44:32.000000000 -0500
+++ upstart-0.3.9/init/Makefile.am 2009-01-23 13:44:54.000000000 -0500
@@ -23,7 +23,8 @@
event.c event.h \
control.c control.h \
notify.c notify.h \
- cfgfile.c cfgfile.h
+ cfgfile.c cfgfile.h \
+ restore.c restore.h
init_LDFLAGS = -static
init_LDADD = \
diff -uNr upstart-0.3.9.orig/init/Makefile.in upstart-0.3.9/init/Makefile.in
--- upstart-0.3.9.orig/init/Makefile.in 2009-01-23 13:44:32.000000000 -0500
+++ upstart-0.3.9/init/Makefile.in 2009-01-23 13:44:54.000000000 -0500
@@ -72,7 +72,7 @@
PROGRAMS = $(sbin_PROGRAMS)
am_init_OBJECTS = main.$(OBJEXT) tty.$(OBJEXT) process.$(OBJEXT) \
job.$(OBJEXT) event.$(OBJEXT) control.$(OBJEXT) \
- notify.$(OBJEXT) cfgfile.$(OBJEXT)
+ notify.$(OBJEXT) cfgfile.$(OBJEXT) restore.$(OBJEXT)
init_OBJECTS = $(am_init_OBJECTS)
am__DEPENDENCIES_1 =
init_DEPENDENCIES = ../upstart/libupstart.la ../nih/libnih.la \
@@ -315,7 +315,8 @@
event.c event.h \
control.c control.h \
notify.c notify.h \
- cfgfile.c cfgfile.h
+ cfgfile.c cfgfile.h \
+ restore.c restore.h
init_LDFLAGS = -static
init_LDADD = \
diff -uNr upstart-0.3.9.orig/init/restore.c upstart-0.3.9/init/restore.c
--- upstart-0.3.9.orig/init/restore.c 1969-12-31 19:00:00.000000000 -0500
+++ upstart-0.3.9/init/restore.c 2009-01-23 13:44:54.000000000 -0500
@@ -0,0 +1,333 @@
+/* Modifications to upstart to allow passing of the state of currently
+ * running jobs when upstart re-execs itself.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+
+#include <sys/types.h>
+#include <string.h>
+#include <nih/string.h>
+#include <nih/logging.h>
+#include <nih/alloc.h>
+#include "job.h"
+#include "restore.h"
+
+
+/**
+ * store_pid:
+ * @proc: pointer to a JobProcess structure or NULL
+ * @args: array of arguments
+ * @parent: parent of @args
+ * @len: current length of @args
+ *
+ * Does nothing if @args is null.
+ * Pushes "X" onto @args if @args is non-null but @process is null.
+ * Otherwise: extracts the pid from @process, creates a hexadecimal string
+ * form of it, pushes a copy onto the array @args, then frees the original.
+ */
+
+void store_pid(JobProcess *proc, char ***args, const void *parent, size_t *len)
+{
+ char *pidstr;
+ if (! *args) return;
+ pidstr = (proc ? nih_sprintf(NULL, "%x", proc->pid) : "X");
+
+ if (! pidstr) {
+ nih_error("Unable to allocate storage to save process id");
+ *args = NULL;
+ return;
+ }
+ if (! nih_str_array_add(args, parent, len, pidstr)) {
+ nih_error("Unable to add process id to argument list");
+ *args = NULL;
+ }
+
+ if (proc) nih_free(pidstr);
+}
+
+/**
+ * unpack_pid:
+ * @pidstr: hexadecimal string created by pack_pid
+ * @err: pointer to flag to set if error occurs
+ *
+ * Returns the process id corresponding to the string passed in pidstr.
+ * If an error occurs, returns 0 and sets the flag pointed to by @err.
+ **/
+
+pid_t unpack_pid(char *pidstr, int *err) {
+ pid_t result = 0;
+ while (*pidstr) {
+ unsigned char c = *pidstr++;
+ result <<= 4;
+ if (c >= '0' && c <= '9') result += (c-'0');
+ else if (c >= 'a' && c <= 'f') result += 10 + (c-'a');
+ else {
+ *err = 1;
+ return 0;
+ }
+ }
+ return result;
+}
+
+/**
+ * retrieve_pid:
+ * @arg: pointer to array of arguments from which to read pid string
+ * @jobname: name of job whose pids are being retrieved
+ * @err: pointer to flag to set if error occurs
+ * @pid: pointer to location to hold the retrieved process id
+ * @present: pointer to a location to hold 1 if the process id was present
+ *
+ * Reads a process id or no-process-present indicator from the hexadecimal
+ * string pointed to by @arg, increments @arg to point to the next string in
+ * the array unless it already points to a null string, and stores into
+ * @present a value of 0 or 1 indicating whether or not a process id is
+ * present, and stores into @pid the unpacked process id (or zero if there
+ * is no process present or an error occurred). If an error occured, sets
+ * the flag pointed to by @err and printes an error message.
+ **/
+
+void retrieve_pid(char ***arg, char *jobname, int *err,
+ pid_t *pid, int *present)
+{
+ *pid = 0;
+ *present = 0;
+ char *str;
+ if (! arg || ! *arg || ! **arg) {
+ nih_error("Ran out of arguments when restoring job %s",
+ jobname);
+ *err = 1;
+ return;
+ }
+ str = **arg;
+ if (str) ++(*arg);
+ if (strcmp(str, "X")==0) return;
+ *present = 1;
+ *pid = unpack_pid(str, err);
+ if (*err) nih_error("Cannot parse pid %s for job %s", str, jobname);
+}
+
+/**
+ * restore_pid:
+ * @proc: pointer to a JobProcess structure, or NULL
+ * @pid: process id
+ * @present: integer which is 1 if process id is applicable
+ * @jobname: name of job whose process ids are being restored
+ *
+ * Checks that the non-null status of @proc matches the true/false
+ * status of @present. If there is a mismatch, prints an error message.
+ * If @present is true and @proc is non-null, stores the process id from
+ * @pid into the JobProcess structure pointed to by @proc.
+ */
+
+void restore_pid(JobProcess *proc, pid_t pid, int present, char *jobname)
+{
+ if (proc == NULL && ! present) return;
+ if (proc != NULL && present) {
+ proc->pid = pid;
+ return;
+ }
+ nih_error("Unable to restore process id for job %s", jobname);
+}
+
+/**
+ * save_current_configuration:
+ * @args: array of arguments to pass to new init
+ * @parent: parent of @args
+ * @len: current length of @args
+ *
+ * Pushes, onto the array @args, information about currently running
+ * jobs. Each job consists of seven arguments:
+ * (1) The job name
+ * (2) A 3-character state/goal string:
+ * First character for the goal: 0=goal JOB_STOP, 1=goal JOB_START
+ * Second character for the current state:
+ * W=JOB_WAITING,
+ * S=JOB_STARTING, A=JOB_PRE_START, B=JOB_SPAWNED, C=JOB_POST_START,
+ * R=JOB_RUNNING,
+ * T=JOB_STOPPING, X=JOB_PRE_STOP, Y=JOB_KILLED, Z=JOB_POST_STOP
+ * Third character: N=normal job, I=instance job
+ * (3) The associated PROCESS_MAIN process id
+ * (4) The associated PROCESS_PRE_START process id
+ * (5) The associated PROCESS_POST_START process id
+ * (6) The associated PROCESS_PRE_STOP process id
+ * (7) The associated PROCESS_POST_STOP process id
+ * Process ids are in hexadecimal using lower-case letters (0-9,a-f),
+ * or 0 if there is a JobProcess structure but no running process, or
+ * "X" if there is no JobProcess structure.
+ *
+ */
+
+void save_current_configuration(char ***args, const void *parent, size_t *len)
+{
+ NIH_HASH_FOREACH(jobs, iter) {
+ Job *job = (Job *) iter;
+ char goal_state[4];
+ JobProcess **pids;
+
+
+ if (job->replacement_for != NULL) continue;
+ if (job->state == JOB_DELETED) continue;
+ if (job->instance && ! job->instance_of) continue;
+
+ if (! nih_str_array_add(args, parent, len, job->name))
+ return;
+
+ if (job->goal == JOB_START) goal_state[0] = '1';
+ else goal_state[0] = '0';
+
+ switch (job->state)
+ {
+ case JOB_WAITING: goal_state[1] = 'W'; break;
+ case JOB_STARTING: goal_state[1] = 'S'; break;
+ case JOB_PRE_START: goal_state[1] = 'A'; break;
+ case JOB_SPAWNED: goal_state[1] = 'B'; break;
+ case JOB_POST_START: goal_state[1] = 'C'; break;
+ case JOB_RUNNING: goal_state[1] = 'R'; break;
+ case JOB_STOPPING: goal_state[1] = 'T'; break;
+ case JOB_PRE_STOP: goal_state[1] = 'X'; break;
+ case JOB_KILLED: goal_state[1] = 'Y'; break;
+ case JOB_POST_STOP: goal_state[1] = 'Z'; break;
+ default: goal_state[1] = '?';
+ }
+ if (job->instance_of) goal_state[2] = 'I';
+ else goal_state[2] = 'N';
+ goal_state[3] = 0;
+
+ if (! nih_str_array_add(args, parent, len, goal_state))
+ return;
+
+ pids = job->process;
+ store_pid(pids[PROCESS_MAIN], args, parent, len);
+ store_pid(pids[PROCESS_PRE_START], args, parent, len);
+ store_pid(pids[PROCESS_POST_START], args, parent, len);
+ store_pid(pids[PROCESS_PRE_STOP], args, parent, len);
+ store_pid(pids[PROCESS_POST_STOP], args, parent, len);
+ }
+}
+
+/**
+ * restore_job_state:
+ * @jobname: name of job whose state we are to restore
+ * @goal_state: the goal/state string generated by save_current_configuration
+ * @pids: array of five process ids
+ * @presents: array of five integers indicating which process ids are applicable
+ */
+
+void restore_job_state (char *jobname, char *goal_state,
+ pid_t *pids, int *presents)
+{
+ Job *job;
+ JobGoal goal = JOB_STOP;
+ JobState state = JOB_WAITING;
+ int is_instance = 0;
+ int is_invalid = 0;
+ JobProcess **procs;
+
+ if (jobname == NULL) {
+ nih_error("Missing name for restored job");
+ return;
+ }
+
+ if (goal_state == NULL) {
+ nih_error("Missing goal/state for restored job %s", jobname);
+ return;
+ }
+
+ if (strlen(goal_state) != 3) {
+ nih_error("Invalid length goal/state %s for restored job %s",
+ goal_state, jobname);
+ return;
+ }
+
+ switch (goal_state[0])
+ {
+ case '0': goal = JOB_STOP; break;
+ case '1': goal = JOB_START; break;
+ default: is_invalid = 1; break;
+ }
+
+ switch (goal_state[1])
+ {
+ case 'W': state = JOB_WAITING; break;
+ case 'S': state = JOB_STARTING; break;
+ case 'A': state = JOB_PRE_START; break;
+ case 'B': state = JOB_SPAWNED; break;
+ case 'C': state = JOB_POST_START; break;
+ case 'R': state = JOB_RUNNING; break;
+ case 'T': state = JOB_STOPPING; break;
+ case 'X': state = JOB_PRE_STOP; break;
+ case 'Y': state = JOB_KILLED; break;
+ case 'Z': state = JOB_POST_STOP; break;
+ default: is_invalid = 1;
+ }
+
+ switch (goal_state[2])
+ {
+ case 'N': break;
+ case 'I': is_instance = 1; break;
+ default: is_invalid = 1;
+ }
+
+ if (is_invalid) {
+ nih_error("Invalid goal/state %s for restored job %s",
+ goal_state, jobname);
+ return;
+ }
+ job = job_find_by_name(jobname);
+ if (! job) {
+ nih_error("Unknown job %s passed to re-exec", jobname);
+ return;
+ }
+ if (is_instance) {
+ if (! job->instance) {
+ nih_error("Can not restore job %s as instance job",
+ jobname);
+ return;
+ }
+ job = job_instance(job);
+ } else {
+ if (job->instance) {
+ nih_error("Can not restore job %s as non-instance job",
+ jobname);
+ return;
+ }
+ }
+ job->goal = goal;
+ job->state = state;
+ procs=job->process;
+ restore_pid(procs[PROCESS_MAIN], pids[0], presents[0], jobname);
+ restore_pid(procs[PROCESS_PRE_START], pids[1], presents[1], jobname);
+ restore_pid(procs[PROCESS_POST_START], pids[2], presents[2], jobname);
+ restore_pid(procs[PROCESS_PRE_STOP], pids[3], presents[3], jobname);
+ restore_pid(procs[PROCESS_POST_STOP], pids[4], presents[4], jobname);
+}
+
+/**
+ * restore_current_configuration:
+ * @args: non-option arguments that were passed to the new init
+ */
+
+void restore_configuration(char **args)
+{
+ if (! args) return;
+
+ char **arg = args;
+ while (arg && *arg) {
+ char *jobname = *(arg++);
+ char *goal_state = *arg;
+ pid_t pids[5];
+ int presents[5];
+ int is_invalid = 0;
+
+ if (*arg) ++arg;
+ for (int i = 0; i < 5; i++)
+ retrieve_pid(&arg, jobname, &is_invalid,
+ &pids[i], &presents[i]);
+
+ if (! is_invalid)
+ restore_job_state (jobname, goal_state, pids, presents);
+ }
+}
diff -uNr upstart-0.3.9.orig/init/restore.h upstart-0.3.9/init/restore.h
--- upstart-0.3.9.orig/init/restore.h 1969-12-31 19:00:00.000000000 -0500
+++ upstart-0.3.9/init/restore.h 2009-01-23 13:44:54.000000000 -0500
@@ -0,0 +1,13 @@
+#ifndef INIT_RESTORE_H
+#define INIT_RESTORE_H
+
+#include <nih/string.h>
+
+NIH_BEGIN_EXTERN
+
+void save_current_configuration(char ***args, const void *parent, size_t *len);
+void restore_configuration(char **args);
+
+NIH_END_EXTERN
+
+#endif /* INIT_RESTORE_H */

View file

@ -1,6 +1,6 @@
Name: upstart
Version: 0.3.9
Release: 17%{?dist}
Release: 22%{?dist}
Summary: An event-driven init system
Group: System Environment/Base
@ -14,8 +14,11 @@ Patch2: upstart-tty-stack.patch
Patch3: upstart-rpm.patch
Patch4: upstart-fedora-buglist.patch
Patch5: upstart-telinit-u.patch
Patch6: upstart-initctl-man.patch
Patch7: upstart-save-state-across-reexec.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24
Provides: SysVinit = 2.86-24, sysvinit = 2.86-24
BuildRequires: gettext
%description
@ -31,6 +34,8 @@ during shutdown and supervising them while the system is running.
%patch3
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%build
%configure --enable-compat=sysv --sbindir=/sbin --libdir=/%{_lib}
@ -96,6 +101,19 @@ rm -rf %{buildroot}
%{_mandir}/man8/telinit.8.gz
%changelog
* Fri Jan 23 2009 Casey Dahlin <cdahlin@redhat.com> - 0.3.9-22
- Re-add 'telinit u' support along with patch to fix it (#450488). Patch due to
<pspencer@fields.utoronto.ca>
* Mon Jan 12 2009 Bill Nottingham <notting@redhat.com> - 0.3.9-21
- Remove 'telinit u' support as it is broken (#450488, <cjdahlin@ncsu.edu>)
* Fri Apr 25 2008 Bill Nottingham <notting@redhat.com> - 0.3.9-19
- with the merge of event-compat-sysv, move the sysvinit obsoletes/provides here
* Thu Apr 24 2008 Bill Nottingham <notting@redhat.com> - 0.3.9-18
- fix some man page typos (#444008, <archimerged@gmail.com>)
* Wed Apr 09 2008 Casey Dahlin <cjdahlin@ncsu.edu> - 0.3.9-17
- Added list of stock events to events(5)