aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_timeout.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api_timeout.c')
-rw-r--r--src/transport/test_transport_api_timeout.c122
1 files changed, 61 insertions, 61 deletions
diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c
index dd2639136..80a457d15 100644
--- a/src/transport/test_transport_api_timeout.c
+++ b/src/transport/test_transport_api_timeout.c
@@ -34,9 +34,9 @@
34/** 34/**
35 * How long until we give up on transmitting the message? 35 * How long until we give up on transmitting the message?
36 */ 36 */
37#define WAIT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30) 37#define WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
38 38
39#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90) 39#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90)
40 40
41#define MTYPE 12345 41#define MTYPE 12345
42 42
@@ -52,94 +52,94 @@ static unsigned int disconnects;
52 52
53 53
54static void 54static void
55custom_shutdown(void *cls) 55custom_shutdown (void *cls)
56{ 56{
57 if (NULL != timer_task) 57 if (NULL != timer_task)
58 { 58 {
59 GNUNET_SCHEDULER_cancel(timer_task); 59 GNUNET_SCHEDULER_cancel (timer_task);
60 timer_task = NULL; 60 timer_task = NULL;
61 } 61 }
62 if (0 == disconnects) 62 if (0 == disconnects)
63 { 63 {
64 ccc->global_ret = GNUNET_OK; 64 ccc->global_ret = GNUNET_OK;
65 } 65 }
66 else 66 else
67 { 67 {
68 ccc->global_ret = -GNUNET_SYSERR; 68 ccc->global_ret = -GNUNET_SYSERR;
69 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 69 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
70 "Fail! Had %u disconnects while waiting %s\n", 70 "Fail! Had %u disconnects while waiting %s\n",
71 disconnects, 71 disconnects,
72 GNUNET_STRINGS_relative_time_to_string(WAIT, 72 GNUNET_STRINGS_relative_time_to_string (WAIT,
73 GNUNET_YES)); 73 GNUNET_YES));
74 } 74 }
75} 75}
76 76
77 77
78static void 78static void
79notify_receive(void *cls, 79notify_receive (void *cls,
80 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, 80 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
81 const struct GNUNET_PeerIdentity *sender, 81 const struct GNUNET_PeerIdentity *sender,
82 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) 82 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
83{ 83{
84 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 84 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
85 "Received message of type %d from peer %s!\n", 85 "Received message of type %d from peer %s!\n",
86 ntohs(message->header.type), 86 ntohs (message->header.type),
87 GNUNET_i2s(sender)); 87 GNUNET_i2s (sender));
88} 88}
89 89
90 90
91static void 91static void
92notify_disconnect(void *cls, 92notify_disconnect (void *cls,
93 struct GNUNET_TRANSPORT_TESTING_PeerContext *me, 93 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
94 const struct GNUNET_PeerIdentity *other) 94 const struct GNUNET_PeerIdentity *other)
95{ 95{
96 GNUNET_TRANSPORT_TESTING_log_disconnect(cls, 96 GNUNET_TRANSPORT_TESTING_log_disconnect (cls,
97 me, 97 me,
98 other); 98 other);
99 if (shutdown_flag != GNUNET_YES) 99 if (shutdown_flag != GNUNET_YES)
100 { 100 {
101 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 101 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
102 "FAIL! Peer `%s' disconnected during waiting period!\n", 102 "FAIL! Peer `%s' disconnected during waiting period!\n",
103 GNUNET_i2s(other)); 103 GNUNET_i2s (other));
104 disconnects++; 104 disconnects++;
105 } 105 }
106} 106}
107 107
108 108
109static void 109static void
110timer(void *cls) 110timer (void *cls)
111{ 111{
112 static unsigned int percentage; 112 static unsigned int percentage;
113 113
114 timer_task = NULL; 114 timer_task = NULL;
115 percentage += 10; 115 percentage += 10;
116 time_running = GNUNET_TIME_relative_add(time_running, 116 time_running = GNUNET_TIME_relative_add (time_running,
117 GNUNET_TIME_relative_divide(WAIT, 117 GNUNET_TIME_relative_divide (WAIT,
118 10)); 118 10));
119 119
120 if (time_running.rel_value_us == 120 if (time_running.rel_value_us ==
121 GNUNET_TIME_relative_max(time_running, WAIT).rel_value_us) 121 GNUNET_TIME_relative_max (time_running, WAIT).rel_value_us)
122 { 122 {
123 fprintf(stderr, "%s", "100%%\n"); 123 fprintf (stderr, "%s", "100%%\n");
124 shutdown_flag = GNUNET_YES; 124 shutdown_flag = GNUNET_YES;
125 GNUNET_SCHEDULER_shutdown(); 125 GNUNET_SCHEDULER_shutdown ();
126 } 126 }
127 else 127 else
128 { 128 {
129 fprintf(stderr, 129 fprintf (stderr,
130 "%u%%..", 130 "%u%%..",
131 percentage); 131 percentage);
132 timer_task = 132 timer_task =
133 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_divide(WAIT, 10), 133 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (WAIT, 10),
134 &timer, 134 &timer,
135 NULL); 135 NULL);
136 } 136 }
137} 137}
138 138
139 139
140int 140int
141main(int argc, 141main (int argc,
142 char *argv[]) 142 char *argv[])
143{ 143{
144 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = { 144 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = {
145 .connect_continuation = &timer, 145 .connect_continuation = &timer,
@@ -153,9 +153,9 @@ main(int argc,
153 153
154 ccc = &my_ccc; 154 ccc = &my_ccc;
155 if (GNUNET_OK != 155 if (GNUNET_OK !=
156 GNUNET_TRANSPORT_TESTING_main(2, 156 GNUNET_TRANSPORT_TESTING_main (2,
157 &GNUNET_TRANSPORT_TESTING_connect_check, 157 &GNUNET_TRANSPORT_TESTING_connect_check,
158 ccc)) 158 ccc))
159 return 1; 159 return 1;
160 return 0; 160 return 0;
161} 161}