diff options
| author | David Barksdale <amatus.amongus@gmail.com> | 2013-07-22 08:26:16 -0500 |
|---|---|---|
| committer | David Barksdale <amatus.amongus@gmail.com> | 2013-07-22 08:26:16 -0500 |
| commit | 7450bd0b6c6c05ee6425e2c63e9b79beb94bfbfa (patch) | |
| tree | dfde89b41437def7ce23af24db53a11a9b5f1075 /src/arm | |
| parent | 740b30688bd745a527f96f9116c19acb3480971a (diff) | |
Imported Upstream version 0.9.5aupstream
Diffstat (limited to 'src/arm')
| -rw-r--r-- | src/arm/Makefile.am | 32 | ||||
| -rw-r--r-- | src/arm/Makefile.in | 295 | ||||
| -rw-r--r-- | src/arm/arm.conf.in | 9 | ||||
| -rw-r--r-- | src/arm/arm_api.c | 123 | ||||
| -rw-r--r-- | src/arm/do_start_process.c | 30 | ||||
| -rw-r--r-- | src/arm/gnunet-arm.c | 321 | ||||
| -rw-r--r-- | src/arm/gnunet-service-arm.c | 81 | ||||
| -rw-r--r-- | src/arm/test_arm_api.c | 26 | ||||
| -rw-r--r-- | src/arm/test_arm_api_data.conf | 10 | ||||
| -rw-r--r-- | src/arm/test_exponential_backoff.c | 30 | ||||
| -rw-r--r-- | src/arm/test_gnunet_arm.py.in | 106 | ||||
| -rwxr-xr-x | src/arm/test_gnunet_arm.sh | 65 | ||||
| -rw-r--r-- | src/arm/test_gnunet_service_arm.c (renamed from src/arm/test_gnunet_service_manager.c) | 88 |
13 files changed, 725 insertions, 491 deletions
diff --git a/src/arm/Makefile.am b/src/arm/Makefile.am index 7da1e2c..48d9955 100644 --- a/src/arm/Makefile.am +++ b/src/arm/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = -I$(top_srcdir)/src/include pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ arm.conf @@ -23,11 +25,13 @@ libgnunetarm_la_LIBADD = \ $(GN_LIBINTL) $(XLIB) libgnunetarm_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) $(WINFLAGS) \ - -version-info 1:1:0 + -version-info 1:3:0 bin_PROGRAMS = \ - gnunet-arm \ + gnunet-arm + +libexec_PROGRAMS = \ gnunet-service-arm \ mockup-service @@ -58,10 +62,10 @@ mockup_service_SOURCES = \ check_PROGRAMS = \ test_arm_api \ test_exponential_backoff \ - test_gnunet_service_manager + test_gnunet_service_arm check_SCRIPTS = \ - test_gnunet_arm.sh + test_gnunet_arm.py if ENABLE_TEST_RUN TESTS = $(check_PROGRAMS) $(check_SCRIPTS) @@ -79,13 +83,23 @@ test_exponential_backoff_LDADD = \ $(top_builddir)/src/arm/libgnunetarm.la \ $(top_builddir)/src/util/libgnunetutil.la -test_gnunet_service_manager_SOURCES = \ - test_gnunet_service_manager.c - test_gnunet_service_manager_LDADD = \ +test_gnunet_service_arm_SOURCES = \ + test_gnunet_service_arm.c + test_gnunet_service_arm_LDADD = \ $(top_builddir)/src/arm/libgnunetarm.la \ $(top_builddir)/src/util/libgnunetutil.la +do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' + +%.py: %.py.in Makefile + $(do_subst) < $(srcdir)/$< > $@ + chmod +x $@ + +test_gnunet_arm.py: test_gnunet_arm.py.in Makefile + $(do_subst) < $(srcdir)/test_gnunet_arm.py.in > test_gnunet_arm.py + chmod +x test_gnunet_arm.py + EXTRA_DIST = \ test_arm_api_data.conf \ - do_start_process.c \ - $(check_SCRIPTS) + test_gnunet_arm.py.in \ + do_start_process.c diff --git a/src/arm/Makefile.in b/src/arm/Makefile.in index 122ab3c..07b50d6 100644 --- a/src/arm/Makefile.in +++ b/src/arm/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -18,6 +18,23 @@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -37,25 +54,26 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -bin_PROGRAMS = gnunet-arm$(EXEEXT) gnunet-service-arm$(EXEEXT) \ - mockup-service$(EXEEXT) +bin_PROGRAMS = gnunet-arm$(EXEEXT) +libexec_PROGRAMS = gnunet-service-arm$(EXEEXT) mockup-service$(EXEEXT) check_PROGRAMS = test_arm_api$(EXEEXT) \ test_exponential_backoff$(EXEEXT) \ - test_gnunet_service_manager$(EXEEXT) + test_gnunet_service_arm$(EXEEXT) subdir = src/arm DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/arm.conf.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/absolute-header.m4 \ $(top_srcdir)/m4/align.m4 $(top_srcdir)/m4/argz.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ - $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libcurl.m4 \ - $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/libunistring.m4 $(top_srcdir)/m4/ltdl.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glib-2.0.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libgcrypt.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/libunistring.m4 \ + $(top_srcdir)/m4/ltdl.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -85,8 +103,14 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ - "$(DESTDIR)$(pkgcfgdir)" + "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(pkgcfgdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = libgnunetarm_la_DEPENDENCIES = \ @@ -94,14 +118,14 @@ libgnunetarm_la_DEPENDENCIES = \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_libgnunetarm_la_OBJECTS = arm_api.lo libgnunetarm_la_OBJECTS = $(am_libgnunetarm_la_OBJECTS) -AM_V_lt = $(am__v_lt_$(V)) -am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent libgnunetarm_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libgnunetarm_la_LDFLAGS) $(LDFLAGS) \ -o $@ -PROGRAMS = $(bin_PROGRAMS) +PROGRAMS = $(bin_PROGRAMS) $(libexec_PROGRAMS) am_gnunet_arm_OBJECTS = gnunet-arm.$(OBJEXT) gnunet_arm_OBJECTS = $(am_gnunet_arm_OBJECTS) am_gnunet_service_arm_OBJECTS = gnunet-service-arm.$(OBJEXT) @@ -121,11 +145,11 @@ test_exponential_backoff_OBJECTS = \ test_exponential_backoff_DEPENDENCIES = \ $(top_builddir)/src/arm/libgnunetarm.la \ $(top_builddir)/src/util/libgnunetutil.la -am_test_gnunet_service_manager_OBJECTS = \ - test_gnunet_service_manager.$(OBJEXT) -test_gnunet_service_manager_OBJECTS = \ - $(am_test_gnunet_service_manager_OBJECTS) -test_gnunet_service_manager_DEPENDENCIES = \ +am_test_gnunet_service_arm_OBJECTS = \ + test_gnunet_service_arm.$(OBJEXT) +test_gnunet_service_arm_OBJECTS = \ + $(am_test_gnunet_service_arm_OBJECTS) +test_gnunet_service_arm_DEPENDENCIES = \ $(top_builddir)/src/arm/libgnunetarm.la \ $(top_builddir)/src/util/libgnunetutil.la DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) @@ -138,30 +162,35 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_$(V)) -am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_$(V)) -am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libgnunetarm_la_SOURCES) $(gnunet_arm_SOURCES) \ $(gnunet_service_arm_SOURCES) $(mockup_service_SOURCES) \ $(test_arm_api_SOURCES) $(test_exponential_backoff_SOURCES) \ - $(test_gnunet_service_manager_SOURCES) + $(test_gnunet_service_arm_SOURCES) DIST_SOURCES = $(libgnunetarm_la_SOURCES) $(gnunet_arm_SOURCES) \ $(gnunet_service_arm_SOURCES) $(mockup_service_SOURCES) \ $(test_arm_api_SOURCES) $(test_exponential_backoff_SOURCES) \ - $(test_gnunet_service_manager_SOURCES) + $(test_gnunet_service_arm_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac DATA = $(pkgcfg_DATA) ETAGS = etags CTAGS = ctags @@ -203,6 +232,10 @@ EXEEXT = @EXEEXT@ EXT_LIBS = @EXT_LIBS@ EXT_LIB_PATH = @EXT_LIB_PATH@ FGREP = @FGREP@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GNUNETDNS_GROUP = @GNUNETDNS_GROUP@ @@ -213,6 +246,7 @@ GN_LIBINTL = @GN_LIBINTL@ GN_LIB_LDFLAGS = @GN_LIB_LDFLAGS@ GN_PLUGIN_LDFLAGS = @GN_PLUGIN_LDFLAGS@ GN_USER_HOME_DIR = @GN_USER_HOME_DIR@ +GOBJECT_QUERY = @GOBJECT_QUERY@ GREP = @GREP@ HAVE_LIBUNISTRING = @HAVE_LIBUNISTRING@ INCLTDL = @INCLTDL@ @@ -235,6 +269,8 @@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBGTOP_CFLAGS = @LIBGTOP_CFLAGS@ +LIBGTOP_LIBS = @LIBGTOP_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBLTDL = @LIBLTDL@ @@ -256,6 +292,7 @@ LT_CONFIG_H = @LT_CONFIG_H@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MONKEYPREFIX = @MONKEYPREFIX@ MSGFMT = @MSGFMT@ @@ -265,6 +302,7 @@ MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ MYSQL_LDFLAGS = @MYSQL_LDFLAGS@ NM = @NM@ NMEDIT = @NMEDIT@ +NSS_DIR = @NSS_DIR@ OBJC = @OBJC@ OBJCDEPMODE = @OBJCDEPMODE@ OBJCFLAGS = @OBJCFLAGS@ @@ -280,6 +318,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ POSTGRES_CPPFLAGS = @POSTGRES_CPPFLAGS@ POSTGRES_LDFLAGS = @POSTGRES_LDFLAGS@ POSUB = @POSUB@ @@ -311,6 +350,7 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ @@ -333,6 +373,7 @@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ +gitcommand = @gitcommand@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ @@ -343,10 +384,9 @@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ -libexecdir = @libexecdir@ +libexecdir = $(pkglibdir)/libexec/ localedir = @localedir@ localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ ltdl_LIBOBJS = @ltdl_LIBOBJS@ ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ mandir = @mandir@ @@ -364,6 +404,7 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ subdirs = @subdirs@ +svnversioncommand = @svnversioncommand@ sys_symbol_underscore = @sys_symbol_underscore@ sysconfdir = @sysconfdir@ target = @target@ @@ -392,7 +433,7 @@ libgnunetarm_la_LIBADD = \ libgnunetarm_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) $(WINFLAGS) \ - -version-info 1:1:0 + -version-info 1:3:0 gnunet_arm_SOURCES = \ gnunet-arm.c @@ -422,7 +463,7 @@ mockup_service_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la check_SCRIPTS = \ - test_gnunet_arm.sh + test_gnunet_arm.py @ENABLE_TEST_RUN_TRUE@TESTS = $(check_PROGRAMS) $(check_SCRIPTS) test_arm_api_SOURCES = \ @@ -439,17 +480,18 @@ test_exponential_backoff_LDADD = \ $(top_builddir)/src/arm/libgnunetarm.la \ $(top_builddir)/src/util/libgnunetutil.la -test_gnunet_service_manager_SOURCES = \ - test_gnunet_service_manager.c +test_gnunet_service_arm_SOURCES = \ + test_gnunet_service_arm.c -test_gnunet_service_manager_LDADD = \ +test_gnunet_service_arm_LDADD = \ $(top_builddir)/src/arm/libgnunetarm.la \ $(top_builddir)/src/util/libgnunetutil.la +do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' EXTRA_DIST = \ test_arm_api_data.conf \ - do_start_process.c \ - $(check_SCRIPTS) + test_gnunet_arm.py.in \ + do_start_process.c all: all-am @@ -489,7 +531,6 @@ arm.conf: $(top_builddir)/config.status $(srcdir)/arm.conf.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ @@ -497,6 +538,8 @@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) else :; fi; \ done; \ test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } @@ -518,12 +561,15 @@ clean-libLTLIBRARIES: echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done -libgnunetarm.la: $(libgnunetarm_la_OBJECTS) $(libgnunetarm_la_DEPENDENCIES) +libgnunetarm.la: $(libgnunetarm_la_OBJECTS) $(libgnunetarm_la_DEPENDENCIES) $(EXTRA_libgnunetarm_la_DEPENDENCIES) $(AM_V_CCLD)$(libgnunetarm_la_LINK) -rpath $(libdir) $(libgnunetarm_la_OBJECTS) $(libgnunetarm_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ @@ -572,24 +618,70 @@ clean-checkPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list -gnunet-arm$(EXEEXT): $(gnunet_arm_OBJECTS) $(gnunet_arm_DEPENDENCIES) +install-libexecPROGRAMS: $(libexec_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-libexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(libexecdir)" && rm -f $$files + +clean-libexecPROGRAMS: + @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +gnunet-arm$(EXEEXT): $(gnunet_arm_OBJECTS) $(gnunet_arm_DEPENDENCIES) $(EXTRA_gnunet_arm_DEPENDENCIES) @rm -f gnunet-arm$(EXEEXT) $(AM_V_CCLD)$(LINK) $(gnunet_arm_OBJECTS) $(gnunet_arm_LDADD) $(LIBS) -gnunet-service-arm$(EXEEXT): $(gnunet_service_arm_OBJECTS) $(gnunet_service_arm_DEPENDENCIES) +gnunet-service-arm$(EXEEXT): $(gnunet_service_arm_OBJECTS) $(gnunet_service_arm_DEPENDENCIES) $(EXTRA_gnunet_service_arm_DEPENDENCIES) @rm -f gnunet-service-arm$(EXEEXT) $(AM_V_CCLD)$(LINK) $(gnunet_service_arm_OBJECTS) $(gnunet_service_arm_LDADD) $(LIBS) -mockup-service$(EXEEXT): $(mockup_service_OBJECTS) $(mockup_service_DEPENDENCIES) +mockup-service$(EXEEXT): $(mockup_service_OBJECTS) $(mockup_service_DEPENDENCIES) $(EXTRA_mockup_service_DEPENDENCIES) @rm -f mockup-service$(EXEEXT) $(AM_V_CCLD)$(LINK) $(mockup_service_OBJECTS) $(mockup_service_LDADD) $(LIBS) -test_arm_api$(EXEEXT): $(test_arm_api_OBJECTS) $(test_arm_api_DEPENDENCIES) +test_arm_api$(EXEEXT): $(test_arm_api_OBJECTS) $(test_arm_api_DEPENDENCIES) $(EXTRA_test_arm_api_DEPENDENCIES) @rm -f test_arm_api$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_arm_api_OBJECTS) $(test_arm_api_LDADD) $(LIBS) -test_exponential_backoff$(EXEEXT): $(test_exponential_backoff_OBJECTS) $(test_exponential_backoff_DEPENDENCIES) +test_exponential_backoff$(EXEEXT): $(test_exponential_backoff_OBJECTS) $(test_exponential_backoff_DEPENDENCIES) $(EXTRA_test_exponential_backoff_DEPENDENCIES) @rm -f test_exponential_backoff$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_exponential_backoff_OBJECTS) $(test_exponential_backoff_LDADD) $(LIBS) -test_gnunet_service_manager$(EXEEXT): $(test_gnunet_service_manager_OBJECTS) $(test_gnunet_service_manager_DEPENDENCIES) - @rm -f test_gnunet_service_manager$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_gnunet_service_manager_OBJECTS) $(test_gnunet_service_manager_LDADD) $(LIBS) +test_gnunet_service_arm$(EXEEXT): $(test_gnunet_service_arm_OBJECTS) $(test_gnunet_service_arm_DEPENDENCIES) $(EXTRA_test_gnunet_service_arm_DEPENDENCIES) + @rm -f test_gnunet_service_arm$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_gnunet_service_arm_OBJECTS) $(test_gnunet_service_arm_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -603,31 +695,28 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mockup-service.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_arm_api.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_exponential_backoff.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_gnunet_service_manager.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_gnunet_service_arm.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo @@ -636,8 +725,11 @@ clean-libtool: -rm -rf .libs _libs install-pkgcfgDATA: $(pkgcfg_DATA) @$(NORMAL_INSTALL) - test -z "$(pkgcfgdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgcfgdir)" @list='$(pkgcfg_DATA)'; test -n "$(pkgcfgdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgcfgdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgcfgdir)" || exit 1; \ + fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -651,9 +743,7 @@ uninstall-pkgcfgDATA: @$(NORMAL_UNINSTALL) @list='$(pkgcfg_DATA)'; test -n "$(pkgcfgdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(pkgcfgdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(pkgcfgdir)" && rm -f $$files + dir='$(DESTDIR)$(pkgcfgdir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -788,14 +878,15 @@ check-TESTS: $(TESTS) fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ - echo "$$grn$$dashes"; \ + col="$$grn"; \ else \ - echo "$$red$$dashes"; \ + col="$$red"; \ fi; \ - echo "$$banner"; \ - test -z "$$skipped" || echo "$$skipped"; \ - test -z "$$report" || echo "$$report"; \ - echo "$$dashes$$std"; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ test "$$failed" -eq 0; \ else :; fi @@ -837,7 +928,7 @@ all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) install-binPROGRAMS: install-libLTLIBRARIES installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgcfgdir)"; do \ + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(pkgcfgdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -850,10 +941,15 @@ install-am: all-am installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: @@ -868,7 +964,8 @@ maintainer-clean-generic: clean: clean-am clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ - clean-libLTLIBRARIES clean-libtool mostlyclean-am + clean-libLTLIBRARIES clean-libexecPROGRAMS clean-libtool \ + mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) @@ -894,7 +991,8 @@ install-dvi: install-dvi-am install-dvi-am: -install-exec-am: install-binPROGRAMS install-libLTLIBRARIES +install-exec-am: install-binPROGRAMS install-libLTLIBRARIES \ + install-libexecPROGRAMS install-html: install-html-am @@ -935,28 +1033,37 @@ ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES \ - uninstall-pkgcfgDATA + uninstall-libexecPROGRAMS uninstall-pkgcfgDATA .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ - clean-libLTLIBRARIES clean-libtool ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-binPROGRAMS install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-libLTLIBRARIES install-man install-pdf \ - install-pdf-am install-pkgcfgDATA install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am \ - uninstall-binPROGRAMS uninstall-libLTLIBRARIES \ + clean-libLTLIBRARIES clean-libexecPROGRAMS clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-libLTLIBRARIES \ + install-libexecPROGRAMS install-man install-pdf install-pdf-am \ + install-pkgcfgDATA install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-libLTLIBRARIES uninstall-libexecPROGRAMS \ uninstall-pkgcfgDATA +%.py: %.py.in Makefile + $(do_subst) < $(srcdir)/$< > $@ + chmod +x $@ + +test_gnunet_arm.py: test_gnunet_arm.py.in Makefile + $(do_subst) < $(srcdir)/test_gnunet_arm.py.in > test_gnunet_arm.py + chmod +x test_gnunet_arm.py + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/arm/arm.conf.in b/src/arm/arm.conf.in index e72e420..e7620b8 100644 --- a/src/arm/arm.conf.in +++ b/src/arm/arm.conf.in @@ -3,7 +3,6 @@ @UNIXONLY@ PORT = 2087 HOSTNAME = localhost HOME = $SERVICEHOME -CONFIG = $DEFAULTCONFIG BINARY = gnunet-service-arm ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; @@ -11,7 +10,13 @@ DEFAULTSERVICES = topology hostlist dht nse mesh fs UNIXPATH = /tmp/gnunet-service-arm.sock UNIX_MATCH_UID = YES UNIX_MATCH_GID = YES -# GLOBAL_POSTFIX = -l $SERVICEHOME/{}-logs + +# In the "-l" option, format characters from 'strftime' are allowed; +# In the GLOBAL_POSTFIX, "{}" stands for the name of the respective +# service. Thus the following option would introduce per-service +# logging with a new log file each day. Note that only the last 3 +# log files are preserved. +# GLOBAL_POSTFIX = -l $SERVICEHOME/{}-%Y-%m-%d.log # GLOBAL_PREFIX = # USERNAME = # MAXBUF = diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 1b78d33..fd49a18 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c @@ -25,11 +25,8 @@ */ #include "platform.h" #include "gnunet_arm_service.h" -#include "gnunet_client_lib.h" -#include "gnunet_getopt_lib.h" -#include "gnunet_os_lib.h" +#include "gnunet_util_lib.h" #include "gnunet_protocols.h" -#include "gnunet_server_lib.h" #include "arm.h" #define LOG(kind,...) GNUNET_log_from (kind, "arm-api",__VA_ARGS__) @@ -295,6 +292,11 @@ struct RequestContext */ uint16_t type; + /** + * Flags for passing std descriptors to ARM (when starting ARM). + */ + enum GNUNET_OS_InheritStdioFlags std_inheritance; + }; #include "do_start_process.c" @@ -314,6 +316,7 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct RequestContext *pos = cls; struct GNUNET_OS_Process *proc; + char *cbinary; char *binary; char *config; char *loprefix; @@ -342,12 +345,10 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) lopostfix = GNUNET_strdup (""); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "BINARY", - &binary)) + &cbinary)) { - LOG (GNUNET_ERROR_TYPE_WARNING, - _ - ("Configuration failes to specify option `%s' in section `%s'!\n"), - "BINARY", "arm"); + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, + "arm", "BINARY"); if (pos->callback != NULL) pos->callback (pos->cls, GNUNET_ARM_PROCESS_UNKNOWN); GNUNET_free (pos); @@ -358,18 +359,9 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (pos->h->cfg, "arm", "CONFIG", &config)) - { - LOG (GNUNET_ERROR_TYPE_WARNING, - _("Configuration fails to specify option `%s' in section `%s'!\n"), - "CONFIG", "arm"); - if (pos->callback != NULL) - pos->callback (pos->cls, GNUNET_ARM_PROCESS_UNKNOWN); - GNUNET_free (binary); - GNUNET_free (pos); - GNUNET_free (loprefix); - GNUNET_free (lopostfix); - return; - } + config = NULL; + binary = GNUNET_OS_get_libexec_binary_path (cbinary); + GNUNET_free (cbinary); if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (pos->h->cfg, "TESTING", "WEAKRANDOM")) && (GNUNET_YES == @@ -381,28 +373,39 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { /* Means we are ONLY running locally */ /* we're clearly running a test, don't daemonize */ - proc = do_start_process (GNUNET_NO, - NULL, loprefix, binary, "-c", config, - /* no daemonization! */ - lopostfix, NULL); + if (NULL == config) + proc = do_start_process (GNUNET_NO, pos->std_inheritance, + NULL, loprefix, binary, + /* no daemonization! */ + lopostfix, NULL); + else + proc = do_start_process (GNUNET_NO, pos->std_inheritance, + NULL, loprefix, binary, "-c", config, + /* no daemonization! */ + lopostfix, NULL); } else { - proc = do_start_process (GNUNET_NO, - NULL, loprefix, binary, "-c", config, - "-d", lopostfix, NULL); + if (NULL == config) + proc = do_start_process (GNUNET_NO, pos->std_inheritance, + NULL, loprefix, binary, + "-d", lopostfix, NULL); + else + proc = do_start_process (GNUNET_NO, pos->std_inheritance, + NULL, loprefix, binary, "-c", config, + "-d", lopostfix, NULL); } GNUNET_free (binary); - GNUNET_free (config); + GNUNET_free_non_null (config); GNUNET_free (loprefix); GNUNET_free (lopostfix); - if (proc == NULL) - { - if (pos->callback != NULL) - pos->callback (pos->cls, GNUNET_ARM_PROCESS_FAILURE); - GNUNET_free (pos); - return; - } + if (NULL == proc) + { + if (pos->callback != NULL) + pos->callback (pos->cls, GNUNET_ARM_PROCESS_FAILURE); + GNUNET_free (pos); + return; + } if (pos->callback != NULL) pos->callback (pos->cls, GNUNET_ARM_PROCESS_STARTING); GNUNET_free (proc); @@ -427,11 +430,7 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) if ((msg == NULL) || (ntohs (msg->size) != sizeof (struct GNUNET_ARM_ResultMessage))) { - LOG (GNUNET_ERROR_TYPE_WARNING, - _ - ("Error receiving response to `%s' request from ARM for service `%s'\n"), - (sc->type == GNUNET_MESSAGE_TYPE_ARM_START) ? "START" : "STOP", - (const char *) &sc[1]); + GNUNET_break (0); GNUNET_CLIENT_disconnect (sc->h->client); sc->h->client = GNUNET_CLIENT_connect ("arm", sc->h->cfg); GNUNET_assert (NULL != sc->h->client); @@ -482,8 +481,8 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, LOG (GNUNET_ERROR_TYPE_DEBUG, (type == GNUNET_MESSAGE_TYPE_ARM_START) ? - _("Requesting start of service `%s'.\n") : - _("Requesting termination of service `%s'.\n"), service_name); + "Requesting start of service `%s'.\n" : + "Requesting termination of service `%s'.\n", service_name); sctx = GNUNET_malloc (sizeof (struct RequestContext) + slen); sctx->h = h; sctx->callback = cb; @@ -501,12 +500,7 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, (sctx->timeout), GNUNET_YES, &handle_response, sctx)) { - LOG (GNUNET_ERROR_TYPE_WARNING, - (type == - GNUNET_MESSAGE_TYPE_ARM_START) - ? _("Error while trying to transmit request to start `%s' to ARM\n") - : _("Error while trying to transmit request to stop `%s' to ARM\n"), - (const char *) &service_name); + GNUNET_break (0); if (cb != NULL) cb (cb_cls, GNUNET_SYSERR); GNUNET_free (sctx); @@ -522,6 +516,7 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, * * @param h handle to ARM * @param service_name name of the service + * @param std_inheritance inheritance of std streams * @param timeout how long to wait before failing for good * @param cb callback to invoke when service is ready * @param cb_cls closure for callback @@ -529,6 +524,7 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, void GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, const char *service_name, + enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_TIME_Relative timeout, GNUNET_ARM_Callback cb, void *cb_cls) { @@ -537,8 +533,8 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, size_t slen; LOG (GNUNET_ERROR_TYPE_DEBUG, - _("Asked to start service `%s' within %llu ms\n"), service_name, - (unsigned long long) timeout.rel_value); + "Asked to start service `%s' within %s\n", service_name, + GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO)); if (0 == strcasecmp ("arm", service_name)) { slen = strlen ("arm") + 1; @@ -547,12 +543,13 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, sctx->callback = cb; sctx->cls = cb_cls; sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); + sctx->std_inheritance = std_inheritance; memcpy (&sctx[1], service_name, slen); GNUNET_CLIENT_service_test ("arm", h->cfg, timeout, &arm_service_report, sctx); return; } - if (h->client == NULL) + if (NULL == h->client) { client = GNUNET_CLIENT_connect ("arm", h->cfg); if (client == NULL) @@ -586,7 +583,6 @@ arm_shutdown_callback (void *cls, enum GNUNET_ARM_ProcessStatus reason) if (arm_shutdown_ctx->cb != NULL) arm_shutdown_ctx->cb (arm_shutdown_ctx->cb_cls, reason); - GNUNET_free (arm_shutdown_ctx); } @@ -609,8 +605,10 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, struct ARM_ShutdownContext *arm_shutdown_ctx; struct GNUNET_CLIENT_Connection *client; - LOG (GNUNET_ERROR_TYPE_INFO, _("Stopping service `%s' within %llu ms\n"), - service_name, (unsigned long long) timeout.rel_value); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Stopping service `%s' within %s\n", + service_name, + GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO)); if (h->client == NULL) { client = GNUNET_CLIENT_connect ("arm", h->cfg); @@ -682,8 +680,7 @@ handle_list_response (void *cls, const struct GNUNET_MessageHeader *msg) if (NULL == msg) { - LOG (GNUNET_ERROR_TYPE_WARNING, - "Error receiving response to LIST request from ARM\n"); + GNUNET_break (0); GNUNET_CLIENT_disconnect (sc->h->client); sc->h->client = GNUNET_CLIENT_connect ("arm", sc->h->cfg); GNUNET_assert (NULL != sc->h->client); @@ -758,13 +755,10 @@ GNUNET_ARM_list_running_services (struct GNUNET_ARM_Handle *h, client = GNUNET_CLIENT_connect ("arm", h->cfg); if (client == NULL) { - LOG (GNUNET_ERROR_TYPE_DEBUG, - "arm_api, GNUNET_CLIENT_connect returned NULL\n"); + GNUNET_break (0); cb (cb_cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR, 0, NULL); return; } - LOG (GNUNET_ERROR_TYPE_DEBUG, - "arm_api, GNUNET_CLIENT_connect returned non-NULL\n"); h->client = client; } @@ -777,8 +771,8 @@ GNUNET_ARM_list_running_services (struct GNUNET_ARM_Handle *h, msg.type = htons (GNUNET_MESSAGE_TYPE_ARM_LIST); LOG (GNUNET_ERROR_TYPE_DEBUG, - "Requesting LIST from ARM service with timeout: %llu ms\n", - (unsigned long long)timeout.rel_value); + "Requesting LIST from ARM service with timeout: %s\n", + GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES)); if (GNUNET_OK != GNUNET_CLIENT_transmit_and_get_response (sctx->h->client, @@ -789,8 +783,7 @@ GNUNET_ARM_list_running_services (struct GNUNET_ARM_Handle *h, &handle_list_response, sctx)) { - LOG (GNUNET_ERROR_TYPE_WARNING, - "Error while trying to transmit request to list services to ARM\n"); + GNUNET_break (0); if (cb != NULL) cb (cb_cls, GNUNET_SYSERR, 0, NULL); GNUNET_free (sctx); diff --git a/src/arm/do_start_process.c b/src/arm/do_start_process.c index 4554f57..b4bb10c 100644 --- a/src/arm/do_start_process.c +++ b/src/arm/do_start_process.c @@ -1,3 +1,23 @@ +/* + This file is part of GNUnet. + (C) 2011, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + /** * Actually start a process. All of the arguments given to this * function are strings that are used for the "argv" array. However, @@ -8,13 +28,14 @@ * with spaces to the new process. * * @param pipe_control should a pipe be used to send signals to the child? + * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags * @param lsocks array of listen sockets to dup starting at fd3 (systemd-style), or NULL * @param first_arg first argument for argv (may be an empty string) * @param ... more arguments, NULL terminated * @return handle of the started process, NULL on error */ static struct GNUNET_OS_Process * -do_start_process (int pipe_control, +do_start_process (int pipe_control, unsigned int std_inheritance, const SOCKTYPE * lsocks, const char *first_arg, ...) { va_list ap; @@ -26,6 +47,7 @@ do_start_process (int pipe_control, char *cp; const char *last; struct GNUNET_OS_Process *proc; + char *binary_path; argv_size = 1; va_start (ap, first_arg); @@ -97,9 +119,13 @@ do_start_process (int pipe_control, /* *INDENT-ON* */ va_end (ap); argv[argv_size] = NULL; - proc = GNUNET_OS_start_process_v (pipe_control, lsocks, argv[0], argv); + binary_path = argv[0]; + proc = GNUNET_OS_start_process_v (pipe_control, std_inheritance, lsocks, + binary_path, argv); while (argv_size > 0) GNUNET_free (argv[--argv_size]); GNUNET_free (argv); return proc; } + +/* end of do_start_process.c */ diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index 58aa709..8a98ba0 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2009 Christian Grothoff (and other contributing authors) + (C) 2009, 2012, 2013 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -25,11 +25,8 @@ */ #include "platform.h" #include "gnunet_arm_service.h" -#include "gnunet_client_lib.h" #include "gnunet_constants.h" -#include "gnunet_getopt_lib.h" -#include "gnunet_program_lib.h" -#include "gnunet_time_lib.h" +#include "gnunet_util_lib.h" /** * Timeout for stopping services. Long to give some services a real chance. @@ -116,7 +113,7 @@ static struct GNUNET_ARM_Handle *h; /** * Our configuration. */ -static const struct GNUNET_CONFIGURATION_Handle *cfg; +static struct GNUNET_CONFIGURATION_Handle *cfg; /** * Processing stage that we are in. Simple counter. @@ -128,6 +125,16 @@ static unsigned int phase; */ static struct GNUNET_TIME_Relative timeout; +/** + * Do we want to give our stdout to gnunet-service-arm? + */ +static unsigned int no_stdout; + +/** + * Do we want to give our stderr to gnunet-service-arm? + */ +static unsigned int no_stderr; + /** * Main continuation-passing-style loop. Runs the various @@ -199,10 +206,10 @@ confirm_cb (void *cls, FPRINTF (stderr, "%s", _("Unknown response code from ARM.\n")); break; } - GNUNET_SCHEDULER_add_continuation (&cps_loop, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_now (&cps_loop, NULL); } + /** * Callback invoked with the list of running services. * Reports to the user and then runs the next phase in the FSM. @@ -227,40 +234,6 @@ list_cb (void *cls, int result, unsigned int count, const char *const*list) FPRINTF (stdout, "%s\n", list[i]); } -/** - * Main function that will be run by the scheduler. - * - * @param cls closure - * @param args remaining command-line arguments - * @param cfgfile name of the configuration file used (for saving, can be NULL!) - * @param c configuration - */ -static void -run (void *cls, char *const *args, const char *cfgfile, - const struct GNUNET_CONFIGURATION_Handle *c) -{ - cfg = c; - config_file = cfgfile; - if (GNUNET_CONFIGURATION_get_value_string - (cfg, "PATHS", "SERVICEHOME", &dir) != GNUNET_OK) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _ - ("Fatal configuration error: `%s' option in section `%s' missing.\n"), - "SERVICEHOME", "PATHS"); - return; - } - h = GNUNET_ARM_connect (cfg, NULL); - if (h == NULL) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Fatal error initializing ARM API.\n")); - ret = 1; - return; - } - GNUNET_SCHEDULER_add_continuation (&cps_loop, NULL, - GNUNET_SCHEDULER_REASON_PREREQ_DONE); -} /** * Attempts to delete configuration file and SERVICEHOME @@ -288,6 +261,76 @@ delete_files () } } + +/** + * Main continuation-passing-style loop. Runs the various + * jobs that we've been asked to do in order. + * + * @param cls closure, unused + * @param tc context, unused + */ +static void +shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + GNUNET_ARM_disconnect (h); + h = NULL; + if ((end == GNUNET_YES) && (delete == GNUNET_YES)) + delete_files (); + GNUNET_CONFIGURATION_destroy (cfg); + cfg = NULL; +} + + +/** + * Main function that will be run by the scheduler. + * + * @param cls closure + * @param args remaining command-line arguments + * @param cfgfile name of the configuration file used (for saving, can be NULL!) + * @param c configuration + */ +static void +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) +{ + char *armconfig; + + cfg = GNUNET_CONFIGURATION_dup (c); + config_file = cfgfile; + if (GNUNET_CONFIGURATION_get_value_string + (cfg, "PATHS", "SERVICEHOME", &dir) != GNUNET_OK) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "PATHS", "SERVICEHOME"); + return; + } + if (NULL != cfgfile) + { + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, "arm", "CONFIG", + &armconfig)) + { + GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", + cfgfile); + } + else + GNUNET_free (armconfig); + } + if (NULL == (h = GNUNET_ARM_connect (cfg, NULL))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Fatal error initializing ARM API.\n")); + ret = 1; + GNUNET_CONFIGURATION_destroy (cfg); + cfg = NULL; + return; + } + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, + &shutdown_task, NULL); + GNUNET_SCHEDULER_add_now (&cps_loop, NULL); +} + + /** * Main continuation-passing-style loop. Runs the various * jobs that we've been asked to do in order. @@ -298,96 +341,101 @@ delete_files () static void cps_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { + if (NULL == h) + return; + if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) + return; while (1) + { + switch (phase++) { - switch (phase++) + case 0: + if (NULL != term) + { + GNUNET_ARM_stop_service (h, term, + (0 == + timeout.rel_value) ? STOP_TIMEOUT : + timeout, &confirm_cb, term); + return; + } + break; + case 1: + if ((end) || (restart)) + { + GNUNET_ARM_stop_service (h, "arm", + (0 == + timeout.rel_value) ? STOP_TIMEOUT_ARM + : timeout, &confirm_cb, "arm"); + return; + } + break; + case 2: + if (start) + { + GNUNET_ARM_start_service (h, "arm", + (no_stdout ? 0 : GNUNET_OS_INHERIT_STD_OUT) | + (no_stderr ? 0 : GNUNET_OS_INHERIT_STD_ERR), + (0 == + timeout.rel_value) ? START_TIMEOUT : + timeout, &confirm_cb, "arm"); + return; + } + break; + case 3: + if (NULL != init) + { + GNUNET_ARM_start_service (h, init, + (no_stdout ? 0 : GNUNET_OS_INHERIT_STD_OUT) | + (no_stderr ? 0 : GNUNET_OS_INHERIT_STD_ERR), + (0 == + timeout.rel_value) ? START_TIMEOUT : + timeout, &confirm_cb, init); + return; + } + break; + case 4: + if (restart) + { + GNUNET_ARM_disconnect (h); + phase = 0; + end = 0; + start = 1; + restart = 0; + if (NULL == (h = GNUNET_ARM_connect (cfg, NULL))) { - case 0: - if (term != NULL) - { - GNUNET_ARM_stop_service (h, term, - (0 == - timeout.rel_value) ? STOP_TIMEOUT : - timeout, &confirm_cb, term); - return; - } - break; - case 1: - if ((end) || (restart)) - { - GNUNET_ARM_stop_service (h, "arm", - (0 == - timeout.rel_value) ? STOP_TIMEOUT_ARM - : timeout, &confirm_cb, "arm"); - return; - } - break; - case 2: - if (start) - { - GNUNET_ARM_start_service (h, "arm", - (0 == - timeout.rel_value) ? START_TIMEOUT : - timeout, &confirm_cb, "arm"); - return; - } - break; - case 3: - if (init != NULL) - { - GNUNET_ARM_start_service (h, init, - (0 == - timeout.rel_value) ? START_TIMEOUT : - timeout, &confirm_cb, init); - return; - } - break; - case 4: - if (restart) - { - GNUNET_ARM_disconnect (h); - phase = 0; - end = 0; - start = 1; - restart = 0; - h = GNUNET_ARM_connect (cfg, NULL); - if (NULL == h) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Fatal error initializing ARM API.\n")); - ret = 1; - return; - } - GNUNET_SCHEDULER_add_now (&cps_loop, NULL); - return; - } - break; - case 5: - if (list) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Going to list all running services controlled by ARM.\n"); - - if (NULL == h) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Fatal error initializing ARM API.\n")); - return; - } - - GNUNET_ARM_list_running_services (h, - (0 == - timeout.rel_value) ? LIST_TIMEOUT : - timeout, &list_cb, NULL); - return; - } - /* Fall through */ - default: /* last phase */ - GNUNET_ARM_disconnect (h); - if ((end == GNUNET_YES) && (delete == GNUNET_YES)) - delete_files (); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Fatal error initializing ARM API.\n")); + ret = 1; return; } + GNUNET_SCHEDULER_add_now (&cps_loop, NULL); + return; + } + break; + case 5: + if (list) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Going to list all running services controlled by ARM.\n"); + + if (NULL == h) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Fatal error initializing ARM API.\n")); + return; + } + GNUNET_ARM_list_running_services (h, + (0 == + timeout.rel_value) ? LIST_TIMEOUT : + timeout, &list_cb, NULL); + return; + } + /* Fall through */ + default: /* last phase */ + GNUNET_SCHEDULER_shutdown (); + return; } + } } @@ -401,8 +449,6 @@ cps_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) int main (int argc, char *const *argv) { - static unsigned long long temp_timeout_ms; - static const struct GNUNET_GETOPT_CommandLineOption options[] = { {'e', "end", NULL, gettext_noop ("stop all GNUnet services"), GNUNET_NO, &GNUNET_GETOPT_set_one, &end}, @@ -420,16 +466,20 @@ main (int argc, char *const *argv) GNUNET_NO, &GNUNET_GETOPT_set_one, &delete}, {'q', "quiet", NULL, gettext_noop ("don't print status messages"), GNUNET_NO, &GNUNET_GETOPT_set_one, &quiet}, - {'T', "timeout", NULL, - gettext_noop ("timeout for completing current operation"), - GNUNET_YES, &GNUNET_GETOPT_set_ulong, &temp_timeout_ms}, - {'I', "info", NULL, gettext_noop ("List currently running services"), + {'T', "timeout", "MSECS", + gettext_noop ("timeout in MSECS milliseconds for completing current operation"), + GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &timeout}, + {'I', "info", NULL, gettext_noop ("list currently running services"), GNUNET_NO, &GNUNET_GETOPT_set_one, &list}, + {'O', "no-stdout", NULL, gettext_noop ("don't let gnunet-service-arm inherit standard output"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &no_stdout}, + {'E', "no-stderr", NULL, gettext_noop ("don't let gnunet-service-arm inherit standard error"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &no_stderr}, GNUNET_GETOPT_OPTION_END }; - if (temp_timeout_ms > 0) - timeout.rel_value = temp_timeout_ms; + if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) + return 2; if (GNUNET_OK == GNUNET_PROGRAM_run (argc, argv, "gnunet-arm", @@ -437,9 +487,10 @@ main (int argc, char *const *argv) ("Control services and the Automated Restart Manager (ARM)"), options, &run, NULL)) { + GNUNET_free ((void *) argv); return ret; } - + GNUNET_free ((void*) argv); return 1; } diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index ce91043..f16fd52 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -30,12 +30,6 @@ #include "arm.h" /** - * Threshold after which exponential backoff shouldn't increase (in ms); 30m - */ -#define EXPONENTIAL_BACKOFF_THRESHOLD GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30) - - -/** * List of our services. */ struct ServiceList; @@ -246,6 +240,7 @@ start_process (struct ServiceList *sl) struct ServiceListeningInfo *sli; SOCKTYPE *lsocks; unsigned int ls; + char *binary; /* calculate listen socket list */ lsocks = NULL; @@ -317,17 +312,35 @@ start_process (struct ServiceList *sl) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service `%s' using binary `%s' and configuration `%s'\n", sl->name, sl->binary, sl->config); + binary = GNUNET_OS_get_libexec_binary_path (sl->binary); GNUNET_assert (NULL == sl->proc); if (GNUNET_YES == use_debug) - sl->proc = - do_start_process (sl->pipe_control, - lsocks, loprefix, sl->binary, "-c", sl->config, "-L", - "DEBUG", options, NULL); + { + if (NULL == sl->config) + sl->proc = + do_start_process (sl->pipe_control, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + lsocks, loprefix, binary, "-L", + "DEBUG", options, NULL); + else + sl->proc = + do_start_process (sl->pipe_control, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + lsocks, loprefix, binary, "-c", sl->config, "-L", + "DEBUG", options, NULL); + } else - sl->proc = - do_start_process (sl->pipe_control, - lsocks, loprefix, sl->binary, "-c", sl->config, - options, NULL); + { + if (NULL == sl->config) + sl->proc = + do_start_process (sl->pipe_control, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + lsocks, loprefix, binary, + options, NULL); + else + sl->proc = + do_start_process (sl->pipe_control, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + lsocks, loprefix, binary, "-c", sl->config, + options, NULL); + } + GNUNET_free (binary); if (sl->proc == NULL) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to start service `%s'\n"), sl->name); @@ -476,6 +489,7 @@ accept_connection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct ServiceList *sl = sli->sl; sli->accept_task = GNUNET_SCHEDULER_NO_TASK; + GNUNET_assert (GNUNET_NO == in_shutdown); if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) return; start_process (sl); @@ -903,8 +917,9 @@ delayed_restart_task (void *cls, } if (lowestRestartDelay.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will restart process in %llums\n", - (unsigned long long) lowestRestartDelay.rel_value); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Will restart process in %s\n", + GNUNET_STRINGS_relative_time_to_string (lowestRestartDelay, GNUNET_YES)); child_restart_task = GNUNET_SCHEDULER_add_delayed_with_priority (lowestRestartDelay, GNUNET_SCHEDULER_PRIORITY_IDLE, @@ -983,9 +998,9 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (0 != pos->killed_at.abs_value) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Service `%s' took %llu ms to terminate\n"), + _("Service `%s' took %s to terminate\n"), pos->name, - GNUNET_TIME_absolute_get_duration (pos->killed_at).rel_value); + GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (pos->killed_at), GNUNET_YES)); } GNUNET_OS_process_destroy (pos->proc); pos->proc = NULL; @@ -1022,10 +1037,7 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) pos->name, statstr, statcode, pos->backoff.rel_value); /* schedule restart */ pos->restart_at = GNUNET_TIME_relative_to_absolute (pos->backoff); - pos->backoff = - GNUNET_TIME_relative_min (EXPONENTIAL_BACKOFF_THRESHOLD, - GNUNET_TIME_relative_multiply - (pos->backoff, 2)); + pos->backoff = GNUNET_TIME_STD_BACKOFF (pos->backoff); } if (GNUNET_SCHEDULER_NO_TASK != child_restart_task) GNUNET_SCHEDULER_cancel (child_restart_task); @@ -1117,20 +1129,23 @@ setup_service (void *cls, const char *section) return; } config = NULL; - if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, section, "CONFIG", - &config)) || + if (( (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, section, "CONFIG", + &config)) && + (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, "PATHS", "DEFAULTCONFIG", + &config)) ) || (0 != STAT (config, &sbuf))) + { + if (NULL != config) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _ - ("Configuration file `%s' for service `%s' not valid: %s\n"), - config, section, - (config == NULL) ? _("option missing") : STRERROR (errno)); - GNUNET_free (binary); - GNUNET_free_non_null (config); - return; + GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, + section, "CONFIG", + STRERROR (errno)); + GNUNET_free (config); + config = NULL; } + } sl = GNUNET_malloc (sizeof (struct ServiceList)); sl->name = GNUNET_strdup (section); sl->binary = binary; diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c index 086cfc2..608c75c 100644 --- a/src/arm/test_arm_api.c +++ b/src/arm/test_arm_api.c @@ -30,8 +30,6 @@ #include "gnunet_program_lib.h" #include "gnunet_resolver_service.h" -#define VERBOSE GNUNET_NO - #define START_ARM GNUNET_YES #define START_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 1500) @@ -111,7 +109,7 @@ arm_notify (void *cls, enum GNUNET_ARM_ProcessStatus success) GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); #endif } - GNUNET_ARM_start_service (arm, "resolver", START_TIMEOUT, &resolver_notify, + GNUNET_ARM_start_service (arm, "resolver", GNUNET_OS_INHERIT_STD_OUT_AND_ERR, START_TIMEOUT, &resolver_notify, NULL); } @@ -120,10 +118,23 @@ static void task (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { + char *armconfig; cfg = c; + if (NULL != cfgfile) + { + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, "arm", "CONFIG", + &armconfig)) + { + GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", + cfgfile); + } + else + GNUNET_free (armconfig); + } arm = GNUNET_ARM_connect (cfg, NULL); #if START_ARM - GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); + GNUNET_ARM_start_service (arm, "arm", GNUNET_OS_INHERIT_STD_OUT_AND_ERR, START_TIMEOUT, &arm_notify, NULL); #else arm_notify (NULL, GNUNET_YES); #endif @@ -137,9 +148,6 @@ check () char *const argv[] = { "test-arm-api", "-c", "test_arm_api_data.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -159,11 +167,7 @@ main (int argc, char *argv[]) GNUNET_log_setup ("test-arm-api", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); ret = check (); diff --git a/src/arm/test_arm_api_data.conf b/src/arm/test_arm_api_data.conf index 7d56e65..b1000e9 100644 --- a/src/arm/test_arm_api_data.conf +++ b/src/arm/test_arm_api_data.conf @@ -1,27 +1,22 @@ [PATHS] SERVICEHOME = /tmp/test-gnunetd-arm/ -DEFAULTCONFIG = test_arm_api_data.conf [arm] PORT = 23354 DEFAULTSERVICES = BINARY = gnunet-service-arm OPTIONS = -L ERROR -# DEBUG = YES #PREFIX = valgrind --tool=memcheck --leak-check=yes [resolver] -# DEBUG = YES PORT = 23355 # PREFIX = valgrind [do-nothing] -#DEBUG = YES AUTOSTART = NO PORT = 2223 HOSTNAME = localhost HOME = $SERVICEHOME -CONFIG = $DEFAULTCONFIG BINARY = mockup-service ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; @@ -44,13 +39,12 @@ AUTOSTART = NO [statistics] AUTOSTART = YES -# DEBUG = NO - [dns] AUTOSTART = NO - +[consensus] +AUTOSTART = NO [nse] AUTOSTART = NO diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index 77bd9e2..19ca585 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c @@ -28,8 +28,6 @@ #include "gnunet_program_lib.h" #include "gnunet_protocols.h" -#define VERBOSE GNUNET_NO - #define START_ARM GNUNET_YES #define LOG_BACKOFF GNUNET_NO @@ -115,9 +113,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) if (msg == NULL) { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service shutdown complete.\n"); -#endif if (shutdown_ctx->cont != NULL) shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_NO); @@ -131,10 +127,8 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) switch (ntohs (msg->type)) { case GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN: -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received confirmation for service shutdown.\n"); -#endif shutdown_ctx->confirmed = GNUNET_YES; GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, shutdown_ctx, @@ -270,7 +264,7 @@ static void arm_notify (void *cls, enum GNUNET_ARM_ProcessStatus status) { GNUNET_assert (status == GNUNET_ARM_PROCESS_STARTING); - GNUNET_ARM_start_service (arm, "do-nothing", TIMEOUT, &do_nothing_notify, + GNUNET_ARM_start_service (arm, "do-nothing", GNUNET_OS_INHERIT_STD_OUT_AND_ERR, TIMEOUT, &do_nothing_notify, NULL); } @@ -361,11 +355,24 @@ static void task (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { + char *armconfig; cfg = c; + if (NULL != cfgfile) + { + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, "arm", "CONFIG", + &armconfig)) + { + GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", + cfgfile); + } + else + GNUNET_free (armconfig); + } arm = GNUNET_ARM_connect (cfg, NULL); #if START_ARM - GNUNET_ARM_start_service (arm, "arm", GNUNET_TIME_UNIT_ZERO, &arm_notify, + GNUNET_ARM_start_service (arm, "arm", GNUNET_OS_INHERIT_STD_OUT_AND_ERR, GNUNET_TIME_UNIT_ZERO, &arm_notify, NULL); #else arm_do_nothing (NULL, GNUNET_YES); @@ -379,9 +386,6 @@ check () char *const argv[] = { "test-exponential-backoff", "-c", "test_arm_api_data.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -431,11 +435,7 @@ main (int argc, char *argv[]) int ret; GNUNET_log_setup ("test-exponential-backoff", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); init (); diff --git a/src/arm/test_gnunet_arm.py.in b/src/arm/test_gnunet_arm.py.in new file mode 100644 index 0000000..c7698a3 --- /dev/null +++ b/src/arm/test_gnunet_arm.py.in @@ -0,0 +1,106 @@ +#!@PYTHON@ +from __future__ import print_function +import os +import sys +import shutil +import re +import subprocess +import time + +if os.name == "nt": + tmp = os.getenv ("TEMP") +else: + tmp = "/tmp" + +if os.name == 'nt': + st = 'gnunet-statistics.exe' + arm = 'gnunet-arm.exe' +else: + st = 'gnunet-statistics' + arm = 'gnunet-arm' + +run_arm = [arm, '-c', 'test_arm_api_data.conf', '--no-stdout', '--no-stderr'] +debug = os.getenv ('DEBUG') +if debug: + run_arm += [debug.split (' ')] + +def cleanup (): + shutil.rmtree (os.path.join (tmp, "test-gnunetd-arm"), True) + +def sub_run (args, want_stdo = True, want_stde = False, nofail = False): + if want_stdo: + stdo = subprocess.PIPE + else: + stdo = None + if want_stde: + stde = subprocess.PIPE + else: + stde = None + p = subprocess.Popen (args, stdout = stdo, stderr = stde) + stdo, stde = p.communicate () + if not nofail: + if p.returncode != 0: + sys.exit (p.returncode) + return (p.returncode, stdo, stde) + +def fail (result): + print (result) + r_arm (['-e'], want_stdo = False) + sys.exit (1) + + +def end_arm_failer (command, rc, stdo, stde, normal): + if normal: + if rc != 0: + fail ("FAIL: error running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) + else: + if rc == 0: + fail ("FAIL: expected error while running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) + +def print_only_failer (command, rc, stdo, stde, normal): + if normal: + if rc != 0: + print ("FAIL: error running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) + sys.exit (1) + else: + if rc == 0: + print ("FAIL: expected error while running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) + sys.exit (1) + + +def r_something (to_run, extra_args, failer = None, normal = True, **kw): + rc, stdo, stde = sub_run (to_run + extra_args, nofail = True, want_stde = True, **kw) + if failer is not None: + failer (to_run + extra_args, rc, stdo, stde, normal) + return (rc, stdo, stde) + +def r_arm (extra_args, **kw): + return r_something (run_arm, extra_args, **kw) + +cleanup () + +print ("TEST: Bad argument checking...", end='') +r_arm (['-x'], normal = False, failer = print_only_failer) +print ("PASS") + +print ("TEST: Start ARM...", end='') +r_arm (['-s'], failer = print_only_failer) +time.sleep (1) +print ("PASS") + +print ("TEST: Start another service...", end='') +r_arm (['-i', 'resolver'], failer = end_arm_failer) +time.sleep (1) +print ("PASS") + +print ("TEST: Stop a service...", end='') +r_arm (['-k', 'resolver'], failer = end_arm_failer) +time.sleep (1) +print ("PASS") + +print ("TEST: Stop ARM...", end='') +r_arm (['-e'], failer = print_only_failer) +time.sleep (1) +print ("PASS") + +cleanup () diff --git a/src/arm/test_gnunet_arm.sh b/src/arm/test_gnunet_arm.sh deleted file mode 100755 index 4a5b726..0000000 --- a/src/arm/test_gnunet_arm.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh - -exe="./gnunet-arm -c test_arm_api_data.conf" -out=`mktemp /tmp/test-gnunet-arm-logXXXXXXXX` -#DEBUG="-L DEBUG" - - -# ---------------------------------------------------------------------------------- -echo -n "TEST: Bad argument checking... " - -if $exe -x 2> /dev/null; then - echo "FAIL: error running $exe" - exit 1 -fi -echo "PASS" - -# ---------------------------------------------------------------------------------- -echo -n "TEST: Start ARM..." - -if ! $exe $DEBUG -s > $out ; then - echo "FAIL: error running $exe" - echo "Command output was:" - cat $out - exit 1 -fi -echo "PASS" -sleep 1 - -# ---------------------------------------------------------------------------------- -echo -n "TEST: Start another service... " - -if ! $exe $DEBUG -i resolver > $out ; then - echo "FAIL: error running $exe" - echo "Command output was:" - cat $out - kill %% - exit 1 -fi -sleep 1 -echo "PASS" - -# ---------------------------------------------------------------------------------- -echo -n "TEST: Stop a service... " - -if ! $exe $DEBUG -k resolver > $out; then - echo "FAIL: error running $exe" - $exe -e - exit 1 -fi -sleep 1 -echo "PASS" - -# ---------------------------------------------------------------------------------- -echo -n "TEST: Stop ARM... " - -if ! $exe $DEBUG -e > $out; then - echo "FAIL: error running $exe" - exit 1 -fi -sleep 1 -echo "PASS" - -rm -rf /tmp/test-gnunetd-arm/ -rm -f $out - diff --git a/src/arm/test_gnunet_service_manager.c b/src/arm/test_gnunet_service_arm.c index fe33571..d367bc6 100644 --- a/src/arm/test_gnunet_service_manager.c +++ b/src/arm/test_gnunet_service_arm.c @@ -18,10 +18,11 @@ Boston, MA 02111-1307, USA. */ /** - * @file arm/test_gnunet_service_manager.c (A mockup testcase, not functionally complete) - * @brief testcase for gnunet-service-manager.c + * @file arm/test_gnunet_service_arm.c + * @brief testcase for gnunet-service-arm.c; tests ARM by making it start the resolver + * @author Safey + * @author Christian Grothoff */ - #include "platform.h" #include "gnunet_arm_service.h" #include "gnunet_resolver_service.h" @@ -37,18 +38,10 @@ #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) -#define START_ARM GNUNET_YES - -#define VERBOSE GNUNET_NO - static int ret = 1; - -static const struct GNUNET_CONFIGURATION_Handle *cfg; - -#if START_ARM static struct GNUNET_ARM_Handle *arm; -#endif + static void arm_stopped (void *cls, enum GNUNET_ARM_ProcessStatus success) @@ -62,12 +55,11 @@ arm_stopped (void *cls, enum GNUNET_ARM_ProcessStatus success) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM stopped\n"); } -#if START_ARM GNUNET_ARM_disconnect (arm); arm = NULL; -#endif } + static void hostNameResolveCB (void *cls, const struct sockaddr *addr, socklen_t addrlen) { @@ -76,18 +68,14 @@ hostNameResolveCB (void *cls, const struct sockaddr *addr, socklen_t addrlen) if (NULL == addr) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Name not resolved!\n"); -#if START_ARM GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); -#endif ret = 3; return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Resolved hostname, now stopping ARM\n"); ret = 0; -#if START_ARM GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); -#endif } @@ -110,9 +98,7 @@ arm_notify (void *cls, enum GNUNET_ARM_ProcessStatus success) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unable initiate connection to resolver service\n"); ret = 2; -#if START_ARM GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); -#endif } } @@ -121,40 +107,38 @@ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { - cfg = c; -#if START_ARM - arm = GNUNET_ARM_connect (cfg, NULL); - GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); -#else - arm_notify (NULL, GNUNET_YES); -#endif + char *armconfig; + + if (NULL != cfgfile) + { + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (c, "arm", "CONFIG", + &armconfig)) + { + GNUNET_CONFIGURATION_set_value_string (c, "arm", "CONFIG", + cfgfile); + } + else + GNUNET_free (armconfig); + } + arm = GNUNET_ARM_connect (c, NULL); + GNUNET_ARM_start_service (arm, "arm", + GNUNET_OS_INHERIT_STD_OUT_AND_ERR, START_TIMEOUT, + &arm_notify, NULL); } -static void -check () +int +main (int argc, char *av[]) { - char *const argv[] = { - "test-gnunet-service-manager", + static char *const argv[] = { + "test-gnunet-service-arm", "-c", "test_arm_api_data.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; - struct GNUNET_GETOPT_CommandLineOption options[] = { + static struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_assert (GNUNET_OK == - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-gnunet-service-manager", - "nohelp", options, &run, NULL)); -} - - -int -main (int argc, char *argv[]) -{ char hostname[GNUNET_OS_get_hostname_max_length () + 1]; if (0 != gethostname (hostname, sizeof (hostname) - 1)) @@ -172,14 +156,14 @@ main (int argc, char *argv[]) hostname); return 0; } - - GNUNET_log_setup ("test-gnunet-service-manager", -#if VERBOSE - "DEBUG", -#else + GNUNET_log_setup ("test-gnunet-service-arm", "WARNING", -#endif NULL); - check (); + GNUNET_assert (GNUNET_OK == + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, + argv, "test-gnunet-service-arm", + "nohelp", options, &run, NULL)); return ret; } + +/* end of test_gnunet_service_arm.c */ |
