Isolate std::future when NOTHREADS is defined and build without SOCK_{NONBLOCK, CLOEXEC}
This commit is contained in:
parent
69c3920a1a
commit
a507fc80b6
11
src/shrpx.h
11
src/shrpx.h
|
@ -29,10 +29,21 @@
|
|||
# include <config.h>
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "shrpx_log.h"
|
||||
|
||||
#ifndef SOCK_NONBLOCK
|
||||
#define SOCK_NONBLOCK 0
|
||||
#endif // !SOCK_NONBLOCK
|
||||
|
||||
#ifndef SOCK_CLOEXEC
|
||||
#define SOCK_CLOEXEC 0
|
||||
#endif // !SOCK_CLOEXEC
|
||||
|
||||
#define DIE() \
|
||||
assert(0);
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ void ListenHandler::worker_reopen_log_files()
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NOTHREADS
|
||||
namespace {
|
||||
void worker_writecb(bufferevent *bev, void *ptr)
|
||||
{
|
||||
|
@ -96,9 +97,11 @@ void worker_writecb(bufferevent *bev, void *ptr)
|
|||
bufferevent_disable(bev, EV_READ | EV_WRITE);
|
||||
}
|
||||
} // namespace
|
||||
#endif // NOTHREADS
|
||||
|
||||
void ListenHandler::create_worker_thread(size_t num)
|
||||
{
|
||||
#ifndef NOTHREADS
|
||||
workers_.resize(0);
|
||||
for(size_t i = 0; i < num; ++i) {
|
||||
int rv;
|
||||
|
@ -137,10 +140,12 @@ void ListenHandler::create_worker_thread(size_t num)
|
|||
LLOG(INFO, this) << "Created thread #" << workers_.size() - 1;
|
||||
}
|
||||
}
|
||||
#endif // NOTHREADS
|
||||
}
|
||||
|
||||
void ListenHandler::join_worker()
|
||||
{
|
||||
#ifndef NOTHREADS
|
||||
int n = 0;
|
||||
|
||||
if(LOG_ENABLED(INFO)) {
|
||||
|
@ -155,6 +160,7 @@ void ListenHandler::join_worker()
|
|||
}
|
||||
++n;
|
||||
}
|
||||
#endif // NOTHREADS
|
||||
}
|
||||
|
||||
void ListenHandler::graceful_shutdown_worker()
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#ifndef NOTHREADS
|
||||
#include <future>
|
||||
#endif // NOTHREADS
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
|
@ -43,7 +45,9 @@
|
|||
namespace shrpx {
|
||||
|
||||
struct WorkerInfo {
|
||||
#ifndef NOTHREADS
|
||||
std::future<void> fut;
|
||||
#endif // NOTHREADS
|
||||
SSL_CTX *sv_ssl_ctx;
|
||||
SSL_CTX *cl_ssl_ctx;
|
||||
bufferevent *bev;
|
||||
|
|
Loading…
Reference in New Issue