nghttpx: Adjust backend buffers
This commit is contained in:
parent
5a6d6ccbd4
commit
8997e4369d
|
@ -229,9 +229,9 @@ template <typename Memchunk> struct Memchunks {
|
|||
size_t len;
|
||||
};
|
||||
|
||||
using Memchunk4K = Memchunk<4096>;
|
||||
using MemchunkPool4K = Pool<Memchunk4K>;
|
||||
using Memchunks4K = Memchunks<Memchunk4K>;
|
||||
using Memchunk16K = Memchunk<16384>;
|
||||
using MemchunkPool = Pool<Memchunk16K>;
|
||||
using DefaultMemchunks = Memchunks<Memchunk16K>;
|
||||
|
||||
} // namespace nghttp2
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
namespace nghttp2 {
|
||||
|
||||
void test_pool_recycle(void) {
|
||||
MemchunkPool4K pool;
|
||||
MemchunkPool pool;
|
||||
|
||||
CU_ASSERT(!pool.pool);
|
||||
CU_ASSERT(0 == pool.poolsize);
|
||||
|
@ -42,13 +42,13 @@ void test_pool_recycle(void) {
|
|||
auto m1 = pool.get();
|
||||
|
||||
CU_ASSERT(m1 == pool.pool.get());
|
||||
CU_ASSERT(MemchunkPool4K::value_type::size == pool.poolsize);
|
||||
CU_ASSERT(MemchunkPool::value_type::size == pool.poolsize);
|
||||
CU_ASSERT(nullptr == pool.freelist);
|
||||
|
||||
auto m2 = pool.get();
|
||||
|
||||
CU_ASSERT(m2 == pool.pool.get());
|
||||
CU_ASSERT(2 * MemchunkPool4K::value_type::size == pool.poolsize);
|
||||
CU_ASSERT(2 * MemchunkPool::value_type::size == pool.poolsize);
|
||||
CU_ASSERT(nullptr == pool.freelist);
|
||||
CU_ASSERT(m1 == m2->knext.get());
|
||||
CU_ASSERT(nullptr == m1->knext.get());
|
||||
|
@ -56,20 +56,20 @@ void test_pool_recycle(void) {
|
|||
auto m3 = pool.get();
|
||||
|
||||
CU_ASSERT(m3 == pool.pool.get());
|
||||
CU_ASSERT(3 * MemchunkPool4K::value_type::size == pool.poolsize);
|
||||
CU_ASSERT(3 * MemchunkPool::value_type::size == pool.poolsize);
|
||||
CU_ASSERT(nullptr == pool.freelist);
|
||||
|
||||
pool.recycle(m3);
|
||||
|
||||
CU_ASSERT(m3 == pool.pool.get());
|
||||
CU_ASSERT(3 * MemchunkPool4K::value_type::size == pool.poolsize);
|
||||
CU_ASSERT(3 * MemchunkPool::value_type::size == pool.poolsize);
|
||||
CU_ASSERT(m3 == pool.freelist);
|
||||
|
||||
auto m4 = pool.get();
|
||||
|
||||
CU_ASSERT(m3 == m4);
|
||||
CU_ASSERT(m4 == pool.pool.get());
|
||||
CU_ASSERT(3 * MemchunkPool4K::value_type::size == pool.poolsize);
|
||||
CU_ASSERT(3 * MemchunkPool::value_type::size == pool.poolsize);
|
||||
CU_ASSERT(nullptr == pool.freelist);
|
||||
|
||||
pool.recycle(m2);
|
||||
|
|
|
@ -748,7 +748,7 @@ void fill_default_config() {
|
|||
mod_config()->auto_tls_ticket_key = true;
|
||||
mod_config()->tls_ctx_per_worker = false;
|
||||
mod_config()->downstream_request_buffer_size = 16 * 1024;
|
||||
mod_config()->downstream_response_buffer_size = 64 * 1024;
|
||||
mod_config()->downstream_response_buffer_size = 16 * 1024;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -477,7 +477,7 @@ bool Downstream::request_buf_full() {
|
|||
}
|
||||
}
|
||||
|
||||
Memchunks4K *Downstream::get_request_buf() { return &request_buf_; }
|
||||
DefaultMemchunks *Downstream::get_request_buf() { return &request_buf_; }
|
||||
|
||||
// Call this function after this object is attached to
|
||||
// Downstream. Otherwise, the program will crash.
|
||||
|
@ -664,7 +664,7 @@ void Downstream::set_response_state(int state) { response_state_ = state; }
|
|||
|
||||
int Downstream::get_response_state() const { return response_state_; }
|
||||
|
||||
Memchunks4K *Downstream::get_response_buf() { return &response_buf_; }
|
||||
DefaultMemchunks *Downstream::get_response_buf() { return &response_buf_; }
|
||||
|
||||
bool Downstream::response_buf_full() {
|
||||
if (dconn_) {
|
||||
|
|
|
@ -181,7 +181,7 @@ public:
|
|||
};
|
||||
void set_request_state(int state);
|
||||
int get_request_state() const;
|
||||
Memchunks4K *get_request_buf();
|
||||
DefaultMemchunks *get_request_buf();
|
||||
// downstream response API
|
||||
const Headers &get_response_headers() const;
|
||||
// Lower the response header field names and indexes response
|
||||
|
@ -224,7 +224,7 @@ public:
|
|||
void set_response_connection_close(bool f);
|
||||
void set_response_state(int state);
|
||||
int get_response_state() const;
|
||||
Memchunks4K *get_response_buf();
|
||||
DefaultMemchunks *get_response_buf();
|
||||
bool response_buf_full();
|
||||
void add_response_bodylen(size_t amount);
|
||||
int64_t get_response_bodylen() const;
|
||||
|
@ -305,8 +305,8 @@ private:
|
|||
std::chrono::high_resolution_clock::time_point request_start_time_;
|
||||
std::string assembled_request_cookie_;
|
||||
|
||||
Memchunks4K request_buf_;
|
||||
Memchunks4K response_buf_;
|
||||
DefaultMemchunks request_buf_;
|
||||
DefaultMemchunks response_buf_;
|
||||
|
||||
ev_timer upstream_rtimer_;
|
||||
ev_timer upstream_wtimer_;
|
||||
|
|
|
@ -1375,6 +1375,6 @@ int Http2Upstream::on_downstream_reset() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
MemchunkPool4K *Http2Upstream::get_mcpool() { return &mcpool_; }
|
||||
MemchunkPool *Http2Upstream::get_mcpool() { return &mcpool_; }
|
||||
|
||||
} // namespace shrpx
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
virtual void on_handler_delete();
|
||||
virtual int on_downstream_reset();
|
||||
|
||||
virtual MemchunkPool4K *get_mcpool();
|
||||
virtual MemchunkPool *get_mcpool();
|
||||
|
||||
bool get_flow_control() const;
|
||||
// Perform HTTP/2 upgrade from |upstream|. On success, this object
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
private:
|
||||
// must be put before downstream_queue_
|
||||
std::unique_ptr<HttpsUpstream> pre_upstream_;
|
||||
MemchunkPool4K mcpool_;
|
||||
MemchunkPool mcpool_;
|
||||
DownstreamQueue downstream_queue_;
|
||||
ev_timer settings_timer_;
|
||||
ClientHandler *handler_;
|
||||
|
|
|
@ -852,6 +852,6 @@ int HttpsUpstream::on_downstream_reset() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
MemchunkPool4K *HttpsUpstream::get_mcpool() { return &mcpool_; }
|
||||
MemchunkPool *HttpsUpstream::get_mcpool() { return &mcpool_; }
|
||||
|
||||
} // namespace shrpx
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
virtual void on_handler_delete();
|
||||
virtual int on_downstream_reset();
|
||||
|
||||
virtual MemchunkPool4K *get_mcpool();
|
||||
virtual MemchunkPool *get_mcpool();
|
||||
|
||||
void reset_current_header_length();
|
||||
void log_response_headers(const std::string &hdrs) const;
|
||||
|
@ -86,7 +86,7 @@ private:
|
|||
http_parser htp_;
|
||||
size_t current_header_length_;
|
||||
// must be put before downstream_
|
||||
MemchunkPool4K mcpool_;
|
||||
MemchunkPool mcpool_;
|
||||
std::unique_ptr<Downstream> downstream_;
|
||||
IOControl ioctrl_;
|
||||
};
|
||||
|
|
|
@ -1060,6 +1060,6 @@ int SpdyUpstream::on_downstream_reset() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
MemchunkPool4K *SpdyUpstream::get_mcpool() { return &mcpool_; }
|
||||
MemchunkPool *SpdyUpstream::get_mcpool() { return &mcpool_; }
|
||||
|
||||
} // namespace shrpx
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
virtual void on_handler_delete();
|
||||
virtual int on_downstream_reset();
|
||||
|
||||
virtual MemchunkPool4K *get_mcpool();
|
||||
virtual MemchunkPool *get_mcpool();
|
||||
|
||||
bool get_flow_control() const;
|
||||
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
|
||||
private:
|
||||
// must be put before downstream_queue_
|
||||
MemchunkPool4K mcpool_;
|
||||
MemchunkPool mcpool_;
|
||||
DownstreamQueue downstream_queue_;
|
||||
ClientHandler *handler_;
|
||||
spdylay_session *session_;
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
virtual int resume_read(IOCtrlReason reason, Downstream *downstream,
|
||||
size_t consumed) = 0;
|
||||
|
||||
virtual MemchunkPool4K *get_mcpool() = 0;
|
||||
virtual MemchunkPool *get_mcpool() = 0;
|
||||
};
|
||||
|
||||
} // namespace shrpx
|
||||
|
|
Loading…
Reference in New Issue