From: Safey A.Halim Date: Tue, 2 Feb 2010 09:33:28 +0000 (+0000) Subject: test arm exponential backoff X-Git-Tag: initial-import-from-subversion-38251~22814 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7c227e687a03a00e4e87d8319aa5315a839ddd24;p=oweals%2Fgnunet.git test arm exponential backoff --- diff --git a/src/arm/mockup-service.c b/src/arm/mockup-service.c index d7b57abc2..3fcac6219 100644 --- a/src/arm/mockup-service.c +++ b/src/arm/mockup-service.c @@ -42,12 +42,14 @@ run (void *cls, int main(int argc, char *const *argv) { int ret; - + + fprintf (stderr, "mockup starting\n"); ret = (GNUNET_OK == GNUNET_SERVICE_run (argc, argv, "do-nothing", GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; + fprintf (stderr, "mockup stopping\n"); return ret; } diff --git a/src/arm/mockup_service b/src/arm/mockup_service new file mode 100755 index 000000000..32f4ccc14 --- /dev/null +++ b/src/arm/mockup_service @@ -0,0 +1,130 @@ +#! /bin/sh + +# mockup_service - temporary wrapper script for .libs/mockup_service +# Generated by ltmain.sh (GNU libtool) 2.2.6 +# +# The mockup_service program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/usr/bin/sed -e 1s/^X//' +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variables: + generated_by_libtool_version='2.2.6' + notinst_deplibs=' ../../src/util/libgnunetutil.la' +else + # When we are sourced in execute mode, $file and $ECHO are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + ECHO="echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then + # Yippee, $ECHO works! + : + else + # Restart under the correct shell, and then maybe $ECHO will work. + exec /bin/sh "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /usr/bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$ECHO "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /usr/bin/sed -n 's/.*-> //p'` + done + + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no + if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then + # special case for '.' + if test "$thisdir" = "."; then + thisdir=`pwd` + fi + # remove .libs from thisdir + case "$thisdir" in + *[\\/].libs ) thisdir=`$ECHO "X$thisdir" | $Xsed -e 's%[\\/][^\\/]*$%%'` ;; + .libs ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program='mockup_service' + progdir="$thisdir/.libs" + + + if test -f "$progdir/$program"; then + # Add our own library path to DYLD_LIBRARY_PATH + DYLD_LIBRARY_PATH="/Users/soufi/Career/Munich/TUM/MasterOfScience/Research/GNUnet/EclipseWorkspaceGNUnet/gnunet/src/util/.libs:$DYLD_LIBRARY_PATH" + + # Some systems cannot cope with colon-terminated DYLD_LIBRARY_PATH + # The second colon is a workaround for a bug in BeOS R4 sed + DYLD_LIBRARY_PATH=`$ECHO "X$DYLD_LIBRARY_PATH" | $Xsed -e 's/::*$//'` + + export DYLD_LIBRARY_PATH + + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec "$progdir/$program" ${1+"$@"} + + $ECHO "$0: cannot exec $program $*" 1>&2 + exit 1 + fi + else + # The program doesn't exist. + $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 + $ECHO "This script is just a wrapper for $program." 1>&2 + echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index 75f70fb13..0208cbafa 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c @@ -27,8 +27,11 @@ #include "gnunet_configuration_lib.h" #include "gnunet_program_lib.h" +#define VERBOSE GNUNET_YES #define START_ARM GNUNET_YES #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) +#define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL +#define FIVE_MILLISECONDS GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5) static struct GNUNET_SCHEDULER_Handle *sched; static const struct GNUNET_CONFIGURATION_Handle *cfg; @@ -37,6 +40,7 @@ static int ok = 1; static FILE *killLogFilePtr; static char *killLogFileName; + static void arm_notify_stop (void *cls, int success) { @@ -47,8 +51,12 @@ arm_notify_stop (void *cls, int success) } +<<<<<<< .mine +static void +======= static void +>>>>>>> .r10190 do_nothing_notify (void *cls, int success) { GNUNET_assert (success == GNUNET_YES); @@ -68,13 +76,24 @@ static void kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc); static void -do_nothing_restarted_notify_task (void *unused, +do_nothing_restarted_notify_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) -{ +{ static char a; static int trialCount = 0; - + trialCount++; +<<<<<<< .mine + + if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) { + fprintf(killLogFilePtr, "%d.Reason is shutdown!\n", trialCount); + } + else if ((tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0) { + fprintf(killLogFilePtr, "%d.Reason is timeout!\n", trialCount); + } + else if ((tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE) != 0) { + fprintf(killLogFilePtr, "%d.Service is running!\n", trialCount); +======= if (trialCount >= 11) { if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) fprintf(killLogFilePtr, "Reason is shutdown!\n"); @@ -82,9 +101,10 @@ do_nothing_restarted_notify_task (void *unused, fprintf(killLogFilePtr, "%d.Reason is timeout!\n", trialCount); else if ((tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE) != 0) fprintf(killLogFilePtr, "%d.Service is running!\n", trialCount); +>>>>>>> .r10190 } - GNUNET_SCHEDULER_add_now (sched, &kill_task, &a); // checks if this was too fast + GNUNET_SCHEDULER_add_now (sched, &kill_task, &a); } @@ -92,12 +112,16 @@ static void kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) { - int* reason; - struct GNUNET_CLIENT_Connection * doNothingConnection = NULL; + static struct GNUNET_CLIENT_Connection * doNothingConnection = NULL; static struct GNUNET_TIME_Absolute startedWaitingAt; struct GNUNET_TIME_Relative waitedFor; static int trialCount = 0; +<<<<<<< .mine + if (NULL != cbData) { + waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt); + fprintf(killLogFilePtr, "Waited for: %lld milliseconds\n\n", waitedFor.value); +======= reason = cbData; if (NULL != reason) { waitedFor = GNUNET_TIME_absolute_get_duration(startedWaitingAt); @@ -108,32 +132,25 @@ kill_task (void *cbData, trialCount, (unsigned long long) startedWaitingAt.value, (unsigned long long) waitedFor.value); +>>>>>>> .r10190 } - /* Connect to the doNothing task */ + /* Connect to the doNothing task */ doNothingConnection = GNUNET_CLIENT_connect (sched, "do-nothing", cfg); if (NULL == doNothingConnection) fprintf(killLogFilePtr, "Unable to connect to do-nothing process!\n"); - else if (trialCount == 20) { + + if (trialCount == 20) { GNUNET_ARM_stop_service (arm, "do-nothing", TIMEOUT, &arm_notify_stop, NULL); return; } - /* Use the created connection to kill the doNothingTask */ + /* Use the created connection to kill the doNothingTask */ GNUNET_CLIENT_service_shutdown(doNothingConnection); - sleep(0.005); + trialCount++; startedWaitingAt = GNUNET_TIME_absolute_get(); - /* - * There is something wrong here! - * TIMEOUT value is set to 10 seconds (a drastically large value) - * debugging is showing that the reason for which - * do_nothing_restarted_notify_task is called is "always" - * TIMEOUT which means that the "do-nothing" service is not running - * however the overall execution time doesn't exceed 2 seconds - * which means there is something tricky about the TIMOUT passed - * to function GNUNET_CLIENT_service_test() - */ - GNUNET_CLIENT_service_test(sched, "do-nothing", cfg, TIMEOUT, &do_nothing_restarted_notify_task, NULL); + sleep(1); + GNUNET_CLIENT_service_test(sched, "do-nothing", cfg, GNUNET_TIME_UNIT_SECONDS, &do_nothing_restarted_notify_task, NULL); } static void diff --git a/src/util/client.c b/src/util/client.c index bd360dd6f..d66ce9ed0 100644 --- a/src/util/client.c +++ b/src/util/client.c @@ -34,7 +34,7 @@ #include "gnunet_server_lib.h" #include "gnunet_scheduler_lib.h" -#define DEBUG_CLIENT GNUNET_NO +#define DEBUG_CLIENT GNUNET_YES /** @@ -687,11 +687,20 @@ GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched, } conn->test_cb = task; conn->test_cb_cls = task_cls; + + + if (NULL == GNUNET_CLIENT_notify_transmit_ready (conn, + sizeof (struct GNUNET_MessageHeader), + timeout, + GNUNET_YES, + &write_test, NULL)) + /* if (NULL == GNUNET_CONNECTION_notify_transmit_ready (conn->sock, sizeof (struct GNUNET_MessageHeader), timeout, &write_test, NULL)) + */ { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failure to transmit request to service `%s'\n"), @@ -730,6 +739,7 @@ client_delayed_retry (void *cls, { struct GNUNET_CLIENT_TransmitHandle *th = cls; + fprintf (stderr, "cdr running\n"); th->reconnect_task = GNUNET_SCHEDULER_NO_TASK; if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) { @@ -785,6 +795,11 @@ client_notify (void *cls, size_t size, void *buf) (0 == --th->attempts_left) || (delay.value < 1) ) { + fprintf (stderr, "Signaling timeout, reason: %d %d %d %d\n", + (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason (th->sock->sched))), + (GNUNET_YES != th->auto_retry), + (0 == --th->attempts_left) , + (delay.value < 1) ); #if DEBUG_CLIENT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmission failed %u times, giving up.\n", @@ -803,7 +818,7 @@ client_notify (void *cls, size_t size, void *buf) th->sock->ignore_shutdown); delay = GNUNET_TIME_relative_min (delay, th->sock->back_off); th->sock->back_off - = GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply (th->sock->back_off, 2), + = GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply (th->sock->back_off, 2), GNUNET_TIME_UNIT_SECONDS); #if DEBUG_CLIENT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,