packages: upstart/upstart.spec, upstart/upstart-state_save.patch (NEW) - re...
blues
blues at pld-linux.org
Thu Jun 24 13:15:16 CEST 2010
Author: blues Date: Thu Jun 24 11:15:16 2010 GMT
Module: packages Tag: HEAD
---- Log message:
- rel.3 - state_save added as bcond (to be removed soon)
---- Files affected:
packages/upstart:
upstart.spec (1.54 -> 1.55) , upstart-state_save.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: packages/upstart/upstart.spec
diff -u packages/upstart/upstart.spec:1.54 packages/upstart/upstart.spec:1.55
--- packages/upstart/upstart.spec:1.54 Tue May 11 12:25:40 2010
+++ packages/upstart/upstart.spec Thu Jun 24 13:15:11 2010
@@ -3,19 +3,22 @@
# - 4 of 13 tests failed (3 with 'permission denied')
#
# Conditional build:
-%bcond_with tests # don't perform "make check"
+%bcond_with statesave # state-save experimental patch
+%bcond_with tests # don't perform "make check"
Summary: Event-based init daemon
Summary(pl.UTF-8): Oparty na zdarzeniach demon init
Name: upstart
Version: 0.6.6
-Release: 2
+Release: 3
License: GPL v2
Group: Base
Source0: http://upstart.ubuntu.com/download/0.6/%{name}-%{version}.tar.gz
# Source0-md5: 5a2e9962a4cea719fbe07c33e2591b06
URL: http://upstart.ubuntu.com/
Patch0: pldize.patch
+# https://code.launchpad.net/~jajcus-jajcus/upstart/state-save-stable/+merge/27053/+preview-diff/+files/preview.diff
+Patch1: %{name}-state_save.patch
Source1: start-ttys.conf
Source2: tty.conf
Source3: %{name}.sysconfig
@@ -55,6 +58,7 @@
%prep
%setup -q
%patch0 -p1
+%{?with_statesave:%patch1 -p0}
cp -a %{SOURCE1} conf
cp -a %{SOURCE2} conf
@@ -130,6 +134,9 @@
All persons listed below can be reached at <cvs_login>@pld-linux.org
$Log$
+Revision 1.55 2010/06/24 11:15:11 blues
+- rel.3 - state_save added as bcond (to be removed soon)
+
Revision 1.54 2010/05/11 10:25:40 jajcus
- updated comment about the failed tests
================================================================
Index: packages/upstart/upstart-state_save.patch
diff -u /dev/null packages/upstart/upstart-state_save.patch:1.1
--- /dev/null Thu Jun 24 13:15:16 2010
+++ packages/upstart/upstart-state_save.patch Thu Jun 24 13:15:11 2010
@@ -0,0 +1,7009 @@
+=== modified file 'configure.ac'
+--- configure.ac 2010-04-27 19:48:44 +0000
++++ configure.ac 2010-06-08 13:33:50 +0000
+@@ -21,6 +21,8 @@
+ # Checks for programs.
+ AC_PROG_CC
+ PKG_PROG_PKG_CONFIG([0.22])
++AM_PROG_LEX
++AC_PROG_YACC
+
+ AC_PATH_PROG([NIH_DBUS_TOOL], [nih-dbus-tool])
+
+@@ -40,6 +42,7 @@
+ NIH_C_THREAD
+
+ # Checks for library functions.
++AC_CHECK_FUNCS([fmemopen])
+
+ # Other checks
+ AC_MSG_CHECKING([whether to include sbindir in PATH])
+
+=== modified file 'init/Makefile.am'
+--- init/Makefile.am 2010-02-04 03:42:29 +0000
++++ init/Makefile.am 2010-06-08 13:33:50 +0000
+@@ -48,7 +48,11 @@
+ blocked.c blocked.h \
+ parse_job.c parse_job.h \
+ parse_conf.c parse_conf.h \
++ save_state.c save_state.h \
++ load_state.c load_state.h \
++ state_lexer.l state_parser.y \
+ conf.c conf.h \
++ reexec.c reexec.h \
+ control.c control.h \
+ errors.h
+ nodist_init_SOURCES = \
+@@ -62,6 +66,7 @@
+ $(DBUS_LIBS) \
+ -lrt
+
++AM_YFLAGS = -d -v
+
+ com_ubuntu_Upstart_OUTPUTS = \
+ com.ubuntu.Upstart.c \
+@@ -113,7 +118,9 @@
+ BUILT_SOURCES = \
+ $(com_ubuntu_Upstart_OUTPUTS) \
+ $(com_ubuntu_Upstart_Job_OUTPUTS) \
+- $(com_ubuntu_Upstart_Instance_OUTPUTS)
++ $(com_ubuntu_Upstart_Instance_OUTPUTS) \
++ state_lexer.c \
++ state_parser.c state_parser.h
+
+ CLEANFILES = \
+ $(com_ubuntu_Upstart_OUTPUTS) \
+@@ -125,6 +132,9 @@
+
+
+ TESTS = \
++ test_state_parser \
++ test_save_state \
++ test_load_state \
+ test_system \
+ test_environ \
+ test_process \
+@@ -143,6 +153,36 @@
+
+ tests: $(BUILT_SOURCES) $(check_PROGRAMS)
+
++test_save_state_SOURCES = tests/test_save_state.c
++test_save_state_LDADD = \
++ system.o environ.o process.o \
++ job_class.o job_process.o job.o event.o event_operator.o blocked.o \
++ parse_job.o parse_conf.o conf.o control.o \
++ com.ubuntu.Upstart.o \
++ com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
++ save_state.o \
++ $(NIH_LIBS) \
++ $(NIH_DBUS_LIBS) \
++ $(DBUS_LIBS)
++
++test_load_state_SOURCES = tests/test_load_state.c
++test_load_state_LDADD = \
++ system.o environ.o process.o \
++ job_class.o job_process.o job.o event.o event_operator.o blocked.o \
++ parse_job.o parse_conf.o conf.o control.o \
++ com.ubuntu.Upstart.o \
++ com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
++ load_state.o state_parser.o state_lexer.o \
++ $(NIH_LIBS) \
++ $(NIH_DBUS_LIBS) \
++ $(DBUS_LIBS)
++
++test_state_parser_SOURCES = tests/test_state_parser.c
++test_state_parser_LDADD = \
++ state_parser.o \
++ state_lexer.o \
++ $(NIH_LIBS)
++
+ test_system_SOURCES = tests/test_system.c
+ test_system_LDADD = \
+ system.o \
+
+=== modified file 'init/control.c'
+--- init/control.c 2009-07-11 11:47:12 +0000
++++ init/control.c 2010-06-08 13:33:50 +0000
+@@ -59,6 +59,9 @@
+ static int control_server_connect (DBusServer *server, DBusConnection *conn);
+ static void control_disconnected (DBusConnection *conn);
+ static void control_register_all (DBusConnection *conn);
++static void control_unregister_all (DBusConnection *conn);
++DBusHandlerResult control_call_rejecting_filter(DBusConnection *connection,
++ DBusMessage *message, void *user_data);
+
+
+ /**
+@@ -231,7 +234,8 @@
+
+ dbus_connection_unref (conn);
+ return -1;
+- } else if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
++ } else if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER
++ && ret != DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) {
+ /* Failed to obtain the name (already taken usually) */
+ nih_error_raise (CONTROL_NAME_TAKEN,
+ _(CONTROL_NAME_TAKEN_STR));
+@@ -267,11 +271,152 @@
+ {
+ nih_assert (control_bus != NULL);
+
++ /* Unregister all objects, so control_bus_open() may be called again */
++ control_unregister_all(control_bus);
++
+ dbus_connection_unref (control_bus);
+
+ control_disconnected (control_bus);
+ }
+
++/**
++ * control_close_all_conns:
++ *
++ * Close all control connections.
++ **/
++void
++control_close_all_conns (void)
++{
++ nih_assert (control_conns != NULL);
++
++ NIH_LIST_FOREACH(control_conns, iter) {
++ NihListEntry *entry = (NihListEntry *)iter;
++ DBusConnection *conn = (DBusConnection *)entry->data;
++ dbus_connection_close(conn);
++ }
++}
++
++typedef struct call_rejection_details {
++ char * error_name;
++ char * message;
++} CallRejectionDetails;
++
++CallRejectionDetails *rejection_details = NULL;
++
++/**
++ * control_reject_calls:
++ *
++ * Add a filter to all connections to reject any incoming method calls.
++ **/
++void
++control_reject_calls (const char * error_name, const char * message)
++{
++
++ nih_assert(rejection_details == NULL);
++
++ rejection_details = nih_new(NULL, CallRejectionDetails);
++ if (rejection_details == NULL) {
++ nih_warn(_("Could not set DBus call rejecting filter"));
++ return;
++ }
++ rejection_details->error_name = nih_strdup(rejection_details,
++ error_name);
++ if (rejection_details->error_name == NULL) {
++ nih_warn(_("Could not set DBus call rejecting filter"));
++ nih_free(rejection_details);
++ rejection_details = NULL;
++ return;
++ }
++ rejection_details->message = nih_strdup(rejection_details,
++ message);
++ if (rejection_details->message == NULL) {
++ nih_warn(_("Could not set DBus call rejecting filter"));
++ nih_free(rejection_details);
++ rejection_details = NULL;
++ return;
++ }
++
++ if (control_bus) {
++ if (!dbus_connection_add_filter (control_bus,
++ control_call_rejecting_filter,
++ NULL, NULL)) {
++ nih_warn(_("Could not set DBus call rejecting filter"));
++ }
++ }
++ NIH_LIST_FOREACH(control_conns, iter) {
++ NihListEntry *entry = (NihListEntry *)iter;
++ DBusConnection *conn = (DBusConnection *)entry->data;
++ if (!dbus_connection_add_filter (conn,
++ control_call_rejecting_filter,
++ NULL, NULL)) {
++ nih_warn(_("Could not set DBus call rejecting filter"));
++ dbus_connection_close(conn);
++ }
++ }
++}
++
++/**
++ * control_unreject_calls:
++ *
++ * Remove the call rejecting filter from all connections.
++ **/
++void
++control_unreject_calls (void)
++{
++
++ nih_assert(rejection_details != NULL);
++ if (control_bus) {
++ dbus_connection_remove_filter (control_bus,
++ control_call_rejecting_filter,
++ NULL);
++ }
++ NIH_LIST_FOREACH(control_conns, iter) {
++ NihListEntry *entry = (NihListEntry *)iter;
++ DBusConnection *conn = (DBusConnection *)entry->data;
++ dbus_connection_remove_filter (conn,
++ control_call_rejecting_filter,
++ NULL);
++ }
++ nih_discard(rejection_details);
++ rejection_details = NULL;
++}
++
++
++DBusHandlerResult
++control_call_rejecting_filter(DBusConnection *connection,
++ DBusMessage *message, void *user_data)
++{
++ DBusMessage *error_message;
++
++ if (rejection_details == NULL) {
++ /* This may happen for the system bus, as libdbus
++ * never really closes it. When rejection_details are NULL
++ * it means the filter is not needed any more.
++ */
++ dbus_connection_remove_filter (connection,
++ control_call_rejecting_filter,
++ NULL);
++ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
++ }
++
++ if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_METHOD_CALL)
++ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
++
++ error_message = dbus_message_new_error (message,
++ rejection_details->error_name,
++ rejection_details->message);
++
++ if (error_message == NULL)
++ return DBUS_HANDLER_RESULT_NEED_MEMORY;
++
++ if (!dbus_connection_send(connection, error_message, NULL)) {
++ dbus_message_unref (error_message);
++ return DBUS_HANDLER_RESULT_NEED_MEMORY;
++ }
++
++ dbus_message_unref (error_message);
++ return DBUS_HANDLER_RESULT_HANDLED;
++}
+
+ /**
+ * control_disconnected:
+@@ -333,6 +478,35 @@
+ }
+ }
+
++/**
++ * control_unregister_all:
++ * @conn: connection to unregister objects for.
++ *
++ * Unregisters the manager object and objects for all jobs and instances on
++ * the given connection.
++ **/
++static void
++control_unregister_all (DBusConnection *conn)
++{
++ nih_assert (conn != NULL);
++
++ job_class_init ();
++
++ /* Unregister the control object */
++ NIH_MUST(dbus_connection_unregister_object_path (control_bus,
++ DBUS_PATH_UPSTART));
++
++ /* Unregister objects for each currently registered job and its
++ * instances.
++ */
++ NIH_HASH_FOREACH (job_classes, iter) {
++ JobClass *class = (JobClass *)iter;
++
++ job_class_unregister (class, conn, FALSE);
++ }
++}
++
++
+
+ /**
+ * control_reload_configuration:
+
+=== modified file 'init/control.h'
+--- init/control.h 2009-07-09 08:36:52 +0000
++++ init/control.h 2010-06-08 13:33:50 +0000
+@@ -46,6 +46,10 @@
+ __attribute__ ((warn_unused_result));
+ void control_bus_close (void);
+
++void control_close_all_conns (void);
++void control_reject_calls (const char * error_name, const char * message);
++void control_unreject_calls (void);
++
+ int control_reload_configuration (void *data, NihDBusMessage *message)
+ __attribute__ ((warn_unused_result));
+
+
+=== modified file 'init/errors.h'
+--- init/errors.h 2009-06-23 09:29:35 +0000
++++ init/errors.h 2010-06-08 13:33:50 +0000
+@@ -48,6 +48,15 @@
+ PARSE_EXPECTED_OPERATOR,
+ PARSE_EXPECTED_VARIABLE,
+ PARSE_MISMATCHED_PARENS,
++
++ /* Errors while parsing saved state */
++ STATE_PARSE_ERROR,
++
++ /* Errors while loading saved state */
++ LOAD_VALUE_MISSING,
++ LOAD_TYPE_MISMATCH,
++ LOAD_UNRECOGNIZED_VALUE,
++ LOAD_BAD_FORMAT_VERSION,
+
+ /* Errors while handling control requests */
+ CONTROL_NAME_TAKEN,
+@@ -68,6 +77,11 @@
+ #define PARSE_EXPECTED_OPERATOR_STR N_("Expected operator")
+ #define PARSE_EXPECTED_VARIABLE_STR N_("Expected variable name before value")
+ #define PARSE_MISMATCHED_PARENS_STR N_("Mismatched parentheses")
++#define STATE_PARSE_ERROR_STR N_("Saved state parse error")
+ #define CONTROL_NAME_TAKEN_STR N_("Name already taken")
++#define LOAD_VALUE_MISSING_STR N_("Value missing")
++#define LOAD_TYPE_MISMATCH_STR N_("Bad type for a field value")
++#define LOAD_UNRECOGNIZED_VALUE_STR N_("Unrecognized value")
++#define LOAD_BAD_FORMAT_VERSION_STR N_("Bad format version")
+
+ #endif /* INIT_ERRORS_H */
+
+=== modified file 'init/event.c'
+--- init/event.c 2009-07-02 17:31:25 +0000
++++ init/event.c 2010-06-08 13:33:50 +0000
+@@ -60,6 +60,12 @@
+ **/
+ NihList *events = NULL;
+
++/**
++ * event_poll_main_func:
++ *
++ * event_poll() callback registered in the NIH main loop.
++ **/
++static NihMainLoopFunc * event_poll_main_func = NULL;
+
+ /**
+ * event_init:
+@@ -190,7 +196,6 @@
+ event->blockers--;
+ }
+
+-
+ /**
+ * event_poll:
+ *
+@@ -252,6 +257,37 @@
+ } while (poll_again);
+ }
+
++/**
++ * event_register_poll:
++ *
++ * Register event_poll as NIH main loop callback function. Store the registered
++ * function information, so it can be removed from main loop when neccessary
++ * (like on re-exec).
++ **/
++void
++event_register_poll (void) {
++
++ /* Process the event queue each time through the main loop */
++ event_poll_main_func = NIH_MUST (
++ nih_main_loop_add_func (NULL, (NihMainLoopCb)event_poll,
++ NULL));
++}
++
++/**
++ * event_unregister_poll:
++ *
++ * Remove event_poll() callback from the NIH main loop. Used during the re-exec
++ * procedure to defer event handling to the new init incarnation.
++ **/
++void
++event_unregister_poll (void) {
++
++ if (event_poll_main_func == NULL)
++ return;
++
++ nih_free(event_poll_main_func);
++ event_poll_main_func = NULL;
++}
+
+ /**
+ * event_pending:
+
+=== modified file 'init/event.h'
+--- init/event.h 2009-07-09 08:36:52 +0000
++++ init/event.h 2010-06-08 13:33:50 +0000
+@@ -87,6 +87,8 @@
+ void event_unblock (Event *event);
+
+ void event_poll (void);
++void event_register_poll (void);
++void event_unregister_poll (void);
+
+ NIH_END_EXTERN
+
+
+=== modified file 'init/job.c'
+--- init/job.c 2009-07-21 11:27:55 +0000
++++ init/job.c 2010-06-08 13:33:50 +0000
+@@ -184,6 +184,32 @@
+ job->path));
+ }
+
++/**
++ * job_unregister:
++ * @job: job to unregister,
++ * @conn: connection to unregister for,
++ * @signal: emit the InstanceRemoved signal.
++ *
++ * Unregister the @job instance from the D-Bus connection @conn, using
++ * the path set when the job was created.
++ **/
++void
++job_unregister (Job *job,
++ DBusConnection *conn,
++ int signal)
++{
++ nih_assert (job != NULL);
++ nih_assert (conn != NULL);
++
++ NIH_MUST (dbus_connection_unregister_object_path (conn, job->path));
++
++ nih_debug ("Unregistered instance %s", job->path);
++ if (signal)
++ NIH_ZERO (job_class_emit_instance_removed (conn,
++ job->class->path,
++ job->path));
++}
++
+
+ /**
+ * job_change_goal:
+
+=== modified file 'init/job.h'
+--- init/job.h 2009-07-03 16:38:02 +0000
++++ init/job.h 2010-06-08 13:33:50 +0000
+@@ -158,7 +158,7 @@
+ Job * job_new (JobClass *class, const char *name)
+ __attribute__ ((warn_unused_result, malloc));
+ void job_register (Job *job, DBusConnection *conn, int signal);
+-
++void job_unregister (Job *job, DBusConnection *conn, int signal);
+ void job_change_goal (Job *job, JobGoal goal);
+
+ void job_change_state (Job *job, JobState state);
+
+=== modified file 'init/job_class.c'
+--- init/job_class.c 2009-07-09 11:50:19 +0000
++++ init/job_class.c 2010-06-08 13:33:50 +0000
+@@ -355,7 +355,7 @@
+ NihListEntry *entry = (NihListEntry *)iter;
+ DBusConnection *conn = (DBusConnection *)entry->data;
+
+- job_class_unregister (class, conn);
++ job_class_unregister (class, conn, TRUE);
+ }
+
+ return TRUE;
+@@ -401,25 +401,31 @@
+ * job_class_unregister:
+ * @class: class to unregistered,
+ * @conn: connection to unregister from.
++ * @signal: emit the JobRemoved signal
+ *
+ * Unregister the job @class from the D-Bus connection @conn, which must
+ * have already been registered with job_class_register().
+ **/
+ void
+ job_class_unregister (JobClass *class,
+- DBusConnection *conn)
++ DBusConnection *conn,
++ int signal)
+ {
+ nih_assert (class != NULL);
+ nih_assert (conn != NULL);
+- NIH_HASH_FOREACH (class->instances, iter)
+- nih_assert_not_reached ();
++ NIH_HASH_FOREACH (class->instances, iter) {
++ Job *job = (Job *)iter;
++
++ job_unregister(job, conn, signal);
++ }
+
+ NIH_MUST (dbus_connection_unregister_object_path (conn, class->path));
+
+ nih_debug ("Unregistered job %s", class->path);
+
+- NIH_ZERO (control_emit_job_removed (conn, DBUS_PATH_UPSTART,
+- class->path));
++ if (signal)
++ NIH_ZERO (control_emit_job_removed (conn, DBUS_PATH_UPSTART,
++ class->path));
+ }
+
+
+
+=== modified file 'init/job_class.h'
+--- init/job_class.h 2009-07-09 11:01:53 +0000
++++ init/job_class.h 2010-06-08 13:33:50 +0000
+@@ -167,7 +167,7 @@
<<Diff was trimmed, longer than 597 lines>>
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/upstart/upstart.spec?r1=1.54&r2=1.55&f=u
More information about the pld-cvs-commit
mailing list