avoid deprecated API, use new connecT API
authorChristian Grothoff <christian@grothoff.org>
Sun, 19 Jun 2016 22:53:13 +0000 (22:53 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 19 Jun 2016 22:53:13 +0000 (22:53 +0000)
src/ats/ats_api_connectivity.c
src/ats/ats_api_scheduling.c
src/consensus/consensus_api.c
src/peerstore/peerstore_api.c
src/rps/rps_api.c
src/secretsharing/secretsharing_api.c
src/set/set_api.c
src/util/test_mq_client.c

index 139f50a814933889e4b149f51bca670fb69ea81b..790d3e4cb139e6f34a6eb262e53ec1096cd7ae5e 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2010-2015 GNUnet e.V.
+     Copyright (C) 2010-2016 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -193,19 +193,18 @@ reconnect (struct GNUNET_ATS_ConnectivityHandle *ch)
     { { NULL, 0, 0 } };
   struct GNUNET_MQ_Envelope *ev;
   struct ClientStartMessage *init;
-  struct GNUNET_CLIENT_Connection *client;
 
   GNUNET_assert (NULL == ch->mq);
-  client = GNUNET_CLIENT_connect ("ats", ch->cfg);
-  if (NULL == client)
+  ch->mq = GNUNET_CLIENT_connecT (ch->cfg,
+                                  "ats",
+                                  handlers,
+                                  &error_handler,
+                                  ch);
+  if (NULL == ch->mq)
   {
     force_reconnect (ch);
     return;
   }
-  ch->mq = GNUNET_MQ_queue_for_connection_client (client,
-                                                  handlers,
-                                                  &error_handler,
-                                                  ch);
   ev = GNUNET_MQ_msg (init,
                       GNUNET_MESSAGE_TYPE_ATS_START);
   init->start_flag = htonl (START_FLAG_CONNECTION_SUGGESTION);
index d7e305950f6dcba3c7c142997fbec93616830102..bcca89456f2f9fd89c88dd9ec6ebb6d82f4c20f2 100644 (file)
@@ -529,21 +529,19 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh)
   struct ClientStartMessage *init;
   unsigned int i;
   struct GNUNET_ATS_AddressRecord *ar;
-  struct GNUNET_CLIENT_Connection *client;
 
   GNUNET_assert (NULL == sh->mq);
-  client = GNUNET_CLIENT_connect ("ats",
-                                  sh->cfg);
-  if (NULL == client)
+  sh->mq = GNUNET_CLIENT_connecT (sh->cfg,
+                                  "ats",
+                                  handlers,
+                                  &error_handler,
+                                  sh);
+  if (NULL == sh->mq)
   {
     GNUNET_break (0);
     force_reconnect (sh);
     return;
   }
-  sh->mq = GNUNET_MQ_queue_for_connection_client (client,
-                                                  handlers,
-                                                  &error_handler,
-                                                  sh);
   ev = GNUNET_MQ_msg (init,
                       GNUNET_MESSAGE_TYPE_ATS_START);
   init->start_flag = htonl (START_FLAG_SCHEDULING);
index 7e7bb3fcf22f9d000f82e604a22c40bcbda589d7..2eebcc439f867595ce834c8edbae51bf0eb9894f 100644 (file)
@@ -217,22 +217,21 @@ GNUNET_CONSENSUS_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
   };
   struct GNUNET_CONSENSUS_JoinMessage *join_msg;
   struct GNUNET_MQ_Envelope *ev;
-  struct GNUNET_CLIENT_Connection *client;
 
   consensus->cfg = cfg;
   consensus->new_element_cb = new_element_cb;
   consensus->new_element_cls = new_element_cls;
   consensus->session_id = *session_id;
-  client = GNUNET_CLIENT_connect ("consensus", cfg);
-  if (NULL == client)
+  consensus->mq = GNUNET_CLIENT_connecT (cfg,
+                                         "consensus",
+                                         mq_handlers,
+                                         &mq_error_handler,
+                                         consensus);
+  if (NULL == consensus->mq)
   {
     GNUNET_free (consensus);
     return NULL;
   }
-  consensus->mq = GNUNET_MQ_queue_for_connection_client (client,
-                                                         mq_handlers,
-                                                         &mq_error_handler,
-                                                         consensus);
   ev = GNUNET_MQ_msg_extra (join_msg,
                             (num_peers * sizeof (struct GNUNET_PeerIdentity)),
                             GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN);
index b08de8229751490457dbfd96e7a1115b007dabc4..a288e74d2df162c279929a67aa5807294b4d1194 100644 (file)
@@ -807,7 +807,6 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h)
   void *icb_cls;
   struct GNUNET_PEERSTORE_StoreContext *sc;
   struct GNUNET_MQ_Envelope *ev;
-  struct GNUNET_CLIENT_Connection *client;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Reconnecting...\n");
@@ -830,13 +829,13 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h)
     GNUNET_MQ_destroy (h->mq);
     h->mq = NULL;
   }
-  client = GNUNET_CLIENT_connect ("peerstore",
-                                  h->cfg);
-  if (NULL == client)
+  h->mq = GNUNET_CLIENT_connecT (h->cfg,
+                                 "peerstore",
+                                 mq_handlers,
+                                 &handle_client_error,
+                                 h);
+  if (NULL == h->mq)
     return;
-  h->mq = GNUNET_MQ_queue_for_connection_client (client,
-                                                 mq_handlers,
-                                                 &handle_client_error, h);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Resending pending requests after reconnect.\n");
   if (NULL != h->watches)
index b52e9da51b9443b5d6bcf21678c83cd08908ee0a..16a0c6c5414e92d42a7b574bedf971c7877ece3e 100644 (file)
@@ -221,13 +221,11 @@ reconnect (struct GNUNET_RPS_Handle *h)
 
   if (NULL != h->mq)
     GNUNET_MQ_destroy (h->mq);
-  conn = GNUNET_CLIENT_connect ("rps", h->cfg);
-  if (NULL == conn)
-    return;
-  h->mq = GNUNET_MQ_queue_for_connection_client (conn,
-                                                 mq_handlers,
-                                                 &mq_error_handler,
-                                                 h);
+  h->mq = GNUNET_CLIENT_connecT (h->cfg,
+                                 "rps",
+                                 mq_handlers,
+                                 &mq_error_handler,
+                                 h);
 }
 
 
index e268fc56f00e8cf6bd02ccf40ca027813f1ce15a..7b98a749ca39509d88519a3a28d7328eadabee0d 100644 (file)
@@ -260,10 +260,14 @@ GNUNET_SECRETSHARING_create_session (const struct GNUNET_CONFIGURATION_Handle *c
   };
   struct GNUNET_MQ_Envelope *ev;
   struct GNUNET_SECRETSHARING_CreateMessage *msg;
-  struct GNUNET_CLIENT_Connection *client;
 
-  client = GNUNET_CLIENT_connect ("secretsharing", cfg);
-  if (NULL == client)
+  s->mq = GNUNET_CLIENT_connecT (cfg,
+                                 "secretsharing",
+                                 client,
+                                 mq_handlers,
+                                 &handle_session_client_error,
+                                 s);
+  if (NULL == s->mq)
   {
     /* secretsharing not configured correctly */
     GNUNET_break (0);
@@ -272,12 +276,6 @@ GNUNET_SECRETSHARING_create_session (const struct GNUNET_CONFIGURATION_Handle *c
   }
   s->secret_ready_cb = cb;
   s->secret_ready_cls = cls;
-  s->mq = GNUNET_MQ_queue_for_connection_client (client,
-                                                 mq_handlers,
-                                                 &handle_session_client_error,
-                                                 s);
-  GNUNET_assert (NULL != s->mq);
-
   ev = GNUNET_MQ_msg_extra (msg,
                             num_peers * sizeof (struct GNUNET_PeerIdentity),
                             GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_GENERATE);
@@ -348,20 +346,19 @@ GNUNET_SECRETSHARING_decrypt (const struct GNUNET_CONFIGURATION_Handle *cfg,
   struct GNUNET_MQ_Envelope *ev;
   struct GNUNET_SECRETSHARING_DecryptRequestMessage *msg;
   size_t share_size;
-  struct GNUNET_CLIENT_Connection *client;
 
-  client = GNUNET_CLIENT_connect ("secretsharing", cfg);
-  if (NULL == client)
-    return NULL;
   s->decrypt_cb = decrypt_cb;
   s->decrypt_cls = decrypt_cb_cls;
-
-  s->mq = GNUNET_MQ_queue_for_connection_client (client,
-                                                 mq_handlers,
-                                                 &handle_decrypt_client_error,
-                                                 s);
-  GNUNET_assert (NULL != s->mq);
-
+  s->mq = GNUNET_CLIENT_connecT (cfg,
+                                 "secretsharing",
+                                 mq_handlers,
+                                 &handle_decrypt_client_error,
+                                 s);
+  if (NULL == s->mq)
+  {
+    GNUNET_free (s);
+    return NULL;
+  }
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_SECRETSHARING_share_write (share, NULL, 0,
                                                    &share_size));
index 0b99c7bf65da6ae9f1a232207b495d9209bbde2d..af4907deaf1fd9e4415e64aa4a49456f66635a60 100644 (file)
@@ -903,21 +903,21 @@ listen_connect (void *cls)
   };
   struct GNUNET_MQ_Envelope *mqm;
   struct GNUNET_SET_ListenMessage *msg;
-  struct GNUNET_CLIENT_Connection *client;
 
   lh->reconnect_task = NULL;
   GNUNET_assert (NULL == lh->mq);
-  client = GNUNET_CLIENT_connect ("set", lh->cfg);
-  if (NULL == client)
+  lh->mq = GNUNET_CLIENT_connecT (lh->cfg,
+                                  "set",
+                                  mq_handlers,
+                                  &handle_client_listener_error,
+                                  lh);
+  if (NULL == lh->mq)
     return;
-  lh->mq = GNUNET_MQ_queue_for_connection_client (client,
-                                                  mq_handlers,
-                                                  &handle_client_listener_error,
-                                                 lh);
   mqm = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_LISTEN);
   msg->operation = htonl (lh->operation);
   msg->app_id = lh->app_id;
-  GNUNET_MQ_send (lh->mq, mqm);
+  GNUNET_MQ_send (lh->mq,
+                  mqm);
 }
 
 
index 27458ec0a0a9a1ed134800b637d0a5329bec5746..f436d1a4c74caaa2962925e7d910c405698066e6 100644 (file)
@@ -113,15 +113,13 @@ send_trap_cb (void *cls)
 static void
 test_mq ()
 {
-  struct GNUNET_CLIENT_Connection *client;
   struct GNUNET_MQ_Handle *mq;
   struct GNUNET_MQ_Envelope *mqm;
 
-  client = GNUNET_CLIENT_connect ("test", cfg);
-  GNUNET_assert (client != NULL);
-
   /* FIXME: test handling responses */
-  mq = GNUNET_MQ_queue_for_connection_client (client, NULL, NULL, NULL);
+  mq = GNUNET_CLIENT_connecT (cfg,
+                              "test",
+                              NULL, NULL, NULL);
 
   mqm = GNUNET_MQ_msg_header (MY_TYPE);
   GNUNET_MQ_send (mq, mqm);