1
0
Fork 0
mirror of https://github.com/kakwa/uts-server synced 2025-07-04 20:47:09 +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:
kakwa 2016-09-08 23:21:53 +02:00
parent 81d7a808cb
commit e948177a41
6 changed files with 56 additions and 12 deletions

View file

@ -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"},