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


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.


  24  */
  25 
  26 #include <stdlib.h>
  27 #include <libscf.h>
  28 #include <string.h>
  29 #include "nscd_switch.h"
  30 #include "nscd_log.h"
  31 #include "nscd_door.h"
  32 
  33 extern int      _whoami;
  34 
  35 /*
  36  * Service states monitored by nscd. Protected by
  37  * readers/writer lock nscd_smf_service_state_lock
  38  */
  39 nscd_smf_state_t *nscd_smf_service_state;
  40 static rwlock_t nscd_smf_service_state_lock = DEFAULTRWLOCK;
  41 /*
  42  * init service state table
  43  */


  90         else if (strcmp(state, SCF_STATE_STRING_ONLINE) == 0)
  91                 NSCD_SMF_SVC_STATE(srci) = SCF_STATE_ONLINE;
  92         else if (strcmp(state, SCF_STATE_STRING_DEGRADED) == 0)
  93                 NSCD_SMF_SVC_STATE(srci) = SCF_STATE_DEGRADED;
  94 
  95         ret = NSCD_SMF_SVC_STATE(srci);
  96         (void) rw_unlock(&nscd_smf_service_state_lock);
  97 
  98         free(state);
  99         return (ret);
 100 }
 101 
 102 /* ARGSUSED */
 103 static void *
 104 set_smf_state(void *arg)
 105 {
 106 
 107         int     i;
 108         int     st;
 109 


 110         /*
 111          * the forker nscd needs not monitor the state
 112          * of the client services
 113          */
 114         if (_whoami == NSCD_FORKER)
 115                 thr_exit(0);
 116 
 117         /*CONSTCOND*/
 118         while (1) {
 119 
 120                 /* skip the first service which is nscd */
 121                 for (i = 1; i < NSCD_NUM_SMF_FMRI; i++) {
 122                         st = query_smf_state(i);
 123                         if (st == NSCD_SVC_STATE_UNINITED)
 124                                 break;
 125                 }
 126 
 127                 (void) sleep(NSCD_SW_CFG_G.check_smf_state_interval_g);
 128         }
 129         /* NOTREACHED */




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  *
  25  * Copyright 2018 Joyent, Inc.
  26  */
  27 
  28 #include <stdlib.h>
  29 #include <libscf.h>
  30 #include <string.h>
  31 #include "nscd_switch.h"
  32 #include "nscd_log.h"
  33 #include "nscd_door.h"
  34 
  35 extern int      _whoami;
  36 
  37 /*
  38  * Service states monitored by nscd. Protected by
  39  * readers/writer lock nscd_smf_service_state_lock
  40  */
  41 nscd_smf_state_t *nscd_smf_service_state;
  42 static rwlock_t nscd_smf_service_state_lock = DEFAULTRWLOCK;
  43 /*
  44  * init service state table
  45  */


  92         else if (strcmp(state, SCF_STATE_STRING_ONLINE) == 0)
  93                 NSCD_SMF_SVC_STATE(srci) = SCF_STATE_ONLINE;
  94         else if (strcmp(state, SCF_STATE_STRING_DEGRADED) == 0)
  95                 NSCD_SMF_SVC_STATE(srci) = SCF_STATE_DEGRADED;
  96 
  97         ret = NSCD_SMF_SVC_STATE(srci);
  98         (void) rw_unlock(&nscd_smf_service_state_lock);
  99 
 100         free(state);
 101         return (ret);
 102 }
 103 
 104 /* ARGSUSED */
 105 static void *
 106 set_smf_state(void *arg)
 107 {
 108 
 109         int     i;
 110         int     st;
 111 
 112         (void) thr_setname(thr_self(), "set_smf_state");
 113 
 114         /*
 115          * the forker nscd needs not monitor the state
 116          * of the client services
 117          */
 118         if (_whoami == NSCD_FORKER)
 119                 thr_exit(0);
 120 
 121         /*CONSTCOND*/
 122         while (1) {
 123 
 124                 /* skip the first service which is nscd */
 125                 for (i = 1; i < NSCD_NUM_SMF_FMRI; i++) {
 126                         st = query_smf_state(i);
 127                         if (st == NSCD_SVC_STATE_UNINITED)
 128                                 break;
 129                 }
 130 
 131                 (void) sleep(NSCD_SW_CFG_G.check_smf_state_interval_g);
 132         }
 133         /* NOTREACHED */