mirror of
https://github.com/kakwa/uts-server
synced 2025-07-04 04:27:05 +02:00
enabling multi-threads support
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
This commit is contained in:
parent
de4f796b33
commit
14852855b9
6 changed files with 56 additions and 12 deletions
|
@ -3,6 +3,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h> /* for offsetof() macro */
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <civetweb.h>
|
||||
#include <openssl/ts.h>
|
||||
|
||||
|
@ -14,12 +15,19 @@
|
|||
#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 *ts_ctx;
|
||||
ts_resp_ctx_wrapper *ts_ctx_pool;
|
||||
CONF *conf;
|
||||
} rfc3161_context;
|
||||
|
||||
|
@ -30,7 +38,7 @@ struct rfc3161_option {
|
|||
};
|
||||
|
||||
static struct rfc3161_option rfc3161_options[] = {
|
||||
{"num_threads", HTTP_OPTIONS, "1"},
|
||||
{"num_threads", HTTP_OPTIONS, "10"},
|
||||
{"run_as_user", HTTP_OPTIONS, NULL},
|
||||
{"throttle", HTTP_OPTIONS, NULL},
|
||||
{"enable_keep_alive", HTTP_OPTIONS, "no"},
|
||||
|
|
|
@ -38,5 +38,6 @@ static int save_ts_serial(const char *serialfile, ASN1_INTEGER *serial);
|
|||
TS_RESP_CTX *create_tsctx(rfc3161_context *ct, CONF *conf, const char *section,
|
||||
const char *policy);
|
||||
int add_oid_section(rfc3161_context *ct, CONF *conf);
|
||||
ts_resp_ctx_wrapper *get_ctxw(rfc3161_context *ct);
|
||||
void init_ssl();
|
||||
void free_ssl();
|
||||
|
|
|
@ -8,6 +8,6 @@ void log_hex(rfc3161_context *ct, int priority, char *id,
|
|||
unsigned char *content, int content_length);
|
||||
int set_params(rfc3161_context *ct, char *conf_file, char *conf_wd);
|
||||
static char *rand_string(char *str, size_t size);
|
||||
void free_uts_context(rfc3161_context *context);
|
||||
void free_uts_context(rfc3161_context *ct);
|
||||
int g_uts_sig_up;
|
||||
int g_uts_sig;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue