Skip to content

Commit 1359c20

Browse files
committed
UPD | stupid update
1 parent e7cd4dc commit 1359c20

40 files changed

Lines changed: 547 additions & 546 deletions

include/ManapiHttp.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ namespace manapi::net::http {
111111
* stop working the server
112112
* @return the future
113113
*/
114-
manapi::future<manapi::status> stop ();
114+
manapi::future<manapi::status> stop () override;
115115
private:
116-
static manapi::future<manapi::status> stop_ (std::shared_ptr<data2_t> data2, bool evloop);
116+
std::shared_ptr<site> copy() override;
117117

118118
manapi::future<> init_pool_ ();
119119

120120
manapi::status pool_ (std::move_only_function<void()> cb) MANAPIHTTP_NOEXCEPT;
121121

122-
static void clean_up (const std::shared_ptr<data2_t>& data2);
122+
void clean_up () override;
123123

124124
static manapi::future<void> stop_pool (std::shared_ptr<data2_t> data2);
125125
};

include/http/ManapiBaseHttp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ namespace manapi::net::http::internal {
5858
* - filesystem - fs failed
5959
*/
6060

61-
future<manapi::status_or<std::string>> compress_file(net::http::site site, std::string file, std::string folder, std::string compress, response_features_t::compress_file_cb *compressor, bool force_compress = false);
61+
future<manapi::status_or<std::string>> compress_file(std::shared_ptr<net::http::site> site, std::string file, std::string folder, std::string compress, response_features_t::compress_file_cb *compressor, bool force_compress = false);
6262
}

include/http/ManapiFormData.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "./ManapiHttpConfig.hpp"
44
#include "../ManapiUtils.hpp"
55
#include "../ManapiAsync.hpp"
6+
#include "../http/ManapiHttpUtils.hpp"
67
#include "../std/ManapiAsyncContext.hpp"
78
#include "../worker/ManapiBaseWorker.hpp"
89

include/http/ManapiHttpPool.hpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <future>
55
#include <functional>
66

7-
#include "./ManapiSite.hpp"
87
#include "./ManapiSiteCtx.hpp"
98
#include "./ManapiBaseHttp.hpp"
109
#include "./ManapiHttpConfig.hpp"
@@ -14,6 +13,10 @@
1413
#include "../worker/ManapiBaseWorker.hpp"
1514

1615
namespace manapi::net {
16+
namespace http {
17+
class site;
18+
}
19+
1720
class http_pool {
1821
public:
1922
/**
@@ -24,7 +27,7 @@ namespace manapi::net {
2427
* @param id ID
2528
* @param events event loop
2629
*/
27-
explicit http_pool(const json &config, std::shared_ptr<multithread_storage::worker_t> worker_config, class http::site site, size_t id, std::shared_ptr<event_loop> events);
30+
explicit http_pool(const json &config, std::shared_ptr<multithread_storage::worker_t> worker_config, std::shared_ptr<http::site> site, size_t id);
2831

2932
/* deconstructor */
3033
~http_pool();
@@ -45,30 +48,28 @@ namespace manapi::net {
4548
* get the site instance
4649
* @return the site instance
4750
*/
48-
MANAPIHTTP_NODISCARD http::site site () const;
51+
MANAPIHTTP_NODISCARD const std::shared_ptr<http::site> &site () const;
4952

5053
MANAPIHTTP_NODISCARD std::shared_ptr <http::config> config () const;
5154
private:
5255
manapi::future<manapi::status> pool_ ();
5356

54-
std::size_t id;
57+
std::size_t m_id;
5558

56-
std::shared_ptr<multithread_storage::worker_t> worker_config;
59+
std::shared_ptr<multithread_storage::worker_t> m_worker_config;
5760

58-
std::shared_ptr <http::config> config_;
61+
std::shared_ptr <http::config> m_config;
5962

60-
std::shared_ptr <worker::base> worker;
63+
std::shared_ptr <worker::base> m_worker;
6164

6265
// pool
6366

64-
std::shared_ptr<manapi::async::mutex> mx;
65-
66-
std::shared_ptr<event_loop> events;
67+
std::shared_ptr<manapi::async::mutex> m_mx;
6768

68-
std::unique_ptr<std::promise <int> > pool_promise;
69+
std::unique_ptr<std::promise <int> > m_pool_promise;
6970

70-
http::site site_;
71+
std::shared_ptr<http::site> m_site;
7172
// watchers
72-
std::shared_ptr <ev::io> watcher;
73+
std::shared_ptr <ev::io> m_watcher;
7374
};
7475
}

include/http/ManapiSite.hpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@
1818
#include "../json/ManapiJson.hpp"
1919
#include "../json/ManapiJsonMask.hpp"
2020

21-
namespace manapi::net::worker {
22-
class base;
23-
class interface_worker;
24-
struct wrk_interface_global_t;
25-
}
26-
27-
namespace manapi::net::http {
28-
class request;
29-
class response;
30-
class uresponse;
31-
}
32-
3321
namespace manapi::net::http {
3422
typedef std::move_only_function <future<>(manapi::net::http::request &req, manapi::net::http::response &res)> async_handler_t;
3523

@@ -97,6 +85,7 @@ namespace manapi::net::http {
9785

9886
class site {
9987
public:
88+
struct data_t;
10089
/**
10190
* Compress file callback
10291
*/
@@ -107,11 +96,10 @@ namespace manapi::net::http {
10796
*/
10897
typedef std::move_only_function<manapi::status_or<std::string>(std::string_view data)> compress_str_cb_t;
10998

110-
typedef std::function<std::shared_ptr<worker::base>(site site, std::shared_ptr<multithread_storage::worker_t> wdata, http::config* config)> implement_create_cb;
99+
typedef std::function<std::shared_ptr<worker::base>(std::shared_ptr<net::http::site> site, std::shared_ptr<multithread_storage::worker_t> wdata, http::config* config)> implement_create_cb;
111100

112101
typedef std::function<manapi::status_or<std::unique_ptr<worker::wrk_interface_global_t>> (worker::interface_worker *w)> implemenet_http_cb;
113102

114-
struct data_t;
115103

116104
site ();
117105
/**
@@ -265,20 +253,27 @@ namespace manapi::net::http {
265253

266254
MANAPIHTTP_NODISCARD const std::string &config_cache_dir();
267255

256+
257+
virtual manapi::future<manapi::status> stop () = 0;
268258
protected:
269-
void init_data_ (server_ctx sctx);
259+
static std::string_view default_config_name;
260+
261+
static manapi::future<> save_config (std::shared_ptr<data_t> data);
270262

271263
static void on_config_update (std::shared_ptr<data_t> data, const manapi::json &n) MANAPIHTTP_NOEXCEPT;
272264

265+
virtual std::shared_ptr<site> copy () = 0;
266+
267+
void init_data_ (server_ctx sctx);
268+
273269
void setup ();
274270

275-
manapi::future<> setup_config (manapi::json &n);
271+
virtual void clean_up () = 0;
276272

277-
static manapi::future<> save_config (std::shared_ptr<data_t> data);
273+
manapi::future<> setup_config (manapi::json &n);
278274

279275
std::shared_ptr<data_t> data;
280276

281-
static std::string_view default_config_name;
282277
private:
283278
static std::shared_ptr<http_handler_function> default_error_handler;
284279

include/http/ManapiSiteCtx.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
#include "../std/ManapiAsyncThreadsMutex.hpp"
77
#include "../utils/ManapiMultithreadStorage.hpp"
88

9+
namespace manapi::net::worker {
10+
class base;
11+
class interface_worker;
12+
struct wrk_interface_global_t;
13+
}
14+
15+
namespace manapi::net::http {
16+
class request;
17+
class response;
18+
class uresponse;
19+
}
20+
921
namespace manapi::net::http {
1022
class server_ctx {
1123
struct data_t;

include/worker/ManapiBaseWorker.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
#include <functional>
55

66
#include "../http/ManapiHttpConfig.hpp"
7-
#include "../http/ManapiSite.hpp"
7+
#include "../http/ManapiSiteCtx.hpp"
8+
#include "../std/ManapiCancellation.hpp"
89
#include "../ManapiUtils.hpp"
910

11+
namespace manapi::net::http {
12+
class site;
13+
}
14+
1015
namespace manapi::net::worker {
1116
struct sockaddr_st {
1217
char data[std::max(sizeof (struct sockaddr_in), sizeof (struct sockaddr_in6))];
@@ -228,7 +233,7 @@ namespace manapi::net::worker {
228233

229234
virtual wrk_interface_global_t *wrk_global () = 0;
230235

231-
virtual http::site &site() = 0;
236+
virtual const std::shared_ptr<http::site> &site() = 0;
232237

233238
virtual http::config *config() = 0;
234239

include/worker/ManapiHttp2Worker.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace manapi::net::worker {
5151

5252
http::config *config() MANAPIHTTP_NOEXCEPT override;
5353

54-
http::site &site() MANAPIHTTP_NOEXCEPT override;
54+
const std::shared_ptr<http::site> &site() MANAPIHTTP_NOEXCEPT override;
5555

5656
void waiting(const shared_conn &conn, bool state) MANAPIHTTP_NOEXCEPT override;
5757

include/worker/ManapiHttp3Cloudflare.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ namespace manapi::net::worker {
2525

2626
struct connection_stream_t;
2727

28-
explicit http_v3_cloudflare_quiche(net::http::site site, std::shared_ptr<multithread_storage::worker_t> wdata,manapi::net::http::config * config);
28+
explicit http_v3_cloudflare_quiche(std::shared_ptr<net::http::site> site, std::shared_ptr<multithread_storage::worker_t> wdata,manapi::net::http::config * config);
2929

3030
~http_v3_cloudflare_quiche() override;
3131

32-
static std::shared_ptr<worker::http_v3_cloudflare_quiche> create (net::http::site site, std::shared_ptr<multithread_storage::worker_t> wdata, manapi::net::http::config* config);
32+
static std::shared_ptr<worker::http_v3_cloudflare_quiche> create (std::shared_ptr<net::http::site> site, std::shared_ptr<multithread_storage::worker_t> wdata, manapi::net::http::config* config);
3333

3434
manapi::future<manapi::status> init(std::size_t deep) override;
3535

include/worker/ManapiHttp3Worker.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace manapi::net::worker {
6666

6767
http::config *config() MANAPIHTTP_NOEXCEPT override;
6868

69-
http::site &site() MANAPIHTTP_NOEXCEPT override;
69+
const std::shared_ptr<http::site> &site() MANAPIHTTP_NOEXCEPT override;
7070

7171
void waiting(const shared_conn &conn, bool state) MANAPIHTTP_NOEXCEPT override;
7272

0 commit comments

Comments
 (0)