Print this page
10120 smatch indenting fixes for usr/src/cmd
Reviewed by: Gergő Doma <domag02@gmail.com>
Portions contributed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/syseventd/daemons/syseventd/sysevent_client.c
+++ new/usr/src/cmd/syseventd/daemons/syseventd/sysevent_client.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright (c) 2000-2001 by Sun Microsystems, Inc.
24 24 * All rights reserved.
25 25 */
26 26
27 -#pragma ident "%Z%%M% %I% %E% SMI"
27 +/*
28 + * Copyright (c) 2018, Joyent, Inc.
29 + */
28 30
29 31 /*
30 32 * syseventd client interfaces
31 33 */
32 34
33 35 #include <stdio.h>
34 36 #include <sys/types.h>
35 37 #include <stdarg.h>
36 38 #include <stddef.h>
37 39 #include <stdlib.h>
38 40 #include <unistd.h>
39 41 #include <door.h>
40 42 #include <errno.h>
41 43 #include <strings.h>
42 44 #include <thread.h>
43 45 #include <pthread.h>
44 46 #include <synch.h>
45 47 #include <syslog.h>
46 48 #include <fcntl.h>
47 49 #include <stropts.h>
48 50 #include <locale.h>
49 51 #include <libsysevent.h>
50 52 #include <sys/stat.h>
51 53 #include <sys/sysevent.h>
52 54
53 55 #include "syseventd.h"
54 56 #include "message.h"
55 57
56 58 /*
57 59 * sysevent_client.c - contains routines particular to syseventd client
58 60 * management (addition and deletion).
59 61 */
60 62
61 63 /* Global client table and lock */
62 64 struct sysevent_client *sysevent_client_tbl[MAX_SLM];
63 65 mutex_t client_tbl_lock;
64 66
65 67 /*
66 68 * initialize_client_tbl - Initialize each client entry in the syseventd
67 69 * client table. Each entry in the client table
68 70 * entry represents one shared-object (SLM) client.
69 71 */
70 72 void
71 73 initialize_client_tbl()
72 74 {
73 75 struct sysevent_client *scp;
74 76 int i;
75 77
76 78 for (i = 0; i < MAX_SLM; ++i) {
77 79 if ((scp = (struct sysevent_client *)malloc(
78 80 sizeof (struct sysevent_client))) == NULL)
79 81 goto init_error;
80 82
81 83 if (mutex_init(&scp->client_lock, USYNC_THREAD, NULL) != 0)
82 84 goto init_error;
83 85
84 86 scp->client_data = NULL;
85 87 scp->client_num = i;
86 88 scp->eventq = NULL;
87 89
88 90 /* Clear all flags when setting UNLOADED */
89 91 scp->client_flags = SE_CLIENT_UNLOADED;
90 92
91 93 sysevent_client_tbl[i] = scp;
92 94 }
93 95
94 96 return;
95 97
96 98 init_error:
97 99 syseventd_err_print(INIT_CLIENT_TBL_ERR);
98 100 syseventd_exit(1);
99 101 }
100 102
101 103 /*
102 104 * insert_client - called when a new SLM is loaded with syseventd. The
103 105 * client specific data is updated to reflect this addition
104 106 */
105 107 int
106 108 insert_client(void *client_data, int client_type, int retry_limit)
107 109 {
108 110 int i;
109 111 struct sysevent_client *scp;
110 112
111 113 (void) mutex_lock(&client_tbl_lock);
112 114 for (i = 0; i < MAX_SLM; ++i) {
113 115 scp = sysevent_client_tbl[i];
↓ open down ↓ |
76 lines elided |
↑ open up ↑ |
114 116 if (scp->client_data == NULL) {
115 117 (void) mutex_lock(&scp->client_lock);
116 118 scp->client_data = client_data;
117 119 scp->client_type = client_type;
118 120 scp->retry_limit = retry_limit;
119 121 scp->client_flags |= SE_CLIENT_LOADED;
120 122 (void) cond_init(&scp->client_cv, USYNC_THREAD,
121 123 NULL);
122 124 (void) mutex_unlock(&scp->client_lock);
123 125 (void) mutex_unlock(&client_tbl_lock);
124 - return (i);
126 + return (i);
125 127 }
126 128 }
127 129
128 130 (void) mutex_unlock(&client_tbl_lock);
129 131 syseventd_print(1, "Unable to insert into syseventd client table\n");
130 132 return (-1);
131 133 }
132 134
133 135 /*
134 136 * delete_client - called to remove an SLM from the client table. Client
135 137 * removal may occur when syseventd terminates, receives
136 138 * a SIGHUP or the client must be force unloaded due
137 139 * it's unresponsive nature.
138 140 */
139 141 void
140 142 delete_client(int id)
141 143 {
142 144 struct sysevent_client *scp;
143 145
144 146 scp = sysevent_client_tbl[id];
145 147
146 148 free(scp->client_data);
147 149 scp->client_data = NULL;
148 150
149 151 /* Clear all flags when setting UNLOADED */
150 152 scp->client_flags = SE_CLIENT_UNLOADED;
151 153 (void) cond_destroy(&scp->client_cv);
152 154 bzero(&scp->client_cv, sizeof (cond_t));
153 155 }
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX