summaryrefslogtreecommitdiff
path: root/usr/src/lib/mpapi
diff options
context:
space:
mode:
authorJiri Svoboda <Jiri.Svoboda@Sun.COM>2010-06-04 11:42:10 +0200
committerJiri Svoboda <Jiri.Svoboda@Sun.COM>2010-06-04 11:42:10 +0200
commitab43d050e1c928fc2af0bbf98450a5358c535b1e (patch)
treee56adeb1f150add747f018f1e48955a154e9925b /usr/src/lib/mpapi
parentabcc7ef9701284c984bd4626e74d300a5de42dc5 (diff)
downloadillumos-joyent-ab43d050e1c928fc2af0bbf98450a5358c535b1e.tar.gz
6906406 fork() prevents libmpscsi_vhci from receiving events
Diffstat (limited to 'usr/src/lib/mpapi')
-rw-r--r--usr/src/lib/mpapi/libmpscsi_vhci/common/Initialize.c22
-rw-r--r--usr/src/lib/mpapi/libmpscsi_vhci/common/MP_RegForObjPropChangesPlugin.c27
-rw-r--r--usr/src/lib/mpapi/libmpscsi_vhci/common/MP_RegForObjVisChangesPlugin.c26
3 files changed, 37 insertions, 38 deletions
diff --git a/usr/src/lib/mpapi/libmpscsi_vhci/common/Initialize.c b/usr/src/lib/mpapi/libmpscsi_vhci/common/Initialize.c
index 24750cdfab..d2a4b3900a 100644
--- a/usr/src/lib/mpapi/libmpscsi_vhci/common/Initialize.c
+++ b/usr/src/lib/mpapi/libmpscsi_vhci/common/Initialize.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -54,17 +53,14 @@ pthread_mutex_t g_prop_mutex = PTHREAD_MUTEX_INITIALIZER;
MP_STATUS
Initialize(MP_UINT32 pluginOwnerID)
{
- MP_STATUS mpStatus = MP_STATUS_SUCCESS;
-
-
log(LOG_INFO, "Initialize()", " - enter");
(void) memset(&g_Property_Callback_List, 0,
- sizeof (PROPERTY_CALLBACK_NODE) * (MP_OBJECT_TYPE_MAX + 1));
+ sizeof (PROPERTY_CALLBACK_NODE) * (MP_OBJECT_TYPE_MAX + 1));
(void) memset(&g_Visibility_Callback_List, 0,
- sizeof (VISIBILITY_CALLBACK_NODE) * (MP_OBJECT_TYPE_MAX + 1));
+ sizeof (VISIBILITY_CALLBACK_NODE) * (MP_OBJECT_TYPE_MAX + 1));
/* Attempt to open the driver that this plugin will make request of. */
g_scsi_vhci_fd = open("/devices/scsi_vhci:devctl",
@@ -75,20 +71,12 @@ Initialize(MP_UINT32 pluginOwnerID)
" - failed to open driver. error is : %s",
strerror(errno));
log(LOG_INFO, "Initialize()", " - error exit");
- return (MP_STATUS_FAILED);
+ return (MP_STATUS_FAILED);
}
g_pluginOwnerID = pluginOwnerID;
- /* Register to listen for visibility and property change events */
- mpStatus = init_sysevents();
-
- log(LOG_INFO, "Initialize()",
- " - init_sysevents() returned %d",
- mpStatus);
-
-
log(LOG_INFO, "Initialize()", " - exit");
- return (mpStatus);
+ return (MP_STATUS_SUCCESS);
}
diff --git a/usr/src/lib/mpapi/libmpscsi_vhci/common/MP_RegForObjPropChangesPlugin.c b/usr/src/lib/mpapi/libmpscsi_vhci/common/MP_RegForObjPropChangesPlugin.c
index 2fa2e58e44..e60bfb10b6 100644
--- a/usr/src/lib/mpapi/libmpscsi_vhci/common/MP_RegForObjPropChangesPlugin.c
+++ b/usr/src/lib/mpapi/libmpscsi_vhci/common/MP_RegForObjPropChangesPlugin.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include "mp_utils.h"
@@ -41,17 +40,17 @@ MP_RegisterForObjectPropertyChangesPlugin(MP_OBJECT_PROPERTY_FN pClientFn,
log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
- " - enter");
+ " - enter");
/* Validate the object type passes in within range */
if (objectType > MP_OBJECT_TYPE_MAX) {
log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
- " - objectType is invalid");
+ " - objectType is invalid");
log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
- " - error exit");
+ " - error exit");
return (MP_STATUS_INVALID_PARAMETER);
}
@@ -59,22 +58,28 @@ MP_RegisterForObjectPropertyChangesPlugin(MP_OBJECT_PROPERTY_FN pClientFn,
if (objectType < 1) {
log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
- " - objectType is invalid");
+ " - objectType is invalid");
log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
- " - error exit");
+ " - error exit");
return (MP_STATUS_INVALID_PARAMETER);
}
- /* Check to see if we are going to be replacing */
+ /* Init sysevents if they have not been initialized yet */
+ if (g_SysEventHandle == NULL) {
+ if (init_sysevents() != MP_STATUS_SUCCESS)
+ return (MP_STATUS_FAILED);
+ }
+
+ /* Check to see if we are going to be replacing */
(void) pthread_mutex_lock(&g_prop_mutex);
if (g_Property_Callback_List[objectType].pClientFn != NULL) {
hasFunc = MP_TRUE;
}
- /* Add the registration. */
+ /* Add the registration */
g_Property_Callback_List[objectType].pClientFn = pClientFn;
g_Property_Callback_List[objectType].pCallerData = pCallerData;
(void) pthread_mutex_unlock(&g_prop_mutex);
@@ -82,14 +87,14 @@ MP_RegisterForObjectPropertyChangesPlugin(MP_OBJECT_PROPERTY_FN pClientFn,
if (hasFunc) {
log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
- " - returning MP_STATUS_FN_REPLACED");
+ " - returning MP_STATUS_FN_REPLACED");
return (MP_STATUS_FN_REPLACED);
}
log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
- " - exit");
+ " - exit");
return (MP_STATUS_SUCCESS);
}
diff --git a/usr/src/lib/mpapi/libmpscsi_vhci/common/MP_RegForObjVisChangesPlugin.c b/usr/src/lib/mpapi/libmpscsi_vhci/common/MP_RegForObjVisChangesPlugin.c
index 59585d3311..8fef484cdd 100644
--- a/usr/src/lib/mpapi/libmpscsi_vhci/common/MP_RegForObjVisChangesPlugin.c
+++ b/usr/src/lib/mpapi/libmpscsi_vhci/common/MP_RegForObjVisChangesPlugin.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include "mp_utils.h"
@@ -41,17 +40,17 @@ MP_RegisterForObjectVisibilityChangesPlugin(MP_OBJECT_VISIBILITY_FN pClientFn,
log(LOG_INFO, "MP_RegisterForObjectVisibilityChangesPlugin()",
- " - enter");
+ " - enter");
/* Validate the object type passes in within range */
if (objectType > MP_OBJECT_TYPE_MAX) {
log(LOG_INFO, "MP_RegisterForObjectVisibilityChangesPlugin()",
- " - objectType is invalid");
+ " - objectType is invalid");
log(LOG_INFO, "MP_RegisterForObjectVisibilityChangesPlugin()",
- " - error exit");
+ " - error exit");
return (MP_STATUS_INVALID_PARAMETER);
}
@@ -59,21 +58,28 @@ MP_RegisterForObjectVisibilityChangesPlugin(MP_OBJECT_VISIBILITY_FN pClientFn,
if (objectType < 1) {
log(LOG_INFO, "MP_RegisterForObjectVisibilityChangesPlugin()",
- " - objectType is invalid");
+ " - objectType is invalid");
log(LOG_INFO, "MP_RegisterForObjectVisibilityChangesPlugin()",
- " - error exit");
+ " - error exit");
return (MP_STATUS_INVALID_PARAMETER);
}
- /* Check to see if we are going to be replacing */
+ /* Init sysevents if they have not been initialized yet */
+ if (g_SysEventHandle == NULL) {
+ if (init_sysevents() != MP_STATUS_SUCCESS)
+ return (MP_STATUS_FAILED);
+ }
+
+ /* Check to see if we are going to be replacing */
(void) pthread_mutex_lock(&g_visa_mutex);
if (g_Visibility_Callback_List[objectType].pClientFn != NULL) {
hasFunc = MP_TRUE;
}
+ /* Add the registration */
g_Visibility_Callback_List[objectType].pClientFn = pClientFn;
g_Visibility_Callback_List[objectType].pCallerData = pCallerData;
(void) pthread_mutex_unlock(&g_visa_mutex);
@@ -81,14 +87,14 @@ MP_RegisterForObjectVisibilityChangesPlugin(MP_OBJECT_VISIBILITY_FN pClientFn,
if (hasFunc) {
log(LOG_INFO, "MP_RegisterForObjectVisibilityChangesPlugin()",
- " - returning MP_STATUS_FN_REPLACED");
+ " - returning MP_STATUS_FN_REPLACED");
return (MP_STATUS_FN_REPLACED);
}
log(LOG_INFO, "MP_RegisterForObjectVisibilityChangesPlugin()",
- " - exit");
+ " - exit");
return (MP_STATUS_SUCCESS);
}