Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section
@@ -19,11 +19,11 @@
* CDDL HEADER END
*/
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright 2018 Joyent, Inc.
*/
/*
* restarter.c - service manipulation
*
@@ -992,10 +992,12 @@
restarter_post_fsminimal_thread(void *unused)
{
scf_handle_t *h;
int r;
+ (void) pthread_setname_np(pthread_self(), "restarter_post_fsmin");
+
h = libscf_handle_create_bound_loop();
for (;;) {
r = libscf_create_self(h);
if (r == 0)
@@ -1769,10 +1771,12 @@
restarter_instance_qentry_t *event;
restarter_inst_t *rip;
char *fmri = (char *)arg;
struct timespec to;
+ (void) pthread_setname_np(pthread_self(), "restarter_process_events");
+
assert(fmri != NULL);
h = libscf_handle_create_bound_loop();
/* grab the queue lock */
@@ -1937,12 +1941,12 @@
free(fmri);
return (NULL);
}
static int
-is_admin_event(restarter_event_type_t t) {
-
+is_admin_event(restarter_event_type_t t)
+{
switch (t) {
case RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON:
case RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON_IMMEDIATE:
case RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF:
case RESTARTER_EVENT_TYPE_ADMIN_REFRESH:
@@ -1983,10 +1987,12 @@
static void *
restarter_event_thread(void *unused)
{
scf_handle_t *h;
+ (void) pthread_setname_np(pthread_self(), "restarter_event");
+
/*
* This is a new thread, and thus, gets its own handle
* to the repository.
*/
h = libscf_handle_create_bound_loop();
@@ -2194,10 +2200,12 @@
restarter_contracts_event_thread(void *unused)
{
int fd, err;
scf_handle_t *local_handle;
+ (void) pthread_setname_np(pthread_self(), "restarter_contracts_event");
+
/*
* Await graph load completion. That is, stop here, until we've scanned
* the repository for contract - instance associations.
*/
MUTEX_LOCK(&st->st_load_lock);
@@ -2543,10 +2551,12 @@
* this thread. As timeouts are specified in seconds, we'll do
* the necessary processing every second, as long as the queue
* is not empty.
*/
+ (void) pthread_setname_np(pthread_self(), "restarter_timeouts_event");
+
/*CONSTCOND*/
while (1) {
/*
* As long as the timeout list isn't empty, process it
* every second.