Commit a507fc80 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Isolate std::future when NOTHREADS is defined and build without SOCK_{NONBLOCK, CLOEXEC}

parent 69c3920a
...@@ -29,10 +29,21 @@ ...@@ -29,10 +29,21 @@
# include <config.h> # include <config.h>
#endif // HAVE_CONFIG_H #endif // HAVE_CONFIG_H
#include <sys/types.h>
#include <sys/socket.h>
#include <cassert> #include <cassert>
#include "shrpx_log.h" #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() \ #define DIE() \
assert(0); assert(0);
......
...@@ -75,6 +75,7 @@ void ListenHandler::worker_reopen_log_files() ...@@ -75,6 +75,7 @@ void ListenHandler::worker_reopen_log_files()
} }
} }
#ifndef NOTHREADS
namespace { namespace {
void worker_writecb(bufferevent *bev, void *ptr) void worker_writecb(bufferevent *bev, void *ptr)
{ {
...@@ -96,9 +97,11 @@ 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); bufferevent_disable(bev, EV_READ | EV_WRITE);
} }
} // namespace } // namespace
#endif // NOTHREADS
void ListenHandler::create_worker_thread(size_t num) void ListenHandler::create_worker_thread(size_t num)
{ {
#ifndef NOTHREADS
workers_.resize(0); workers_.resize(0);
for(size_t i = 0; i < num; ++i) { for(size_t i = 0; i < num; ++i) {
int rv; int rv;
...@@ -137,10 +140,12 @@ void ListenHandler::create_worker_thread(size_t num) ...@@ -137,10 +140,12 @@ void ListenHandler::create_worker_thread(size_t num)
LLOG(INFO, this) << "Created thread #" << workers_.size() - 1; LLOG(INFO, this) << "Created thread #" << workers_.size() - 1;
} }
} }
#endif // NOTHREADS
} }
void ListenHandler::join_worker() void ListenHandler::join_worker()
{ {
#ifndef NOTHREADS
int n = 0; int n = 0;
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
...@@ -155,6 +160,7 @@ void ListenHandler::join_worker() ...@@ -155,6 +160,7 @@ void ListenHandler::join_worker()
} }
++n; ++n;
} }
#endif // NOTHREADS
} }
void ListenHandler::graceful_shutdown_worker() void ListenHandler::graceful_shutdown_worker()
......
...@@ -32,7 +32,9 @@ ...@@ -32,7 +32,9 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#ifndef NOTHREADS
#include <future> #include <future>
#endif // NOTHREADS
#include <openssl/ssl.h> #include <openssl/ssl.h>
...@@ -43,7 +45,9 @@ ...@@ -43,7 +45,9 @@
namespace shrpx { namespace shrpx {
struct WorkerInfo { struct WorkerInfo {
#ifndef NOTHREADS
std::future<void> fut; std::future<void> fut;
#endif // NOTHREADS
SSL_CTX *sv_ssl_ctx; SSL_CTX *sv_ssl_ctx;
SSL_CTX *cl_ssl_ctx; SSL_CTX *cl_ssl_ctx;
bufferevent *bev; bufferevent *bev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment