Lines Matching refs:list

9  *    notice, this list of conditions and the following disclaimer.
11 * notice, this list of conditions and the following disclaimer in the
55 * Initialize the eventhandler mutex and list.
72 eventhandler_register_internal(struct eventhandler_list *list,
84 /* Do we need to find/create the (slow) list? */
85 if (list == NULL) {
86 /* look for a matching, existing list */
87 list = _eventhandler_find_list(name);
89 /* Do we need to create the list? */
90 if (list == NULL) {
98 list = _eventhandler_find_list(name);
99 if (list != NULL) {
102 CTR2(KTR_EVH, "%s: creating list \"%s\"", __func__, name);
103 list = new_list;
104 list->el_flags = 0;
105 list->el_runcount = 0;
106 bzero(&list->el_lock, sizeof(list->el_lock));
107 list->el_name = (char *)list + sizeof(struct eventhandler_list);
108 strcpy(list->el_name, name);
109 TAILQ_INSERT_HEAD(&eventhandler_lists, list, el_link);
113 if (!(list->el_flags & EHL_INITTED)) {
114 TAILQ_INIT(&list->el_entries);
115 mtx_init(&list->el_lock, name, "eventhandler list", MTX_DEF);
116 atomic_store_rel_int(&list->el_flags, EHL_INITTED);
123 /* sort it into the list */
126 EHL_LOCK(list);
127 TAILQ_FOREACH(ep, &list->el_entries, ee_link) {
135 TAILQ_INSERT_TAIL(&list->el_entries, epn, ee_link);
136 EHL_UNLOCK(list);
141 eventhandler_register(struct eventhandler_list *list, const char *name,
153 return (eventhandler_register_internal(list, name, &eg->ee));
165 vimage_eventhandler_register(struct eventhandler_list *list, const char *name,
179 return (eventhandler_register_internal(list, name, &eg->ee));
184 eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag)
188 EHL_LOCK_ASSERT(list, MA_OWNED);
191 if (list->el_runcount == 0) {
193 list->el_name);
194 TAILQ_REMOVE(&list->el_entries, ep, ee_link);
198 ep, list->el_name);
202 /* remove entire list */
203 if (list->el_runcount == 0) {
205 list->el_name);
206 while (!TAILQ_EMPTY(&list->el_entries)) {
207 ep = TAILQ_FIRST(&list->el_entries);
208 TAILQ_REMOVE(&list->el_entries, ep, ee_link);
213 __func__, list->el_name);
214 TAILQ_FOREACH(ep, &list->el_entries, ee_link)
218 while (list->el_runcount > 0)
219 mtx_sleep(list, &list->el_lock, 0, "evhrm", 0);
220 EHL_UNLOCK(list);
224 * Internal version for use when eventhandler list is already locked.
229 struct eventhandler_list *list;
232 TAILQ_FOREACH(list, &eventhandler_lists, el_link) {
233 if (!strcmp(name, list->el_name))
236 return (list);
240 * Lookup a "slow" list by name. Returns with the list locked.
245 struct eventhandler_list *list;
250 /* scan looking for the requested list */
252 list = _eventhandler_find_list(name);
253 if (list != NULL)
254 EHL_LOCK(list);
257 return(list);
261 * Prune "dead" entries from an eventhandler list.
264 eventhandler_prune_list(struct eventhandler_list *list)
269 CTR2(KTR_EVH, "%s: pruning list \"%s\"", __func__, list->el_name);
270 EHL_LOCK_ASSERT(list, MA_OWNED);
271 TAILQ_FOREACH_SAFE(ep, &list->el_entries, ee_link, en) {
273 TAILQ_REMOVE(&list->el_entries, ep, ee_link);
279 wakeup(list);