HTTP subsystem refactoring, fixed possible crashes shortly after destroying daemon or self-select client.

This commit is contained in:
XMRig 2020-02-23 01:40:19 +07:00
parent 23c51c9a11
commit 1ee27a564b
No known key found for this signature in database
GPG key ID: 446A53638BE94409
16 changed files with 129 additions and 58 deletions

View file

@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -54,6 +54,8 @@ xmrig::Httpd::Httpd(Base *base) :
m_server(nullptr),
m_port(0)
{
m_httpListener = std::make_shared<HttpListener>(this);
base->addListener(this);
}
@ -69,7 +71,7 @@ bool xmrig::Httpd::start()
return true;
}
m_http = new HttpServer(this);
m_http = new HttpServer(m_httpListener);
m_server = new TcpServer(config.host(), config.port(), m_http);
const int rc = m_server->bind();

View file

@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,14 +26,15 @@
#define XMRIG_HTTPD_H
#include <cstdint>
#include "base/kernel/interfaces/IBaseListener.h"
#include "base/kernel/interfaces/IHttpListener.h"
#include "base/net/http/HttpListener.h"
#include "base/tools/Object.h"
#include <cstdint>
#include <memory>
namespace xmrig {
@ -62,6 +63,7 @@ private:
Base *m_base;
HttpServer *m_http;
std::shared_ptr<IHttpListener> m_httpListener;
TcpServer *m_server;
uint16_t m_port;
};