Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/svc/startd/graph.c
          +++ new/usr/src/cmd/svc/startd/graph.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
       24 + * Copyright 2018 Joyent, Inc.
  24   25   * Copyright (c) 2015, Syneto S.R.L. All rights reserved.
  25   26   * Copyright 2016 Toomas Soome <tsoome@me.com>
  26   27   * Copyright 2016 RackTop Systems.
  27   28   */
  28   29  
  29   30  /*
  30   31   * graph.c - master restarter graph engine
  31   32   *
  32   33   *   The graph engine keeps a dependency graph of all service instances on the
  33   34   *   system, as recorded in the repository.  It decides when services should
↓ open down ↓ 535 lines elided ↑ open up ↑
 569  570   * after the target vertex has been found.
 570  571   */
 571  572  typedef enum {
 572  573          WALK_DEPENDENTS,
 573  574          WALK_DEPENDENCIES
 574  575  } graph_walk_dir_t;
 575  576  
 576  577  typedef int (*graph_walk_cb_t)(graph_vertex_t *, void *);
 577  578  
 578  579  typedef struct graph_walk_info {
 579      -        graph_walk_dir_t        gi_dir;
      580 +        graph_walk_dir_t        gi_dir;
 580  581          uchar_t                 *gi_visited;    /* vertex bitmap */
 581  582          int                     (*gi_pre)(graph_vertex_t *, void *);
 582  583          void                    (*gi_post)(graph_vertex_t *, void *);
 583  584          void                    *gi_arg;        /* callback arg */
 584  585          int                     gi_ret;         /* return value */
 585  586  } graph_walk_info_t;
 586  587  
 587  588  static int
 588  589  graph_walk_recurse(graph_edge_t *e, graph_walk_info_t *gip)
 589  590  {
↓ open down ↓ 3252 lines elided ↑ open up ↑
3842 3843  }
3843 3844  
3844 3845  /*
3845 3846   * The sulogin thread runs sulogin while can_come_up() is false.  run_sulogin()
3846 3847   * keeps sulogin from stepping on console-login's toes.
3847 3848   */
3848 3849  /* ARGSUSED */
3849 3850  static void *
3850 3851  sulogin_thread(void *unused)
3851 3852  {
     3853 +        (void) pthread_setname_np(pthread_self(), "sulogin");
     3854 +
3852 3855          MUTEX_LOCK(&dgraph_lock);
3853 3856  
3854 3857          assert(sulogin_thread_running);
3855 3858  
3856 3859          do {
3857 3860                  (void) run_sulogin("Console login service(s) cannot run\n");
3858 3861          } while (!can_come_up());
3859 3862  
3860 3863          sulogin_thread_running = B_FALSE;
3861 3864          MUTEX_UNLOCK(&dgraph_lock);
↓ open down ↓ 7 lines elided ↑ open up ↑
3869 3872  {
3870 3873          uint_t left;
3871 3874          scf_handle_t *h;
3872 3875          scf_instance_t *inst;
3873 3876          scf_property_t *prop;
3874 3877          scf_value_t *val;
3875 3878          const char *msg;
3876 3879          char *buf;
3877 3880          int r;
3878 3881  
     3882 +        (void) pthread_setname_np(pthread_self(), "single_user");
     3883 +
3879 3884          MUTEX_LOCK(&single_user_thread_lock);
3880 3885          single_user_thread_count++;
3881 3886  
3882 3887          if (!booting_to_single_user)
3883 3888                  kill_user_procs();
3884 3889  
3885 3890          if (go_single_user_mode || booting_to_single_user) {
3886 3891                  msg = "SINGLE USER MODE\n";
3887 3892          } else {
3888 3893                  assert(go_to_level1);
↓ open down ↓ 1883 lines elided ↑ open up ↑
5772 5777   * graph_event_thread()
5773 5778   *    Wait for state changes from the restarters.
5774 5779   */
5775 5780  /*ARGSUSED*/
5776 5781  void *
5777 5782  graph_event_thread(void *unused)
5778 5783  {
5779 5784          scf_handle_t *h;
5780 5785          int err;
5781 5786  
     5787 +        (void) pthread_setname_np(pthread_self(), "graph_event");
     5788 +
5782 5789          h = libscf_handle_create_bound_loop();
5783 5790  
5784 5791          /*CONSTCOND*/
5785 5792          while (1) {
5786 5793                  graph_protocol_event_t *e;
5787 5794  
5788 5795                  MUTEX_LOCK(&gu->gu_lock);
5789 5796  
5790 5797                  while (gu->gu_wakeup == 0)
5791 5798                          (void) pthread_cond_wait(&gu->gu_cv, &gu->gu_lock);
↓ open down ↓ 339 lines elided ↑ open up ↑
6131 6138   *
6132 6139   * Graph management thread.
6133 6140   */
6134 6141  /*ARGSUSED*/
6135 6142  void *
6136 6143  graph_thread(void *arg)
6137 6144  {
6138 6145          scf_handle_t *h;
6139 6146          int err;
6140 6147  
     6148 +        (void) pthread_setname_np(pthread_self(), "graph");
     6149 +
6141 6150          h = libscf_handle_create_bound_loop();
6142 6151  
6143 6152          if (st->st_initial)
6144 6153                  set_initial_milestone(h);
6145 6154  
6146 6155          MUTEX_LOCK(&dgraph_lock);
6147 6156          initial_milestone_set = B_TRUE;
6148 6157          err = pthread_cond_broadcast(&initial_milestone_cv);
6149 6158          assert(err == 0);
6150 6159          MUTEX_UNLOCK(&dgraph_lock);
↓ open down ↓ 636 lines elided ↑ open up ↑
6787 6796  void *
6788 6797  repository_event_thread(void *unused)
6789 6798  {
6790 6799          scf_handle_t *h;
6791 6800          scf_propertygroup_t *pg;
6792 6801          scf_instance_t *inst;
6793 6802          char *fmri = startd_alloc(max_scf_fmri_size);
6794 6803          char *pg_name = startd_alloc(max_scf_value_size);
6795 6804          int r;
6796 6805  
     6806 +        (void) pthread_setname_np(pthread_self(), "repository_event");
     6807 +
6797 6808          h = libscf_handle_create_bound_loop();
6798 6809  
6799 6810          pg = safe_scf_pg_create(h);
6800 6811          inst = safe_scf_instance_create(h);
6801 6812  
6802 6813  retry:
6803 6814          if (_scf_notify_add_pgtype(h, SCF_GROUP_FRAMEWORK) != SCF_SUCCESS) {
6804 6815                  if (scf_error() == SCF_ERROR_CONNECTION_BROKEN) {
6805 6816                          libscf_handle_rebind(h);
6806 6817                  } else {
↓ open down ↓ 91 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX