diff options
Diffstat (limited to 'runtime/staprun/staprun_funcs.c')
-rw-r--r-- | runtime/staprun/staprun_funcs.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/runtime/staprun/staprun_funcs.c b/runtime/staprun/staprun_funcs.c index eec4ae63..86a72985 100644 --- a/runtime/staprun/staprun_funcs.c +++ b/runtime/staprun/staprun_funcs.c @@ -385,8 +385,10 @@ int check_permissions(void) return check_path(); } -/* wait for symbol requests and reply */ -void handle_symbols(void) +pthread_t symbol_thread_id = (pthread_t)0; + +/* Symbol handling thread */ +void *handle_symbols(void __attribute__((unused)) *arg) { ssize_t nb; void *data; @@ -395,12 +397,6 @@ void handle_symbols(void) dbug(2, "waiting for symbol requests\n"); - /* create control channel */ - if (init_ctl_channel() < 0) { - err("Failed to initialize control channel.\n"); - exit(1); - } - while (1) { /* handle messages from control channel */ nb = read(control_channel, recvbuf, sizeof(recvbuf)); if (nb <= 0) { @@ -417,7 +413,7 @@ void handle_symbols(void) { dbug(2, "STP_MODULES request received\n"); do_module(data); - goto done; + break; } case STP_SYMBOLS: { @@ -439,6 +435,36 @@ void handle_symbols(void) err("WARNING: ignored message of type %d\n", (type)); } } -done: + + return NULL; +} + +void start_symbol_thread(void) +{ + int status; + + /* create symbol control channel */ + status = do_cap(CAP_DAC_OVERRIDE, init_ctl_channel, 1); + drop_cap(CAP_DAC_OVERRIDE); + if (status < 0) { + err("Failed to initialize control channel.\n"); + exit(1); + } + status = pthread_create(&symbol_thread_id, NULL, handle_symbols, NULL); + if (status) { + perr("Failed to create symbol thread.\n"); + exit(1); + } +} + +void stop_symbol_thread(void) +{ + + if (symbol_thread_id) { + dbug(2, "Stopping symbol thread.\n"); + pthread_cancel(symbol_thread_id); + pthread_join(symbol_thread_id, NULL); + } close_ctl_channel(); } + |