diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-29 12:26:32 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-29 12:26:32 +0100 |
commit | 45caa641e429136405194085e50305f7f23e98df (patch) | |
tree | bfdcacbcb4f3d834a7713b047c578a532d7fbe3f /common | |
parent | 6a072b2dcf23cbcdb210f2bd5c273ea0f425b188 (diff) | |
download | sink-45caa641e429136405194085e50305f7f23e98df.tar.gz sink-45caa641e429136405194085e50305f7f23e98df.zip |
Don't reference temporary memory
Diffstat (limited to 'common')
-rw-r--r-- | common/commandprocessor.cpp | 5 | ||||
-rw-r--r-- | common/synchronizer.cpp | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/common/commandprocessor.cpp b/common/commandprocessor.cpp index 8eb0ef1..06ee142 100644 --- a/common/commandprocessor.cpp +++ b/common/commandprocessor.cpp | |||
@@ -103,7 +103,7 @@ void CommandProcessor::processFlushCommand(const QByteArray &data) | |||
103 | if (Sink::Commands::VerifyFlushBuffer(verifier)) { | 103 | if (Sink::Commands::VerifyFlushBuffer(verifier)) { |
104 | auto buffer = Sink::Commands::GetFlush(data.constData()); | 104 | auto buffer = Sink::Commands::GetFlush(data.constData()); |
105 | const auto flushType = buffer->type(); | 105 | const auto flushType = buffer->type(); |
106 | const auto flushId = BufferUtils::extractBuffer(buffer->id()); | 106 | const auto flushId = BufferUtils::extractBufferCopy(buffer->id()); |
107 | if (flushType == Sink::Flush::FlushSynchronization) { | 107 | if (flushType == Sink::Flush::FlushSynchronization) { |
108 | mSynchronizer->flush(flushType, flushId); | 108 | mSynchronizer->flush(flushType, flushId); |
109 | } else { | 109 | } else { |
@@ -323,7 +323,8 @@ KAsync::Job<void> CommandProcessor::flush(void const *command, size_t size) | |||
323 | if (Sink::Commands::VerifyFlushBuffer(verifier)) { | 323 | if (Sink::Commands::VerifyFlushBuffer(verifier)) { |
324 | auto buffer = Sink::Commands::GetFlush(command); | 324 | auto buffer = Sink::Commands::GetFlush(command); |
325 | const auto flushType = buffer->type(); | 325 | const auto flushType = buffer->type(); |
326 | const auto flushId = BufferUtils::extractBuffer(buffer->id()); | 326 | const QByteArray flushId = BufferUtils::extractBufferCopy(buffer->id()); |
327 | Q_ASSERT(!flushId.isEmpty()); | ||
327 | if (flushType == Sink::Flush::FlushReplayQueue) { | 328 | if (flushType == Sink::Flush::FlushReplayQueue) { |
328 | SinkTrace() << "Flushing synchronizer "; | 329 | SinkTrace() << "Flushing synchronizer "; |
329 | Q_ASSERT(mSynchronizer); | 330 | Q_ASSERT(mSynchronizer); |
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index 6483cdf..036288e 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp | |||
@@ -268,7 +268,8 @@ void Synchronizer::synchronize(const Sink::QueryBase &query) | |||
268 | 268 | ||
269 | void Synchronizer::flush(int commandId, const QByteArray &flushId) | 269 | void Synchronizer::flush(int commandId, const QByteArray &flushId) |
270 | { | 270 | { |
271 | SinkTrace() << "Flushing the synchronization queue"; | 271 | Q_ASSERT(!flushId.isEmpty()); |
272 | SinkTrace() << "Flushing the synchronization queue " << flushId; | ||
272 | mSyncRequestQueue << Synchronizer::SyncRequest{Synchronizer::SyncRequest::Flush, commandId, flushId}; | 273 | mSyncRequestQueue << Synchronizer::SyncRequest{Synchronizer::SyncRequest::Flush, commandId, flushId}; |
273 | processSyncQueue().exec(); | 274 | processSyncQueue().exec(); |
274 | } | 275 | } |
@@ -318,6 +319,7 @@ KAsync::Job<void> Synchronizer::processSyncQueue() | |||
318 | } | 319 | } |
319 | }); | 320 | }); |
320 | } else if (request.requestType == Synchronizer::SyncRequest::Flush) { | 321 | } else if (request.requestType == Synchronizer::SyncRequest::Flush) { |
322 | Q_ASSERT(!request.requestId.isEmpty()); | ||
321 | if (request.flushType == Flush::FlushReplayQueue) { | 323 | if (request.flushType == Flush::FlushReplayQueue) { |
322 | SinkTrace() << "Emitting flush completion."; | 324 | SinkTrace() << "Emitting flush completion."; |
323 | Sink::Notification n; | 325 | Sink::Notification n; |
@@ -326,7 +328,7 @@ KAsync::Job<void> Synchronizer::processSyncQueue() | |||
326 | emit notify(n); | 328 | emit notify(n); |
327 | } else { | 329 | } else { |
328 | flatbuffers::FlatBufferBuilder fbb; | 330 | flatbuffers::FlatBufferBuilder fbb; |
329 | auto flushId = fbb.CreateString(request.requestId); | 331 | auto flushId = fbb.CreateString(request.requestId.toStdString()); |
330 | auto location = Sink::Commands::CreateFlush(fbb, flushId, static_cast<int>(Sink::Flush::FlushSynchronization)); | 332 | auto location = Sink::Commands::CreateFlush(fbb, flushId, static_cast<int>(Sink::Flush::FlushSynchronization)); |
331 | Sink::Commands::FinishFlushBuffer(fbb, location); | 333 | Sink::Commands::FinishFlushBuffer(fbb, location); |
332 | enqueueCommand(Sink::Commands::FlushCommand, BufferUtils::extractBuffer(fbb)); | 334 | enqueueCommand(Sink::Commands::FlushCommand, BufferUtils::extractBuffer(fbb)); |