m_SSL.reset();
m_Socket->Close();
+ m_Socket.reset();
m_Eof = true;
m_SSL.reset();
m_Socket->Close();
+ m_Socket.reset();
m_ErrorCode = ERR_peek_error();
m_ErrorOccurred = true;
*/
void TlsStream::Close(void)
{
+ SocketEvents::Unregister();
+
boost::mutex::scoped_lock lock(m_Mutex);
if (!m_SSL)
(void) SSL_shutdown(m_SSL.get());
m_SSL.reset();
- SocketEvents::Unregister();
-
m_Socket->Close();
+ m_Socket.reset();
m_Eof = true;
}
{
BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjectsByType<Endpoint>()) {
BOOST_FOREACH(const ApiClient::Ptr& client, endpoint->GetClients()) {
+ if (endpoint->GetSyncing()) {
+ Log(LogInformation, "ApiClient")
+ << "Not sending heartbeat for endpoint '" << endpoint->GetName() << "' because we're replaying the log for it.";
+ continue;
+ }
+
if (client->m_NextHeartbeat != 0 && client->m_NextHeartbeat < Utility::GetTime()) {
Log(LogWarning, "ApiClient")
<< "Client for endpoint '" << endpoint->GetName() << "' has requested "
void ApiClient::TimeoutTimerHandler(void)
{
- if (m_Seen < Utility::GetTime() - 60) {
+ if (m_Seen < Utility::GetTime() - 60 && !m_Endpoint->GetSyncing()) {
/* Obtain a strong reference to ourselves because Disconnect otherwise removes the last reference */
ApiClient::Ptr self = this;
#include "remote/apilistener.hpp"
#include "remote/apiclient.hpp"
#include "remote/endpoint.hpp"
+#include "remote/jsonrpc.hpp"
#include "base/convert.hpp"
#include "base/netstring.hpp"
#include "base/json.hpp"
int count = -1;
double peer_ts = endpoint->GetLocalLogPosition();
+ double logpos_ts = peer_ts;
bool last_sync = false;
Endpoint::Ptr target_endpoint = client->GetEndpoint();
Log(LogNotice, "ApiListener")
<< "Replaying log: " << path;
- std::fstream *fp = new std::fstream(path.CStr(), std::fstream::in);
+ std::fstream *fp = new std::fstream(path.CStr(), std::fstream::in | std::fstream::binary);
StdioStream::Ptr logStream = new StdioStream(fp, true);
String message;
count++;
peer_ts = pmessage->Get("timestamp");
+
+ if (ts > logpos_ts + 10) {
+ logpos_ts = ts;
+
+ Dictionary::Ptr lparams = new Dictionary();
+ lparams->Set("log_position", logpos_ts);
+
+ Dictionary::Ptr lmessage = new Dictionary();
+ lmessage->Set("jsonrpc", "2.0");
+ lmessage->Set("method", "log::SetLogPosition");
+ lmessage->Set("params", lparams);
+
+ JsonRpc::SendMessage(client->GetStream(), lmessage);
+ }
}
logStream->Close();