Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerkaraszewski committed Jan 13, 2025
1 parent 95780b4 commit 5f74f58
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
14 changes: 0 additions & 14 deletions sqlitecluster/SQLiteNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2566,22 +2566,9 @@ STCPManager::Socket* SQLiteNode::_acceptSocket() {
void SQLiteNode::_processPeerMessages(uint64_t& nextActivity, SQLitePeer* peer, bool unlimited) {
try {
size_t messagesDeqeued = 0;
if (unlimited) {
if (peer->socket) {
string recvBuffer = peer->socket->recvBuffer.c_str();
if (recvBuffer.size()) {
SINFO("TYLER: peer recv buffer " << peer->socket->recvBuffer);
}
} else {
SINFO("TYLER: no socket");
}
}
while (true) {
SData message = peer->popMessage();
_onMESSAGE(peer, message);
if (unlimited) {
SINFO("TYLER: processed message with unlimited set " << message.methodLine);
}
messagesDeqeued++;
if (messagesDeqeued >= 100 && !unlimited) {
// We should run again immediately, we have more to do.
Expand Down Expand Up @@ -2664,7 +2651,6 @@ void SQLiteNode::postPoll(fd_map& fdm, uint64_t& nextActivity) {
// Now check established peer connections.
for (SQLitePeer* peer : _peerList) {
auto result = peer->postPoll(fdm, nextActivity);

switch (result) {
case SQLitePeer::PeerPostPollStatus::JUST_CONNECTED:
{
Expand Down
2 changes: 0 additions & 2 deletions sqlitecluster/SQLitePeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ SQLitePeer::PeerPostPollStatus SQLitePeer::postPoll(fd_map& fdm, uint64_t& nextA
} else {
SHMMM("Lost peer connection after " << (STimeNow() - socket->openTime) / 1000 << "ms, reconnecting in " << delay / 1000 << "ms");
}
// Can't reset until the buffer is cleared.
// reset();
nextReconnect = STimeNow() + delay;
nextActivity = min(nextActivity, nextReconnect.load());
return PeerPostPollStatus::SOCKET_CLOSED;
Expand Down
3 changes: 2 additions & 1 deletion sqlitecluster/SQLitePeer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class SQLitePeer {
// If there are no messages, throws `std::out_of_range`.
SData popMessage();

// NOTE: If this returns PeerPostPollStatus::SOCKET_CLOSED then the caller must call `reset` on this peer.
// This is not done internally becuase we need to expose the outstanding data on the socket before deleting it.
PeerPostPollStatus postPoll(fd_map& fdm, uint64_t& nextActivity);

// Send a message to this peer. Thread-safe.
Expand Down Expand Up @@ -104,7 +106,6 @@ class SQLitePeer {
mutable recursive_mutex peerMutex;

// Not named with an underscore because it's only sort-of private (see friend class declaration above).
public:
STCPManager::Socket* socket = nullptr;
};

Expand Down

0 comments on commit 5f74f58

Please sign in to comment.