summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorJerry Gilliam <Jerry.Gilliam@Sun.COM>2010-08-10 17:19:16 -0700
committerJerry Gilliam <Jerry.Gilliam@Sun.COM>2010-08-10 17:19:16 -0700
commit999620f696af5092beda95a29692ad3ff16e9434 (patch)
tree8ba04b0a4342bca3dc118ed9c57fd94295a8d538 /usr/src
parente82bc0ba9649a7146fdab88089eaa4b8502b2da4 (diff)
downloadillumos-joyent-999620f696af5092beda95a29692ad3ff16e9434.tar.gz
4846848 devfsadm module delivery thread should be more robust
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/syseventd/modules/devfsadmd_mod/devfsadmd_mod.c80
1 files changed, 47 insertions, 33 deletions
diff --git a/usr/src/cmd/syseventd/modules/devfsadmd_mod/devfsadmd_mod.c b/usr/src/cmd/syseventd/modules/devfsadmd_mod/devfsadmd_mod.c
index e2d512a538..08d424f6ba 100644
--- a/usr/src/cmd/syseventd/modules/devfsadmd_mod/devfsadmd_mod.c
+++ b/usr/src/cmd/syseventd/modules/devfsadmd_mod/devfsadmd_mod.c
@@ -19,12 +19,9 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -70,9 +67,18 @@ static cond_t evq_cv;
static ev_queue_t *eventq_head;
static ev_queue_t *eventq_tail;
-#define DELIVER_FAILED gettext("/devices or /dev may not be current \
- (devfsadmd not responding) Run devfsadm")
-#define RETRY_MAX 3
+#define DELIVERY_FAILED \
+ gettext("devfsadmd not responding, /dev may not be current")
+
+#define DELIVERY_RESUMED \
+ gettext("devfsadmd now responding again")
+
+/*
+ * Retry error recovery when attempting to send an event to devfsadmd
+ */
+#define RETRY_DAEMON_RESTART 0
+#define RETRY_MSG_THRESHOLD 60
+#define RETRY_DAEMON_INTERVAL 60
static int
system1(const char *s_path, const char *s)
@@ -94,8 +100,8 @@ system1(const char *s_path, const char *s)
return (-1);
}
if (((geteuid() == st.st_uid) && ((st.st_mode & S_IXUSR) == 0)) ||
- ((getegid() == st.st_gid) && ((st.st_mode & S_IXGRP) == 0)) ||
- ((st.st_mode & S_IXOTH) == 0)) {
+ ((getegid() == st.st_gid) && ((st.st_mode & S_IXGRP) == 0)) ||
+ ((st.st_mode & S_IXOTH) == 0)) {
errno = EPERM;
return (-1);
}
@@ -208,7 +214,8 @@ thread_t deliver_thr_id;
void
devfsadmd_deliver_thr()
{
- int retry;
+ int retry = 0;
+ int msg_emitted = 0;
ev_queue_t *evqp;
(void) mutex_lock(&evq_lock);
@@ -230,33 +237,40 @@ devfsadmd_deliver_thr()
while (sysevent_send_event(sysevent_hp,
evqp->evq_ev) != 0) {
/*
- * If we are using an alternate root, devfsadm
- * is run to handle node creation.
+ * Invoke devfsadm to handle node creation
+ * but not for an alternate root.
*/
- if (use_alt_root == 0) {
- /*
- * daemon unresponsive -
- * restart daemon and retry once more
- * if not installing
- */
- if (errno == EBADF || errno == ENOENT) {
- if (system1(
- DEVFSADMD_START_PATH,
- DEVFSADMD_START) != -1) {
- (void) sleep(1);
- }
- }
- ++retry;
- if (retry < RETRY_MAX) {
- continue;
- } else {
- syslog(LOG_ERR, DELIVER_FAILED);
- break;
- }
- } else {
+ if (use_alt_root != 0)
break;
+ /*
+ * daemon unresponsive -
+ * restart daemon and retry once more
+ */
+ if ((errno == EBADF || errno == ENOENT) &&
+ (retry == RETRY_DAEMON_RESTART) ||
+ ((retry % RETRY_DAEMON_INTERVAL) == 0)) {
+ (void) system1(
+ DEVFSADMD_START_PATH,
+ DEVFSADMD_START);
+ }
+ if (retry == RETRY_MSG_THRESHOLD) {
+ syslog(LOG_ERR, DELIVERY_FAILED);
+ msg_emitted = 1;
}
+ (void) sleep(1);
+ ++retry;
+ continue;
}
+
+ /*
+ * Event delivered: remove from queue
+ * and reset delivery retry state.
+ */
+ if (msg_emitted) {
+ syslog(LOG_ERR, DELIVERY_RESUMED);
+ msg_emitted = 0;
+ }
+ retry = 0;
(void) mutex_lock(&evq_lock);
if (eventq_head != NULL) {
eventq_head = eventq_head->evq_next;