aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSafey A.Halim <safey.allah@gmail.com>2010-02-02 09:33:28 +0000
committerSafey A.Halim <safey.allah@gmail.com>2010-02-02 09:33:28 +0000
commit7c227e687a03a00e4e87d8319aa5315a839ddd24 (patch)
tree9a39015a6655bfc5b6fa7f5d0bb61063576697a7 /src
parentba7332c3c403e89e8af5193707ce2d699f942229 (diff)
downloadgnunet-7c227e687a03a00e4e87d8319aa5315a839ddd24.tar.gz
gnunet-7c227e687a03a00e4e87d8319aa5315a839ddd24.zip
test arm exponential backoff
Diffstat (limited to 'src')
-rw-r--r--src/arm/mockup-service.c4
-rwxr-xr-xsrc/arm/mockup_service130
-rw-r--r--src/arm/test_exponential_backoff.c59
-rw-r--r--src/util/client.c19
4 files changed, 188 insertions, 24 deletions
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,
42int main(int argc, char *const *argv) 42int main(int argc, char *const *argv)
43{ 43{
44 int ret; 44 int ret;
45 45
46 fprintf (stderr, "mockup starting\n");
46 ret = (GNUNET_OK == 47 ret = (GNUNET_OK ==
47 GNUNET_SERVICE_run (argc, 48 GNUNET_SERVICE_run (argc,
48 argv, 49 argv,
49 "do-nothing", GNUNET_SERVICE_OPTION_NONE, 50 "do-nothing", GNUNET_SERVICE_OPTION_NONE,
50 &run, NULL)) ? 0 : 1; 51 &run, NULL)) ? 0 : 1;
51 52
53 fprintf (stderr, "mockup stopping\n");
52 return ret; 54 return ret;
53} 55}
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 @@
1#! /bin/sh
2
3# mockup_service - temporary wrapper script for .libs/mockup_service
4# Generated by ltmain.sh (GNU libtool) 2.2.6
5#
6# The mockup_service program cannot be directly executed until all the libtool
7# libraries that it depends on are installed.
8#
9# This wrapper script should never be moved out of the build directory.
10# If it is, it will not operate correctly.
11
12# Sed substitution that helps us do robust quoting. It backslashifies
13# metacharacters that are still active within double-quoted strings.
14Xsed='/usr/bin/sed -e 1s/^X//'
15sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
16
17# Be Bourne compatible
18if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
19 emulate sh
20 NULLCMD=:
21 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
22 # is contrary to our usage. Disable this feature.
23 alias -g '${1+"$@"}'='"$@"'
24 setopt NO_GLOB_SUBST
25else
26 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
27fi
28BIN_SH=xpg4; export BIN_SH # for Tru64
29DUALCASE=1; export DUALCASE # for MKS sh
30
31# The HP-UX ksh and POSIX shell print the target directory to stdout
32# if CDPATH is set.
33(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
34
35relink_command=""
36
37# This environment variable determines our operation mode.
38if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
39 # install mode needs the following variables:
40 generated_by_libtool_version='2.2.6'
41 notinst_deplibs=' ../../src/util/libgnunetutil.la'
42else
43 # When we are sourced in execute mode, $file and $ECHO are already set.
44 if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
45 ECHO="echo"
46 file="$0"
47 # Make sure echo works.
48 if test "X$1" = X--no-reexec; then
49 # Discard the --no-reexec flag, and continue.
50 shift
51 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
52 # Yippee, $ECHO works!
53 :
54 else
55 # Restart under the correct shell, and then maybe $ECHO will work.
56 exec /bin/sh "$0" --no-reexec ${1+"$@"}
57 fi
58 fi
59
60 # Find the directory that this script lives in.
61 thisdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'`
62 test "x$thisdir" = "x$file" && thisdir=.
63
64 # Follow symbolic links until we get to the real thisdir.
65 file=`ls -ld "$file" | /usr/bin/sed -n 's/.*-> //p'`
66 while test -n "$file"; do
67 destdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'`
68
69 # If there was a directory component, then change thisdir.
70 if test "x$destdir" != "x$file"; then
71 case "$destdir" in
72 [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
73 *) thisdir="$thisdir/$destdir" ;;
74 esac
75 fi
76
77 file=`$ECHO "X$file" | $Xsed -e 's%^.*/%%'`
78 file=`ls -ld "$thisdir/$file" | /usr/bin/sed -n 's/.*-> //p'`
79 done
80
81
82 # Usually 'no', except on cygwin/mingw when embedded into
83 # the cwrapper.
84 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
85 if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
86 # special case for '.'
87 if test "$thisdir" = "."; then
88 thisdir=`pwd`
89 fi
90 # remove .libs from thisdir
91 case "$thisdir" in
92 *[\\/].libs ) thisdir=`$ECHO "X$thisdir" | $Xsed -e 's%[\\/][^\\/]*$%%'` ;;
93 .libs ) thisdir=. ;;
94 esac
95 fi
96
97 # Try to get the absolute directory name.
98 absdir=`cd "$thisdir" && pwd`
99 test -n "$absdir" && thisdir="$absdir"
100
101 program='mockup_service'
102 progdir="$thisdir/.libs"
103
104
105 if test -f "$progdir/$program"; then
106 # Add our own library path to DYLD_LIBRARY_PATH
107 DYLD_LIBRARY_PATH="/Users/soufi/Career/Munich/TUM/MasterOfScience/Research/GNUnet/EclipseWorkspaceGNUnet/gnunet/src/util/.libs:$DYLD_LIBRARY_PATH"
108
109 # Some systems cannot cope with colon-terminated DYLD_LIBRARY_PATH
110 # The second colon is a workaround for a bug in BeOS R4 sed
111 DYLD_LIBRARY_PATH=`$ECHO "X$DYLD_LIBRARY_PATH" | $Xsed -e 's/::*$//'`
112
113 export DYLD_LIBRARY_PATH
114
115 if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
116 # Run the actual program with our arguments.
117
118 exec "$progdir/$program" ${1+"$@"}
119
120 $ECHO "$0: cannot exec $program $*" 1>&2
121 exit 1
122 fi
123 else
124 # The program doesn't exist.
125 $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
126 $ECHO "This script is just a wrapper for $program." 1>&2
127 echo "See the libtool documentation for more information." 1>&2
128 exit 1
129 fi
130fi
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 @@
27#include "gnunet_configuration_lib.h" 27#include "gnunet_configuration_lib.h"
28#include "gnunet_program_lib.h" 28#include "gnunet_program_lib.h"
29 29
30#define VERBOSE GNUNET_YES
30#define START_ARM GNUNET_YES 31#define START_ARM GNUNET_YES
31#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) 32#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
33#define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL
34#define FIVE_MILLISECONDS GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5)
32 35
33static struct GNUNET_SCHEDULER_Handle *sched; 36static struct GNUNET_SCHEDULER_Handle *sched;
34static const struct GNUNET_CONFIGURATION_Handle *cfg; 37static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -37,6 +40,7 @@ static int ok = 1;
37static FILE *killLogFilePtr; 40static FILE *killLogFilePtr;
38static char *killLogFileName; 41static char *killLogFileName;
39 42
43
40static void 44static void
41arm_notify_stop (void *cls, int success) 45arm_notify_stop (void *cls, int success)
42{ 46{
@@ -47,8 +51,12 @@ arm_notify_stop (void *cls, int success)
47} 51}
48 52
49 53
54<<<<<<< .mine
55static void
56=======
50 57
51static void 58static void
59>>>>>>> .r10190
52do_nothing_notify (void *cls, int success) 60do_nothing_notify (void *cls, int success)
53{ 61{
54 GNUNET_assert (success == GNUNET_YES); 62 GNUNET_assert (success == GNUNET_YES);
@@ -68,13 +76,24 @@ static void
68kill_task (void *cbData, 76kill_task (void *cbData,
69 const struct GNUNET_SCHEDULER_TaskContext *tc); 77 const struct GNUNET_SCHEDULER_TaskContext *tc);
70static void 78static void
71do_nothing_restarted_notify_task (void *unused, 79do_nothing_restarted_notify_task (void *cls,
72 const struct GNUNET_SCHEDULER_TaskContext *tc) 80 const struct GNUNET_SCHEDULER_TaskContext *tc)
73{ 81{
74 static char a; 82 static char a;
75 static int trialCount = 0; 83 static int trialCount = 0;
76 84
77 trialCount++; 85 trialCount++;
86<<<<<<< .mine
87
88 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) {
89 fprintf(killLogFilePtr, "%d.Reason is shutdown!\n", trialCount);
90 }
91 else if ((tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0) {
92 fprintf(killLogFilePtr, "%d.Reason is timeout!\n", trialCount);
93 }
94 else if ((tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE) != 0) {
95 fprintf(killLogFilePtr, "%d.Service is running!\n", trialCount);
96=======
78 if (trialCount >= 11) { 97 if (trialCount >= 11) {
79 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 98 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
80 fprintf(killLogFilePtr, "Reason is shutdown!\n"); 99 fprintf(killLogFilePtr, "Reason is shutdown!\n");
@@ -82,9 +101,10 @@ do_nothing_restarted_notify_task (void *unused,
82 fprintf(killLogFilePtr, "%d.Reason is timeout!\n", trialCount); 101 fprintf(killLogFilePtr, "%d.Reason is timeout!\n", trialCount);
83 else if ((tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE) != 0) 102 else if ((tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE) != 0)
84 fprintf(killLogFilePtr, "%d.Service is running!\n", trialCount); 103 fprintf(killLogFilePtr, "%d.Service is running!\n", trialCount);
104>>>>>>> .r10190
85 } 105 }
86 106
87 GNUNET_SCHEDULER_add_now (sched, &kill_task, &a); // checks if this was too fast 107 GNUNET_SCHEDULER_add_now (sched, &kill_task, &a);
88} 108}
89 109
90 110
@@ -92,12 +112,16 @@ static void
92kill_task (void *cbData, 112kill_task (void *cbData,
93 const struct GNUNET_SCHEDULER_TaskContext *tc) 113 const struct GNUNET_SCHEDULER_TaskContext *tc)
94{ 114{
95 int* reason; 115 static struct GNUNET_CLIENT_Connection * doNothingConnection = NULL;
96 struct GNUNET_CLIENT_Connection * doNothingConnection = NULL;
97 static struct GNUNET_TIME_Absolute startedWaitingAt; 116 static struct GNUNET_TIME_Absolute startedWaitingAt;
98 struct GNUNET_TIME_Relative waitedFor; 117 struct GNUNET_TIME_Relative waitedFor;
99 static int trialCount = 0; 118 static int trialCount = 0;
100 119
120<<<<<<< .mine
121 if (NULL != cbData) {
122 waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt);
123 fprintf(killLogFilePtr, "Waited for: %lld milliseconds\n\n", waitedFor.value);
124=======
101 reason = cbData; 125 reason = cbData;
102 if (NULL != reason) { 126 if (NULL != reason) {
103 waitedFor = GNUNET_TIME_absolute_get_duration(startedWaitingAt); 127 waitedFor = GNUNET_TIME_absolute_get_duration(startedWaitingAt);
@@ -108,32 +132,25 @@ kill_task (void *cbData,
108 trialCount, 132 trialCount,
109 (unsigned long long) startedWaitingAt.value, 133 (unsigned long long) startedWaitingAt.value,
110 (unsigned long long) waitedFor.value); 134 (unsigned long long) waitedFor.value);
135>>>>>>> .r10190
111 } 136 }
112 137
113 /* Connect to the doNothing task */ 138 /* Connect to the doNothing task */
114 doNothingConnection = GNUNET_CLIENT_connect (sched, "do-nothing", cfg); 139 doNothingConnection = GNUNET_CLIENT_connect (sched, "do-nothing", cfg);
115 if (NULL == doNothingConnection) 140 if (NULL == doNothingConnection)
116 fprintf(killLogFilePtr, "Unable to connect to do-nothing process!\n"); 141 fprintf(killLogFilePtr, "Unable to connect to do-nothing process!\n");
117 else if (trialCount == 20) { 142
143 if (trialCount == 20) {
118 GNUNET_ARM_stop_service (arm, "do-nothing", TIMEOUT, &arm_notify_stop, NULL); 144 GNUNET_ARM_stop_service (arm, "do-nothing", TIMEOUT, &arm_notify_stop, NULL);
119 return; 145 return;
120 } 146 }
121 147
122 /* Use the created connection to kill the doNothingTask */ 148 /* Use the created connection to kill the doNothingTask */
123 GNUNET_CLIENT_service_shutdown(doNothingConnection); 149 GNUNET_CLIENT_service_shutdown(doNothingConnection);
124 sleep(0.005); 150 trialCount++;
125 startedWaitingAt = GNUNET_TIME_absolute_get(); 151 startedWaitingAt = GNUNET_TIME_absolute_get();
126 /* 152 sleep(1);
127 * There is something wrong here! 153 GNUNET_CLIENT_service_test(sched, "do-nothing", cfg, GNUNET_TIME_UNIT_SECONDS, &do_nothing_restarted_notify_task, NULL);
128 * TIMEOUT value is set to 10 seconds (a drastically large value)
129 * debugging is showing that the reason for which
130 * do_nothing_restarted_notify_task is called is "always"
131 * TIMEOUT which means that the "do-nothing" service is not running
132 * however the overall execution time doesn't exceed 2 seconds
133 * which means there is something tricky about the TIMOUT passed
134 * to function GNUNET_CLIENT_service_test()
135 */
136 GNUNET_CLIENT_service_test(sched, "do-nothing", cfg, TIMEOUT, &do_nothing_restarted_notify_task, NULL);
137} 154}
138 155
139static void 156static 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 @@
34#include "gnunet_server_lib.h" 34#include "gnunet_server_lib.h"
35#include "gnunet_scheduler_lib.h" 35#include "gnunet_scheduler_lib.h"
36 36
37#define DEBUG_CLIENT GNUNET_NO 37#define DEBUG_CLIENT GNUNET_YES
38 38
39 39
40/** 40/**
@@ -687,11 +687,20 @@ GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched,
687 } 687 }
688 conn->test_cb = task; 688 conn->test_cb = task;
689 conn->test_cb_cls = task_cls; 689 conn->test_cb_cls = task_cls;
690
691
692 if (NULL == GNUNET_CLIENT_notify_transmit_ready (conn,
693 sizeof (struct GNUNET_MessageHeader),
694 timeout,
695 GNUNET_YES,
696 &write_test, NULL))
697 /*
690 if (NULL == 698 if (NULL ==
691 GNUNET_CONNECTION_notify_transmit_ready (conn->sock, 699 GNUNET_CONNECTION_notify_transmit_ready (conn->sock,
692 sizeof (struct 700 sizeof (struct
693 GNUNET_MessageHeader), 701 GNUNET_MessageHeader),
694 timeout, &write_test, NULL)) 702 timeout, &write_test, NULL))
703 */
695 { 704 {
696 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 705 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
697 _("Failure to transmit request to service `%s'\n"), 706 _("Failure to transmit request to service `%s'\n"),
@@ -730,6 +739,7 @@ client_delayed_retry (void *cls,
730{ 739{
731 struct GNUNET_CLIENT_TransmitHandle *th = cls; 740 struct GNUNET_CLIENT_TransmitHandle *th = cls;
732 741
742 fprintf (stderr, "cdr running\n");
733 th->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 743 th->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
734 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 744 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
735 { 745 {
@@ -785,6 +795,11 @@ client_notify (void *cls, size_t size, void *buf)
785 (0 == --th->attempts_left) || 795 (0 == --th->attempts_left) ||
786 (delay.value < 1) ) 796 (delay.value < 1) )
787 { 797 {
798 fprintf (stderr, "Signaling timeout, reason: %d %d %d %d\n",
799 (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason (th->sock->sched))),
800 (GNUNET_YES != th->auto_retry),
801 (0 == --th->attempts_left) ,
802 (delay.value < 1) );
788#if DEBUG_CLIENT 803#if DEBUG_CLIENT
789 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 804 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
790 "Transmission failed %u times, giving up.\n", 805 "Transmission failed %u times, giving up.\n",
@@ -803,7 +818,7 @@ client_notify (void *cls, size_t size, void *buf)
803 th->sock->ignore_shutdown); 818 th->sock->ignore_shutdown);
804 delay = GNUNET_TIME_relative_min (delay, th->sock->back_off); 819 delay = GNUNET_TIME_relative_min (delay, th->sock->back_off);
805 th->sock->back_off 820 th->sock->back_off
806 = GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply (th->sock->back_off, 2), 821 = GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply (th->sock->back_off, 2),
807 GNUNET_TIME_UNIT_SECONDS); 822 GNUNET_TIME_UNIT_SECONDS);
808#if DEBUG_CLIENT 823#if DEBUG_CLIENT
809 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 824 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,