merge
authorChristian Grothoff <christian@grothoff.org>
Thu, 9 Aug 2018 14:43:47 +0000 (16:43 +0200)
committerChristian Grothoff <christian@grothoff.org>
Thu, 9 Aug 2018 14:43:47 +0000 (16:43 +0200)
1  2 
src/cadet/cadet_api.c
src/set/gnunet-service-set_union.c

diff --combined src/cadet/cadet_api.c
index 980b9abbfef9d5cdd46b228186daadd1fb12ec48,92dd39b971d40eba59fde35d8c232d06d5120a22..e2ca461a536280d8336dcfe8670ee8c1c8c0a301
@@@ -841,6 -841,7 +841,7 @@@ handle_mq_error (void *cls
                                             h);
    GNUNET_MQ_destroy (h->mq);
    h->mq = NULL;
+   GNUNET_assert (NULL == h->reconnect_task);
    h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_time,
                                                    &reconnect_cbk,
                                                    h);
@@@ -1253,18 -1254,21 +1254,21 @@@ GNUNET_CADET_disconnect (struct GNUNET_
  void
  GNUNET_CADET_close_port (struct GNUNET_CADET_Port *p)
  {
-   struct GNUNET_CADET_PortMessage *msg;
-   struct GNUNET_MQ_Envelope *env;
    GNUNET_assert (GNUNET_YES ==
                   GNUNET_CONTAINER_multihashmap_remove (p->cadet->ports,
                                                         &p->id,
                                                         p));
-   env = GNUNET_MQ_msg (msg,
-                        GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE);
-   msg->port = p->id;
-   GNUNET_MQ_send (p->cadet->mq,
-                   env);
+   if (NULL != p->cadet->mq)
+   {
+     struct GNUNET_CADET_PortMessage *msg;
+     struct GNUNET_MQ_Envelope *env;
+     env = GNUNET_MQ_msg (msg,
+                          GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE);
+     msg->port = p->id;
+     GNUNET_MQ_send (p->cadet->mq,
+                     env);
+   }
    GNUNET_free_non_null (p->handlers);
    GNUNET_free (p);
  }
  /**
   * Destroy an existing channel.
   *
 - * The existing end callback for the channel will be called immediately.
 + * The existing end callback for the channel will NOT be called.
   * Any pending outgoing messages will be sent but no incoming messages will be
   * accepted and no data callbacks will be called.
   *
@@@ -1296,7 -1300,6 +1300,7 @@@ GNUNET_CADET_channel_destroy (struct GN
    }
    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
              "Destroying channel due to GNUNET_CADET_channel_destroy()\n");
 +  channel->disconnects = NULL;
    destroy_channel (channel);
  }
  
index 8c0c52d643507c1ca84b577838f13deb1cf0e532,c1268948a3dcadeeb78f27693f08dd48705715d9..73d3f5c83f1d330b52f79d3745721e0f64f23c8b
@@@ -11,7 -11,7 +11,7 @@@
        WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        Affero General Public License for more details.
-      
        You should have received a copy of the GNU Affero General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
@@@ -758,8 -758,8 +758,8 @@@ get_order_from_difference (unsigned in
   */
  static int
  send_full_element_iterator (void *cls,
-                        const struct GNUNET_HashCode *key,
-                        void *value)
+                             const struct GNUNET_HashCode *key,
+                             void *value)
  {
    struct Operation *op = cls;
    struct GNUNET_SET_ElementMessage *emsg;
@@@ -1366,6 -1366,26 +1366,26 @@@ send_client_element (struct Operation *
  }
  
  
+ /**
+  * Destroy remote channel.
+  *
+  * @param op operation
+  */
+ static void
+ destroy_channel (struct Operation *op)
+ {
+   struct GNUNET_CADET_Channel *channel;
+   if (NULL != (channel = op->channel))
+   {
+     /* This will free op; called conditionally as this helper function
+        is also called from within the channel disconnect handler. */
+     op->channel = NULL;
+     GNUNET_CADET_channel_destroy (channel);
+   }
+ }
  /**
   * Signal to the client that the operation has finished and
   * destroy the operation.
@@@ -1379,13 -1399,17 +1399,18 @@@ send_client_done (void *cls
    struct GNUNET_MQ_Envelope *ev;
    struct GNUNET_SET_ResultMessage *rm;
  
--  if (GNUNET_YES == op->state->client_done_sent) {
++  if (GNUNET_YES == op->state->client_done_sent)
++  {
      return;
    }
  
    if (PHASE_DONE != op->state->phase) {
      LOG (GNUNET_ERROR_TYPE_WARNING,
-          "union operation failed\n");
+          "Union operation failed\n");
+     GNUNET_STATISTICS_update (_GSS_statistics,
+                               "# Union operations failed",
+                               1,
+                               GNUNET_NO);
      ev = GNUNET_MQ_msg (rm, GNUNET_MESSAGE_TYPE_SET_RESULT);
      rm->result_status = htons (GNUNET_SET_STATUS_FAILURE);
      rm->request_id = htonl (op->client_request_id);
  
    op->state->client_done_sent = GNUNET_YES;
  
+   GNUNET_STATISTICS_update (_GSS_statistics,
+                             "# Union operations succeeded",
+                             1,
+                             GNUNET_NO);
    LOG (GNUNET_ERROR_TYPE_INFO,
         "Signalling client that union operation is done\n");
    ev = GNUNET_MQ_msg (rm,
@@@ -1448,7 -1476,7 +1477,7 @@@ maybe_finish (struct Operation *op
      {
        op->state->phase = PHASE_DONE;
        send_client_done (op);
 -      destroy_channel (op);
 +      _GSS_operation_destroy2 (op);
      }
    }
  }
@@@ -1877,7 -1905,7 +1906,7 @@@ handle_union_p2p_full_done (void *cls
        op->state->phase = PHASE_DONE;
        GNUNET_CADET_receive_done (op->channel);
        send_client_done (op);
 -      destroy_channel (op);
 +      _GSS_operation_destroy2 (op);
        return;
      }
      break;