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:
parent
81d7a808cb
commit
e948177a41
6 changed files with 56 additions and 12 deletions
|
@ -84,6 +84,22 @@ void free_ssl() {
|
|||
OBJ_cleanup();
|
||||
}
|
||||
|
||||
// recover a ts wrapper
|
||||
ts_resp_ctx_wrapper *get_ctxw(rfc3161_context *ct) {
|
||||
ts_resp_ctx_wrapper *ret = NULL;
|
||||
for (int i = 0; i < ct->numthreads; i++) {
|
||||
pthread_mutex_lock(&ct->ts_ctx_pool[i].lock);
|
||||
if (ct->ts_ctx_pool[i].available) {
|
||||
ct->ts_ctx_pool[i].available = 0;
|
||||
ret = &(ct->ts_ctx_pool[i]);
|
||||
pthread_mutex_unlock(&ct->ts_ctx_pool[i].lock);
|
||||
return ret;
|
||||
}
|
||||
pthread_mutex_unlock(&ct->ts_ctx_pool[i].lock);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
TS_RESP_CTX *create_tsctx(rfc3161_context *ct, CONF *conf, const char *section,
|
||||
const char *policy) {
|
||||
unsigned long err_code;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue