Adding a shared queue in Socket class#184
Conversation
include/Core/Models/SpentOutput.h
Outdated
| { | ||
| const uint8_t version = byteBuffer.ReadU8(); | ||
| assert(version == 0); | ||
| assert(byteBuffer.ReadU8() == 0); |
There was a problem hiding this comment.
Revert this change. If compiled with NDEBUG (many release builds), anything inside of assertions isn't executed, so it will deserialize incorrectly.
| pConnection->SendSync(TxHashSetArchiveMessage{ pHeader->GetHash(), pHeader->GetHeight(), fileSize }); | ||
|
|
||
| std::vector<uint8_t> buffer(BUFFER_SIZE, 0); | ||
| uint64_t totalBytesRead = 0; |
There was a problem hiding this comment.
Just remove unused code, don't comment it out.
src/PMMR/TxHashSetImpl.cpp
Outdated
| void TxHashSet::SaveOutputPositions(const Chain::CPtr& pChain, std::shared_ptr<IBlockDB> pBlockDB) const | ||
| { | ||
| uint64_t firstOutput = 0; | ||
| // uint64_t firstOutput = 0; |
There was a problem hiding this comment.
Just remove, don't comment it out.
src/Server/Node/API/TxHashSetAPI.cpp
Outdated
| { | ||
| Json::Value outputNode; | ||
| const EOutputFeatures features = info.GetIdentifier().GetFeatures(); | ||
| // const EOutputFeatures features = info.GetIdentifier().GetFeatures(); |
There was a problem hiding this comment.
Just remove, don't comment it out.
| for (const WalletTx& walletTx : transactions) | ||
| { | ||
| sqlite3_stmt* stmt = nullptr; | ||
| // sqlite3_stmt* stmt = nullptr; |
There was a problem hiding this comment.
Just remove, don't comment it out.
| TEST_CASE("Bech32Address") | ||
| { | ||
| uint8_t version = 1; | ||
| // uint8_t version = 1; |
There was a problem hiding this comment.
Just remove, don't comment it out.
include/Common/SharedQueue.h
Outdated
| SharedQueue<T>::~SharedQueue() {} | ||
|
|
||
| template <typename T> | ||
| T& SharedQueue<T>::front() |
There was a problem hiding this comment.
Move the function implementations into the actual class definition. Otherwise, I think you'll have issues if trying to include this header in multiple places.
template <typename T>
class SharedQueue
{
public:
SharedQueue() = default;
~SharedQueue() = default;
T& front()
{
// implement here
}
void pop_front()
{
// implement here
}
void push_back(const T& item)
{
// implement here
}
void push_back(T&& item)
{
// implement here
}
int size()
{
// implement here
}
bool empty()
{
// implement here
}
private:
std::deque<T> queue_;
std::mutex mutex_;
std::condition_variable cond_;
};
| #include <condition_variable> | ||
|
|
||
| template <typename T> | ||
| class SharedQueue |
There was a problem hiding this comment.
Why is this class even needed? Does ConcurrentQueue not do what you need?
There was a problem hiding this comment.
ConcurrentQueue is subject to race conditions between calls to empty, front and pop if there is more than one thread; we could either use SharedQueue class or edit the ConcurrentQueue class. More here https://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html
src/Net/Socket.cpp
Outdated
| m_writeQueue.push(message); | ||
|
|
||
| if (!first_in_queue) { | ||
| if (!m_writeQueue.empty()) { |
There was a problem hiding this comment.
This isn't correct. Since you aren't adding message to the queue, if something's already being written to the socket, we just drop message.
| release_command: 'npm run clean_build:nix && npm run release' | ||
| - name: ubuntu | ||
| os: ubuntu-16.04 | ||
| os: ubuntu-18.04 |
There was a problem hiding this comment.
We had some users running older Debian instances, which is why we built with 16.04. We're probably good to update this to 18.04 now, but you should check with the channel first, if you haven't already.
There was a problem hiding this comment.
Ubuntu 16.04 environment was removed on September 20, 2021 actions/runner-images#3287
There was a problem hiding this comment.
I guess we don't really have a choice then. You'll want to mention that in the next release announcement.
| peersToUpdate.push_back(peerEntry.m_peer); | ||
| peerEntry.m_peer->SetDirty(false); | ||
| } else if (peerEntry.m_peer->GetLastContactTime() > 0 && peerEntry.m_peer->GetLastContactTime() < minimumContactTime) { | ||
| peerManager.m_peersByAddress.erase(iter); |
Uh oh!
There was an error while loading. Please reload this page.