[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: TNG testing: Handle queues
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: TNG testing: Handle queues properly |
Date: |
Sat, 20 Apr 2019 14:02:09 +0200 |
This is an automated email from the git hooks/post-receive script.
julius-buenger pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 377319503 TNG testing: Handle queues properly
377319503 is described below
commit 37731950386546244483b8037127fb18b12bf9d0
Author: Julius Bünger <address@hidden>
AuthorDate: Sat Apr 20 14:01:16 2019 +0200
TNG testing: Handle queues properly
---
src/transport/test_communicator_unix.c | 3 +-
src/transport/transport-testing2.c | 137 +++++++++++++++++++++++++++++----
src/transport/transport-testing2.h | 19 +++--
3 files changed, 135 insertions(+), 24 deletions(-)
diff --git a/src/transport/test_communicator_unix.c
b/src/transport/test_communicator_unix.c
index 64ba1d5f5..e52391ef2 100644
--- a/src/transport/test_communicator_unix.c
+++ b/src/transport/test_communicator_unix.c
@@ -105,7 +105,8 @@ queue_create_reply_cb (void *cls,
static void
add_queue_cb (void *cls,
- struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
*tc_h)
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
*tc_h,
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
*tc_queue)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Got Queue!\n");
diff --git a/src/transport/transport-testing2.c
b/src/transport/transport-testing2.c
index 9fa6b7761..2abe6c9ce 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -97,9 +97,14 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
char *c_address;
/**
- * @brief Task to request the opening of a view
+ * @brief Head of the queues
*/
- struct GNUNET_MQ_Envelope *open_queue_env;
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_head;
+
+ /**
+ * @brief Tail of the queues
+ */
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_tail;
/* Callbacks + Closures */
/**
@@ -129,6 +134,65 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
};
+struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
+{
+ /**
+ * @brief Handle to the TransportCommunicator
+ */
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h;
+
+ /**
+ * @brief Task to request the opening of a view
+ */
+ struct GNUNET_MQ_Envelope *open_queue_env;
+
+ /**
+ * @brief Peer ID of the peer on the other side of the queue
+ */
+ struct GNUNET_PeerIdentity peer_id;
+
+ /**
+ * @brief Queue ID
+ */
+ uint32_t qid;
+
+ /**
+ * @brief Current message id
+ */
+ uint64_t mid;
+
+ /**
+ * An `enum GNUNET_NetworkType` in NBO.
+ */
+ uint32_t nt;
+
+ /**
+ * Maximum transmission unit, in NBO. UINT32_MAX for unlimited.
+ */
+ uint32_t mtu;
+
+ /**
+ * An `enum GNUNET_TRANSPORT_ConnectionStatus` in NBO.
+ */
+ uint32_t cs;
+
+ /**
+ * @brief Next element inside a DLL
+ */
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *next;
+
+ /**
+ * @brief Previous element inside a DLL
+ */
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *prev;
+};
+
+
+struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission
+{
+};
+
+
/**
* @brief Check whether incoming msg indicating available communicator is
* correct
@@ -290,11 +354,24 @@ handle_add_queue_message (void *cls,
const struct GNUNET_TRANSPORT_AddQueueMessage *msg)
{
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue;
+ tc_queue = tc_h->queue_head;
+ while (tc_queue->qid != msg->qid)
+ {
+ tc_queue = tc_queue->next;
+ }
+ GNUNET_assert (tc_queue->qid == msg->qid);
+ GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id,
+ &msg->receiver));
+ tc_queue->nt = msg->nt;
+ tc_queue->mtu = msg->mtu;
+ tc_queue->cs = msg->cs;
if (NULL != tc_h->add_queue_cb)
{
tc_h->add_queue_cb (tc_h->cb_cls,
- tc_h);
+ tc_h,
+ tc_queue);
}
GNUNET_SERVICE_client_continue (tc_h->client);
}
@@ -329,17 +406,20 @@ connect_cb (void *cls,
struct GNUNET_MQ_Handle *mq)
{
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue_iter;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Client connected.\n");
tc_h->client = client;
tc_h->c_mq = mq;
- if (NULL != tc_h->open_queue_env)
+ if (NULL == tc_h->queue_head) return tc_h;
+ while (NULL != (tc_queue_iter = tc_h->queue_head))
{
+ if (NULL == tc_queue_iter->open_queue_env) continue;
GNUNET_MQ_send (tc_h->c_mq,
- tc_h->open_queue_env);
- tc_h->open_queue_env = NULL;
+ tc_queue_iter->open_queue_env);
+ tc_queue_iter->open_queue_env = NULL;
}
return tc_h;
}
@@ -556,17 +636,14 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue
const struct GNUNET_PeerIdentity *peer_id,
const char *address)
{
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue;
static uint32_t idgen;
char *prefix;
struct GNUNET_TRANSPORT_CreateQueue *msg;
struct GNUNET_MQ_Envelope *env;
size_t alen;
- if (NULL != tc_h->open_queue_env)
- {
- // FIXME: handle multiple queue requests
- return; /* Already waiting for opening of queue */
- }
+ tc_queue = GNUNET_new (struct
GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue);
prefix = GNUNET_HELLO_address_to_prefix (address);
if (NULL == prefix)
{
@@ -578,7 +655,9 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue
alen,
GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE);
msg->request_id = htonl (idgen++);
+ tc_queue->qid = msg->request_id;
msg->receiver = *peer_id;
+ tc_queue->peer_id = *peer_id;
memcpy (&msg[1],
address,
alen);
@@ -589,13 +668,37 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue
}
else
{
- tc_h->open_queue_env = env;
+ tc_queue->open_queue_env = env;
}
+ GNUNET_CONTAINER_DLL_insert (tc_h->queue_head,
+ tc_h->queue_tail,
+ tc_queue);
}
-//struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *
-//GNUNET_TRANSPORT_TESTING_transport_communicator_send
-// (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tcq,
-// const struct GNUNET_MessageHeader *hdr,
-// GNUNET_TRANSPORT_TESTING_SuccessStatus cb, void *cb_cls);
+
+struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *
+GNUNET_TRANSPORT_TESTING_transport_communicator_send
+ (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue,
+ const void *payload,
+ size_t payload_size/*,
+ GNUNET_TRANSPORT_TESTING_SuccessStatus cb,
+ void *cb_cls*/)
+{
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *tc_t;
+ struct GNUNET_TRANSPORT_SendMessageTo *msg;
+ struct GNUNET_MQ_Envelope *env;
+
+ env = GNUNET_MQ_msg_extra (msg,
+ payload_size,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG);
+ msg->qid = htonl (tc_queue->qid);
+ msg->mid = tc_queue->mid++;
+ msg->receiver = tc_queue->peer_id;
+ memcpy (&msg[1],
+ payload,
+ payload_size);
+ GNUNET_MQ_send (tc_queue->tc_h->c_mq,
+ env);
+ return tc_t;
+}
diff --git a/src/transport/transport-testing2.h
b/src/transport/transport-testing2.h
index 6aee919cd..4b9eb0f54 100644
--- a/src/transport/transport-testing2.h
+++ b/src/transport/transport-testing2.h
@@ -32,6 +32,10 @@
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle;
+struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue;
+
+struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission;
+
/**
* @brief Function signature for callbacks that are called when new
communicators become available
*
@@ -62,7 +66,8 @@ typedef void
typedef void
(*GNUNET_TRANSPORT_TESTING_AddQueueCallback)(void *cls,
- struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h);
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue);
/**
@@ -92,9 +97,11 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue
const struct GNUNET_PeerIdentity *peer_id,
const char *address);
-//struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *
-//GNUNET_TRANSPORT_TESTING_transport_communicator_send
-// (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tcq,
-// const struct GNUNET_MessageHeader *hdr,
-// GNUNET_TRANSPORT_TESTING_SuccessStatus cb, void *cb_cls);
+struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *
+GNUNET_TRANSPORT_TESTING_transport_communicator_send
+ (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue,
+ const void *payload,
+ size_t payload_size/*,
+ GNUNET_TRANSPORT_TESTING_SuccessStatus cb,
+ void *cb_cls*/);
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: TNG testing: Handle queues properly,
gnunet <=