diff options
author | Renato Botelho <renato@netgate.com> | 2016-04-28 11:34:22 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-04-28 11:34:22 -0300 |
commit | d1ef4e7974b0b2817406da15fd95d9f836aa1912 (patch) | |
tree | be0fc739c69cdd44a57a5c6abe9001c070bf335f /contrib/ntp/libntp/work_thread.c | |
parent | 6f331e8a44f8f914e7cd1813a5e96d20c55891e5 (diff) | |
parent | 1d5d3749a4b560c02782ced59660844e31c631a9 (diff) | |
download | FreeBSD-src-d1ef4e7974b0b2817406da15fd95d9f836aa1912.zip FreeBSD-src-d1ef4e7974b0b2817406da15fd95d9f836aa1912.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'contrib/ntp/libntp/work_thread.c')
-rw-r--r-- | contrib/ntp/libntp/work_thread.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/contrib/ntp/libntp/work_thread.c b/contrib/ntp/libntp/work_thread.c index 11e3267..82f6064 100644 --- a/contrib/ntp/libntp/work_thread.c +++ b/contrib/ntp/libntp/work_thread.c @@ -88,7 +88,27 @@ static int ensure_workresp_empty_slot(blocking_child *); static int queue_req_pointer(blocking_child *, blocking_pipe_header *); static void cleanup_after_child(blocking_child *); +static sema_type worker_mmutex; +static sem_ref worker_memlock; +/* -------------------------------------------------------------------- + * locking the global worker state table (and other global stuff) + */ +void +worker_global_lock( + int inOrOut) +{ + if (worker_memlock) { + if (inOrOut) + wait_for_sem(worker_memlock, NULL); + else + tickle_sem(worker_memlock); + } +} + +/* -------------------------------------------------------------------- + * implementation isolation wrapper + */ void exit_worker( int exitcode @@ -724,6 +744,9 @@ prepare_child_sems( blocking_child *c ) { + if (NULL == worker_memlock) + worker_memlock = create_sema(&worker_mmutex, 1, 1); + c->accesslock = create_sema(&c->sem_table[0], 1, 1); c->workitems_pending = create_sema(&c->sem_table[1], 0, 0); c->wake_scheduled_sleep = create_sema(&c->sem_table[2], 0, 1); |