Files
@ d11fdaf3e279
Branch filter:
Location: libtransport.git/libtransport/HTTPRequestQueue.cpp - annotation
d11fdaf3e279
1.5 KiB
text/x-c++hdr
systemd: wait for network-online.target and add WantedBy=multi-user.target
Thanks to that, "systemctl enable spectrum2" does what expected, that is
makes Spectrum2 start on boot. Also, network.target doesn't tell anything
meaningful - it's just that the network stack is available.
Adding network-online.target makes sure that the network interfaces are up
before starting Spectrum2.
Thanks to that, "systemctl enable spectrum2" does what expected, that is
makes Spectrum2 start on boot. Also, network.target doesn't tell anything
meaningful - it's just that the network stack is available.
Adding network-online.target makes sure that the network interfaces are up
before starting Spectrum2.
5adb3d1f9733 5adb3d1f9733 26a01b8efa0a 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 eb8f7ddad957 5adb3d1f9733 83ba9855b521 eb8f7ddad957 26a01b8efa0a 26a01b8efa0a 26a01b8efa0a 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 26a01b8efa0a 83ba9855b521 83ba9855b521 83ba9855b521 83ba9855b521 26a01b8efa0a 26a01b8efa0a 26a01b8efa0a a025aa108559 26a01b8efa0a 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 eb8f7ddad957 83ba9855b521 26a01b8efa0a 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 83ba9855b521 eb8f7ddad957 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 83ba9855b521 5adb3d1f9733 eb8f7ddad957 eb8f7ddad957 83ba9855b521 83ba9855b521 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 83ba9855b521 5adb3d1f9733 5adb3d1f9733 eb8f7ddad957 eb8f7ddad957 eb8f7ddad957 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 | #include "transport/HTTPRequestQueue.h"
#include "transport/HTTPRequest.h"
#include "transport/Transport.h"
namespace Transport {
DEFINE_LOGGER(logger, "HTTPRequestQueue")
HTTPRequestQueue::HTTPRequestQueue(Component *component, const std::string &user, int delay) {
m_delay = delay;
m_req = NULL;
m_user = user;
m_queueTimer = component->getNetworkFactories()->getTimerFactory()->createTimer(500);
m_queueTimer->onTick.connect(boost::bind(&HTTPRequestQueue::sendNextRequest, this));
}
HTTPRequestQueue::~HTTPRequestQueue() {
m_queueTimer->stop();
if (m_req) {
m_req->onRequestFinished.disconnect(boost::bind(&HTTPRequestQueue::handleRequestFinished, this));
}
}
void HTTPRequestQueue::handleRequestFinished() {
m_req = NULL;
m_queueTimer->start();
}
void HTTPRequestQueue::sendNextRequest() {
if (m_queue.empty()) {
LOG4CXX_INFO(logger, m_user << ": Queue is empty.");
m_req = NULL;
m_queueTimer->stop();
return;
}
if (m_req) {
LOG4CXX_INFO(logger, m_user << ": There is already a request being handled.");
return;
}
m_req = m_queue.front();
m_queue.pop();
LOG4CXX_INFO(logger, m_user << ": Starting request '" << m_req->getURL() << "'.");
m_req->onRequestFinished.connect(boost::bind(&HTTPRequestQueue::handleRequestFinished, this));
m_req->execute();
}
void HTTPRequestQueue::queueRequest(HTTPRequest *req) {
m_queue.push(req);
if (!m_req) {
sendNextRequest();
}
else {
LOG4CXX_INFO(logger, m_user << ": Request '" << req->getURL() << "' queued.");
}
}
}
|