aboutsummaryrefslogtreecommitdiff
path: root/src/arm/test_exponential_backoff.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-04-19 18:51:22 +0000
committerChristian Grothoff <christian@grothoff.org>2012-04-19 18:51:22 +0000
commit39e90459cc68f5a33942a1751c6e4b8f85bd25f1 (patch)
treeb73e806c757ea07a52255e71ba1cad2ef57d9b3f /src/arm/test_exponential_backoff.c
parent8e0637f1a72107a8ac1d312ce084644ee27d7981 (diff)
downloadgnunet-39e90459cc68f5a33942a1751c6e4b8f85bd25f1.tar.gz
gnunet-39e90459cc68f5a33942a1751c6e4b8f85bd25f1.zip
-fixes
Diffstat (limited to 'src/arm/test_exponential_backoff.c')
-rw-r--r--src/arm/test_exponential_backoff.c82
1 files changed, 35 insertions, 47 deletions
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c
index 15756657f..77bd9e2ce 100644
--- a/src/arm/test_exponential_backoff.c
+++ b/src/arm/test_exponential_backoff.c
@@ -113,59 +113,47 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg)
113{ 113{
114 struct ShutdownContext *shutdown_ctx = cls; 114 struct ShutdownContext *shutdown_ctx = cls;
115 115
116 if ((msg == NULL) && (shutdown_ctx->confirmed != GNUNET_YES)) 116 if (msg == NULL)
117 { 117 {
118 /* Means the other side closed the connection and never confirmed a shutdown */
119 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
120 "Service handle shutdown before ACK!\n");
121 if (shutdown_ctx->cont != NULL)
122 shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_SYSERR);
123 GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task);
124 GNUNET_CLIENT_disconnect (shutdown_ctx->sock);
125 GNUNET_free (shutdown_ctx);
126 }
127 else if ((msg == NULL) && (shutdown_ctx->confirmed == GNUNET_YES))
128 {
129#if VERBOSE 118#if VERBOSE
130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service shutdown complete.\n"); 119 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service shutdown complete.\n");
131#endif 120#endif
132 if (shutdown_ctx->cont != NULL) 121 if (shutdown_ctx->cont != NULL)
133 shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_NO); 122 shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_NO);
134 123
135 GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task); 124 GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task);
136 GNUNET_CLIENT_disconnect (shutdown_ctx->sock); 125 GNUNET_CLIENT_disconnect (shutdown_ctx->sock);
137 GNUNET_free (shutdown_ctx); 126 GNUNET_free (shutdown_ctx);
138 } 127 return;
139 else 128 }
140 { 129 GNUNET_assert (ntohs (msg->size) ==
141 GNUNET_assert (ntohs (msg->size) == 130 sizeof (struct GNUNET_MessageHeader));
142 sizeof (struct GNUNET_MessageHeader)); 131 switch (ntohs (msg->type))
143 switch (ntohs (msg->type)) 132 {
144 { 133 case GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN:
145 case GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN:
146#if VERBOSE 134#if VERBOSE
147 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 135 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
148 "Received confirmation for service shutdown.\n"); 136 "Received confirmation for service shutdown.\n");
149#endif 137#endif
150 shutdown_ctx->confirmed = GNUNET_YES; 138 shutdown_ctx->confirmed = GNUNET_YES;
151 GNUNET_CLIENT_receive (shutdown_ctx->sock, 139 GNUNET_CLIENT_receive (shutdown_ctx->sock,
152 &service_shutdown_handler, shutdown_ctx, 140 &service_shutdown_handler, shutdown_ctx,
153 GNUNET_TIME_UNIT_FOREVER_REL); 141 GNUNET_TIME_UNIT_FOREVER_REL);
154 break; 142 break;
155 default: /* Fall through */ 143 default: /* Fall through */
156 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 144 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
157 "Service shutdown refused!\n"); 145 "Service shutdown refused!\n");
158 if (shutdown_ctx->cont != NULL) 146 if (shutdown_ctx->cont != NULL)
159 shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_YES); 147 shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_YES);
160 148
161 GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task); 149 GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task);
162 GNUNET_CLIENT_disconnect (shutdown_ctx->sock); 150 GNUNET_CLIENT_disconnect (shutdown_ctx->sock);
163 GNUNET_free (shutdown_ctx); 151 GNUNET_free (shutdown_ctx);
164 break; 152 break;
165 } 153 }
166 }
167} 154}
168 155
156
169/** 157/**
170 * Shutting down took too long, cancel receive and return error. 158 * Shutting down took too long, cancel receive and return error.
171 * 159 *