diff options
author | Olivier Roques <oroques@cisco.com> | 2019-11-12 09:51:34 +0000 |
---|---|---|
committer | Olivier Roques <olvrqs@gmail.com> | 2019-11-14 10:48:26 +0000 |
commit | 92bc1a46f8e33cc664a95819fde45b9b5b4ac321 (patch) | |
tree | 3057a8a30788fb887cfa846a040a36edd2e79da7 /libtransport/src/hicn/transport/interfaces | |
parent | 34d819b0cf58fa3a96b5cae84b825b5a8a633cd4 (diff) |
[HICN-393] Fix various issues related to manifests
The current manifest implementation is broken:
1. ManifestIndexingManager, responsible for validating manifests and
segments and retrieving the next ones, assumes that all manifests
have the same size. This assumption affects the retrieval of next
manifests which is based on the number of segments the current
manifest contains. Therefore when a non-full manifests arrives,
the computed suffix of the next manifest is wrong and refer to a
content instead, which results in an error.
2. Manifests are used to update a suffix queue which stores all
the segments listed in manifests. This queue is used to retrieve
content sequentially via a pointer indicating the next content to
fetch. When the pointer reaches the end of the suffix queue, the
consumer stops sending interests. The correct behavior would be to
wait for a new manifest which would update the queue.
This patch fixes these two issues:
1. Issue 1 was fixed by using SuffixManifest (HICN-392). This allows
to set the capacity of a manifest at the start of the consumption
instead of checking each time the size of the current manifest and
then using that (non-constant) value to retrieve the next manifests.
2. Issue 2 was fixed by passing to ManifestIndexingManager a reference
to an object capable of calling the scheduleNextInterest function,
which is then called after a new manifest is retrieved to make sure
interests for content kept being sent. This is not an optimal solution
but rather a temporary one, until the retrieval of manifests is done
at the transport level rather than in ManifestIndexingManager.
This patch also changes the order of production: manifests are now
sent before content. To do so, contents are added into a queue until
the manifest is complete.
Signed-off-by: Olivier Roques <olvrqs@gmail.com>
Change-Id: I1a1bb92ca1cf2d3c745c1b65f6c7376f916c679b
Diffstat (limited to 'libtransport/src/hicn/transport/interfaces')
-rw-r--r-- | libtransport/src/hicn/transport/interfaces/socket_producer.cc | 19 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/interfaces/socket_producer.h | 3 |
2 files changed, 19 insertions, 3 deletions
diff --git a/libtransport/src/hicn/transport/interfaces/socket_producer.cc b/libtransport/src/hicn/transport/interfaces/socket_producer.cc index 5cf40cd1c..7d7f4a0fe 100644 --- a/libtransport/src/hicn/transport/interfaces/socket_producer.cc +++ b/libtransport/src/hicn/transport/interfaces/socket_producer.cc @@ -267,6 +267,12 @@ uint32_t ProducerSocket::produce(Name content_name, identity->getSigner().sign(*manifest); passContentObjectToCallbacks(manifest); + // Send content objects stored in the queue + while (!content_queue_.empty()) { + passContentObjectToCallbacks(content_queue_.front()); + content_queue_.pop(); + } + // Create new manifest. The reference to the last manifest has been // acquired in the passContentObjectToCallbacks function, so we can // safely release this reference @@ -317,11 +323,14 @@ uint32_t ProducerSocket::produce(Name content_name, using namespace std::chrono_literals; utils::CryptoHash hash = content_object->computeDigest(hash_algo); manifest->addSuffixHash(suffix_content.getSuffix(), hash); - } else if (identity) { - identity->getSigner().sign(*content_object); + content_queue_.push(content_object); + } else { + if (identity) { + identity->getSigner().sign(*content_object); + } + passContentObjectToCallbacks(content_object); } - passContentObjectToCallbacks(content_object); suffix_content++; } @@ -337,6 +346,10 @@ uint32_t ProducerSocket::produce(Name content_name, manifest->encode(); identity->getSigner().sign(*manifest); passContentObjectToCallbacks(manifest); + while (!content_queue_.empty()) { + passContentObjectToCallbacks(content_queue_.front()); + content_queue_.pop(); + } } if (on_content_produced_) { diff --git a/libtransport/src/hicn/transport/interfaces/socket_producer.h b/libtransport/src/hicn/transport/interfaces/socket_producer.h index 952587b70..1f1acd401 100644 --- a/libtransport/src/hicn/transport/interfaces/socket_producer.h +++ b/libtransport/src/hicn/transport/interfaces/socket_producer.h @@ -194,6 +194,9 @@ class ProducerSocket : public Socket<BasePortal>, utils::SuffixManifest suffix_manifest_; utils::SuffixContent suffix_content_; + // While manifests are being built, contents are stored in a queue + std::queue<std::shared_ptr<ContentObject>> content_queue_; + // callbacks ProducerInterestCallback on_interest_input_; ProducerInterestCallback on_interest_dropped_input_buffer_; |