Merge branch 'master' of ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / rps / gnunet-service-rps.c
index 11a2215c5714024feb56c67f72ced3d907010883..adcfe7d02fa6e539f9911d735f111e64ab1551a4 100644 (file)
@@ -926,7 +926,10 @@ destroy_reply_cls (struct ReplyCls *rep_cls)
 
   cli_ctx = rep_cls->cli_ctx;
   GNUNET_assert (NULL != cli_ctx);
-  RPS_sampler_request_cancel (rep_cls->req_handle);
+  if (NULL != rep_cls->req_handle)
+  {
+    RPS_sampler_request_cancel (rep_cls->req_handle);
+  }
   GNUNET_CONTAINER_DLL_remove (cli_ctx->rep_cls_head,
                                cli_ctx->rep_cls_tail,
                                rep_cls);
@@ -1035,6 +1038,7 @@ client_respond (void *cls,
 
   cli_ctx = reply_cls->cli_ctx;
   GNUNET_assert (NULL != cli_ctx);
+  reply_cls->req_handle = NULL;
   destroy_reply_cls (reply_cls);
   GNUNET_MQ_send (cli_ctx->mq, ev);
 }
@@ -1186,7 +1190,7 @@ handle_client_seed (void *cls,
 
   ////GNUNET_free (peers);
 
-  GNUNET_SERVICE_client_drop (cli_ctx->client);
+  GNUNET_SERVICE_client_continue (cli_ctx->client);
 }
 
 /**
@@ -1504,7 +1508,7 @@ compute_rand_delay (struct GNUNET_TIME_Relative mean,
    * via multiplying round_interval with a 'fraction' (0 to value)/value
    */
   rand_delay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, max_rand_delay);
-  ret = GNUNET_TIME_relative_multiply (mean,  rand_delay);
+  ret = GNUNET_TIME_relative_saturating_multiply (mean,  rand_delay);
   ret = GNUNET_TIME_relative_divide   (ret, max_rand_delay);
   ret = GNUNET_TIME_relative_add      (ret, half_interval);
 
@@ -2237,8 +2241,8 @@ client_connect_cb (void *cls,
  */
 static void
 client_disconnect_cb (void *cls,
-                                 struct GNUNET_SERVICE_Client *client,
-                                 void *internal_cls)
+                      struct GNUNET_SERVICE_Client *client,
+                      void *internal_cls)
 {
   struct ClientContext *cli_ctx = internal_cls;
 
@@ -2390,7 +2394,7 @@ run (void *cls,
   struct GNUNET_TIME_Relative half_round_interval;
   struct GNUNET_TIME_Relative  max_round_interval;
 
-  half_round_interval = GNUNET_TIME_relative_multiply (round_interval, .5);
+  half_round_interval = GNUNET_TIME_relative_divide (round_interval, 2);
   max_round_interval = GNUNET_TIME_relative_add (round_interval, half_round_interval);
 
   prot_sampler =   RPS_sampler_init     (sampler_size_est_need, max_round_interval);