clang-format
This commit is contained in:
parent
6b0b8ea7d5
commit
eb05777d88
|
@ -258,8 +258,7 @@ static int on_data_chunk_recv_callback(nghttp2_session *session _U_,
|
||||||
stream), if it is closed, we send GOAWAY and tear down the
|
stream), if it is closed, we send GOAWAY and tear down the
|
||||||
session */
|
session */
|
||||||
static int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
|
static int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
|
||||||
uint32_t error_code,
|
uint32_t error_code, void *user_data) {
|
||||||
void *user_data) {
|
|
||||||
http2_session_data *session_data = (http2_session_data *)user_data;
|
http2_session_data *session_data = (http2_session_data *)user_data;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,9 @@ void io_service_pool::run(bool asynchronous) {
|
||||||
// Create a pool of threads to run all of the io_services.
|
// Create a pool of threads to run all of the io_services.
|
||||||
for (std::size_t i = 0; i < io_services_.size(); ++i) {
|
for (std::size_t i = 0; i < io_services_.size(); ++i) {
|
||||||
futures_.push_back(std::async(std::launch::async,
|
futures_.push_back(std::async(std::launch::async,
|
||||||
(size_t (boost::asio::io_service::*)(void)) &
|
(size_t (boost::asio::io_service::*)(void)) &
|
||||||
boost::asio::io_service::run,
|
boost::asio::io_service::run,
|
||||||
io_services_[i]));
|
io_services_[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!asynchronous) {
|
if (!asynchronous) {
|
||||||
|
|
|
@ -156,15 +156,9 @@ void server::start_accept(tcp::acceptor &acceptor, serve_mux &mux) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void server::stop()
|
void server::stop() { io_service_pool_.stop(); }
|
||||||
{
|
|
||||||
io_service_pool_.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void server::join()
|
void server::join() { io_service_pool_.join(); }
|
||||||
{
|
|
||||||
io_service_pool_.join();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace server
|
} // namespace server
|
||||||
} // namespace asio_http2
|
} // namespace asio_http2
|
||||||
|
|
|
@ -59,11 +59,9 @@ boost::system::error_code http2::listen_and_serve(boost::system::error_code &ec,
|
||||||
return impl_->listen_and_serve(ec, nullptr, address, port, asynchronous);
|
return impl_->listen_and_serve(ec, nullptr, address, port, asynchronous);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::system::error_code
|
boost::system::error_code http2::listen_and_serve(
|
||||||
http2::listen_and_serve(boost::system::error_code &ec,
|
boost::system::error_code &ec, boost::asio::ssl::context &tls_context,
|
||||||
boost::asio::ssl::context &tls_context,
|
const std::string &address, const std::string &port, bool asynchronous) {
|
||||||
const std::string &address, const std::string &port,
|
|
||||||
bool asynchronous) {
|
|
||||||
return impl_->listen_and_serve(ec, &tls_context, address, port, asynchronous);
|
return impl_->listen_and_serve(ec, &tls_context, address, port, asynchronous);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,15 +73,9 @@ bool http2::handle(std::string pattern, request_cb cb) {
|
||||||
return impl_->handle(std::move(pattern), std::move(cb));
|
return impl_->handle(std::move(pattern), std::move(cb));
|
||||||
}
|
}
|
||||||
|
|
||||||
void http2::stop()
|
void http2::stop() { impl_->stop(); }
|
||||||
{
|
|
||||||
impl_->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void http2::join()
|
void http2::join() { return impl_->join(); }
|
||||||
{
|
|
||||||
return impl_->join();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace server
|
} // namespace server
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,8 @@ boost::system::error_code http2_impl::listen_and_serve(
|
||||||
boost::system::error_code &ec, boost::asio::ssl::context *tls_context,
|
boost::system::error_code &ec, boost::asio::ssl::context *tls_context,
|
||||||
const std::string &address, const std::string &port, bool asynchronous) {
|
const std::string &address, const std::string &port, bool asynchronous) {
|
||||||
server_.reset(new server(num_threads_));
|
server_.reset(new server(num_threads_));
|
||||||
return server_->listen_and_serve(ec, tls_context, address, port, backlog_, mux_, asynchronous);
|
return server_->listen_and_serve(ec, tls_context, address, port, backlog_,
|
||||||
|
mux_, asynchronous);
|
||||||
}
|
}
|
||||||
|
|
||||||
void http2_impl::num_threads(size_t num_threads) { num_threads_ = num_threads; }
|
void http2_impl::num_threads(size_t num_threads) { num_threads_ = num_threads; }
|
||||||
|
@ -54,14 +55,9 @@ bool http2_impl::handle(std::string pattern, request_cb cb) {
|
||||||
return mux_.handle(std::move(pattern), std::move(cb));
|
return mux_.handle(std::move(pattern), std::move(cb));
|
||||||
}
|
}
|
||||||
|
|
||||||
void http2_impl::stop() {
|
void http2_impl::stop() { return server_->stop(); }
|
||||||
return server_->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void http2_impl::join()
|
void http2_impl::join() { return server_->join(); }
|
||||||
{
|
|
||||||
return server_->join();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace server
|
} // namespace server
|
||||||
|
|
||||||
|
|
|
@ -42,11 +42,9 @@ class server;
|
||||||
class http2_impl {
|
class http2_impl {
|
||||||
public:
|
public:
|
||||||
http2_impl();
|
http2_impl();
|
||||||
boost::system::error_code
|
boost::system::error_code listen_and_serve(
|
||||||
listen_and_serve(boost::system::error_code &ec,
|
boost::system::error_code &ec, boost::asio::ssl::context *tls_context,
|
||||||
boost::asio::ssl::context *tls_context,
|
const std::string &address, const std::string &port, bool asynchronous);
|
||||||
const std::string &address, const std::string &port,
|
|
||||||
bool asynchronous);
|
|
||||||
void num_threads(size_t num_threads);
|
void num_threads(size_t num_threads);
|
||||||
void backlog(int backlog);
|
void backlog(int backlog);
|
||||||
bool handle(std::string pattern, request_cb cb);
|
bool handle(std::string pattern, request_cb cb);
|
||||||
|
|
|
@ -58,7 +58,7 @@ json_t *dump_header(const uint8_t *name, size_t namelen, const uint8_t *value,
|
||||||
json_t *nv_pair = json_object();
|
json_t *nv_pair = json_object();
|
||||||
char *cname = malloc(namelen + 1);
|
char *cname = malloc(namelen + 1);
|
||||||
if (cname == NULL) {
|
if (cname == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memcpy(cname, name, namelen);
|
memcpy(cname, name, namelen);
|
||||||
cname[namelen] = '\0';
|
cname[namelen] = '\0';
|
||||||
|
|
|
@ -738,14 +738,14 @@ char *get_exec_path(int argc, char **const argv, const char *cwd) {
|
||||||
if (argv0[0] == '/') {
|
if (argv0[0] == '/') {
|
||||||
path = static_cast<char *>(malloc(len + 1));
|
path = static_cast<char *>(malloc(len + 1));
|
||||||
if (path == nullptr) {
|
if (path == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
memcpy(path, argv0, len + 1);
|
memcpy(path, argv0, len + 1);
|
||||||
} else {
|
} else {
|
||||||
auto cwdlen = strlen(cwd);
|
auto cwdlen = strlen(cwd);
|
||||||
path = static_cast<char *>(malloc(len + 1 + cwdlen + 1));
|
path = static_cast<char *>(malloc(len + 1 + cwdlen + 1));
|
||||||
if (path == nullptr) {
|
if (path == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
memcpy(path, cwd, cwdlen);
|
memcpy(path, cwd, cwdlen);
|
||||||
path[cwdlen] = '/';
|
path[cwdlen] = '/';
|
||||||
|
|
Loading…
Reference in New Issue