diff options
Diffstat (limited to 'src/ctx.cpp')
-rw-r--r-- | src/ctx.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/ctx.cpp b/src/ctx.cpp index b6298e2..917c3e6 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -43,7 +43,8 @@ xs::ctx_t::ctx_t (uint32_t io_threads_) : starting (true), terminating (false), max_sockets (512), - io_thread_count (io_threads_) + io_thread_count (io_threads_), + reentrant (false) { } @@ -147,6 +148,16 @@ int xs::ctx_t::setctxopt (int option_, const void *optval_, size_t optvallen_) max_sockets = *((int*) optval_); opt_sync.unlock (); break; + case XS_CTX_REENTRANT: + if (optvallen_ != sizeof (int) || (*((int*) optval_) != 0 && + *((int*) optval_) != 1)) { + errno = EINVAL; + return -1; + } + opt_sync.lock (); + reentrant = (*((int*) optval_) ? true : false); + opt_sync.unlock (); + break; default: errno = EINVAL; return -1; @@ -379,6 +390,14 @@ void xs::ctx_t::publish_logs (const char *text_) log_sync.unlock (); } +bool xs::ctx_t::is_reentrant () +{ + opt_sync.lock (); + bool ret = reentrant; + opt_sync.unlock (); + return ret; +} + // The last used socket ID, or 0 if no socket was used so far. Note that this // is a global variable. Thus, even sockets created in different contexts have // unique IDs. |