mirror of
https://github.com/kakwa/uts-server
synced 2024-11-04 17:08:49 +01:00
14852855b9
as TS_RESP_CTX is not thread safe, this commit implement a pool of TS_RESP_CTX in which a thread can pick one in a thread safe maner. * implement a ts_resp_ctx_wrapper containing a TS_RESP_CTX and a lock and bool to mark the availability of the TS_RESP_CTX * implement the get_ctxw to recover a given TS_RESP_CTX in a thread safe maner * adapt the rest of the code to accomodate the new way of doing things * set the default number of threads to 10 as it's now safe to do so
60 lines
1.7 KiB
C
60 lines
1.7 KiB
C
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stddef.h> /* for offsetof() macro */
|
|
#include <string.h>
|
|
#include <pthread.h>
|
|
#include <civetweb.h>
|
|
#include <openssl/ts.h>
|
|
|
|
#define HTTP_OPTIONS 1
|
|
#define LOGLEVEL_OPTIONS 2
|
|
#define TSA_OPTIONS 3
|
|
#define MAIN_CONF_SECTION "main"
|
|
|
|
#define RFC3161_OPTIONS_LEN \
|
|
sizeof(rfc3161_options) / sizeof(struct rfc3161_option)
|
|
|
|
typedef struct {
|
|
TS_RESP_CTX *ts_ctx;
|
|
bool available;
|
|
pthread_mutex_t lock;
|
|
} ts_resp_ctx_wrapper;
|
|
|
|
typedef struct {
|
|
uint64_t query_counter;
|
|
bool stdout_dbg;
|
|
int loglevel;
|
|
int numthreads;
|
|
const char *http_options[40];
|
|
ts_resp_ctx_wrapper *ts_ctx_pool;
|
|
CONF *conf;
|
|
} rfc3161_context;
|
|
|
|
struct rfc3161_option {
|
|
const char *name;
|
|
int type;
|
|
const char *default_value;
|
|
};
|
|
|
|
static struct rfc3161_option rfc3161_options[] = {
|
|
{"num_threads", HTTP_OPTIONS, "10"},
|
|
{"run_as_user", HTTP_OPTIONS, NULL},
|
|
{"throttle", HTTP_OPTIONS, NULL},
|
|
{"enable_keep_alive", HTTP_OPTIONS, "no"},
|
|
{"listening_ports", HTTP_OPTIONS, "8080"},
|
|
{"request_timeout_ms", HTTP_OPTIONS, "30000"},
|
|
{"ssl_certificate", HTTP_OPTIONS, NULL},
|
|
{"ssl_verify_peer", HTTP_OPTIONS, "yes"},
|
|
{"ssl_ca_path", HTTP_OPTIONS, NULL},
|
|
{"ssl_ca_file", HTTP_OPTIONS, NULL},
|
|
{"ssl_verify_depth", HTTP_OPTIONS, "9"},
|
|
{"ssl_default_verify_paths", HTTP_OPTIONS, "yes"},
|
|
{"ssl_cipher_list", HTTP_OPTIONS, NULL},
|
|
{"ssl_protocol_version", HTTP_OPTIONS, "0"},
|
|
{"ssl_short_trust", HTTP_OPTIONS, "no"},
|
|
{"access_control_allow_origin", HTTP_OPTIONS, "*"},
|
|
{"tcp_nodelay", HTTP_OPTIONS, "0"},
|
|
{"log_level", LOGLEVEL_OPTIONS, "info"},
|
|
};
|