Fix compile error with libstdc++ and/or --disable-threads
This commit is contained in:
parent
b313068cab
commit
5dce9501a6
11
src/shrpx.cc
11
src/shrpx.cc
|
@ -438,7 +438,11 @@ void refresh_cb(struct ev_loop *loop, ev_timer *w, int revents) {
|
|||
|
||||
namespace {
|
||||
void renew_ticket_key_cb(struct ev_loop *loop, ev_timer *w, int revents) {
|
||||
auto old_ticket_keys = std::atomic_load(&get_config()->ticket_keys);
|
||||
#ifndef NOTHREADS
|
||||
std::lock_guard<std::mutex> g(mod_config()->ticket_keys_lock);
|
||||
#endif // !NOTHREADS
|
||||
auto old_ticket_keys = get_config()->ticket_keys;
|
||||
|
||||
auto ticket_keys = std::make_shared<TicketKeys>();
|
||||
if (LOG_ENABLED(INFO)) {
|
||||
LOG(INFO) << "renew ticket key";
|
||||
|
@ -461,8 +465,7 @@ void renew_ticket_key_cb(struct ev_loop *loop, ev_timer *w, int revents) {
|
|||
if (LOG_ENABLED(INFO)) {
|
||||
LOG(INFO) << "failed to renew ticket key";
|
||||
}
|
||||
std::atomic_store(&mod_config()->ticket_keys,
|
||||
std::shared_ptr<TicketKeys>());
|
||||
mod_config()->ticket_keys.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -473,7 +476,7 @@ void renew_ticket_key_cb(struct ev_loop *loop, ev_timer *w, int revents) {
|
|||
}
|
||||
}
|
||||
|
||||
std::atomic_store(&mod_config()->ticket_keys, ticket_keys);
|
||||
mod_config()->ticket_keys = ticket_keys;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <vector>
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
|
@ -183,6 +184,7 @@ struct Config {
|
|||
std::vector<LogFragment> accesslog_format;
|
||||
std::vector<DownstreamAddr> downstream_addrs;
|
||||
std::vector<std::string> tls_ticket_key_files;
|
||||
std::mutex ticket_keys_lock;
|
||||
std::shared_ptr<TicketKeys> ticket_keys;
|
||||
// binary form of http proxy host and port
|
||||
sockaddr_union downstream_http_proxy_addr;
|
||||
|
|
|
@ -147,9 +147,18 @@ namespace {
|
|||
int ticket_key_cb(SSL *ssl, unsigned char *key_name, unsigned char *iv,
|
||||
EVP_CIPHER_CTX *ctx, HMAC_CTX *hctx, int enc) {
|
||||
auto handler = static_cast<ClientHandler *>(SSL_get_app_data(ssl));
|
||||
auto ticket_keys = get_config()->auto_tls_ticket_key
|
||||
? std::atomic_load(&get_config()->ticket_keys)
|
||||
: get_config()->ticket_keys;
|
||||
#ifndef NOTHREADS
|
||||
std::shared_ptr<TicketKeys> ticket_keys;
|
||||
if (get_config()->auto_tls_ticket_key) {
|
||||
std::lock_guard<std::mutex> g(mod_config()->ticket_keys_lock);
|
||||
ticket_keys = get_config()->ticket_keys;
|
||||
} else {
|
||||
ticket_keys = get_config()->ticket_keys;
|
||||
}
|
||||
#else // NOTHREADS
|
||||
auto ticket_keys = get_config()->ticket_keys;
|
||||
#endif // NOTHREADS
|
||||
|
||||
if (!ticket_keys) {
|
||||
/* No ticket keys available. Perform full handshake */
|
||||
return 0;
|
||||
|
|
|
@ -66,7 +66,9 @@ Worker::~Worker() {
|
|||
}
|
||||
|
||||
void Worker::run() {
|
||||
#ifndef NOTHREADS
|
||||
fut_ = std::async(std::launch::async, [this] { this->run_loop(); });
|
||||
#endif // !NOTHREADS
|
||||
}
|
||||
|
||||
void Worker::run_loop() {
|
||||
|
@ -74,7 +76,11 @@ void Worker::run_loop() {
|
|||
ev_run(loop_);
|
||||
}
|
||||
|
||||
void Worker::wait() { fut_.get(); }
|
||||
void Worker::wait() {
|
||||
#ifndef NOTHREADS
|
||||
fut_.get();
|
||||
#endif // !NOTHREADS
|
||||
}
|
||||
|
||||
void Worker::send(const WorkerEvent &event) {
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue