Mercurial > illumos > illumos-gate
changeset 3973:1e8fb2023770
6540816 Local Zone Assertion failed: impl_handle != NULL, file ../common/libshare.c, line 2208
author | dougm |
---|---|
date | Thu, 05 Apr 2007 07:33:45 -0700 |
parents | cf5de7ce56fd |
children | a01a9d07ea67 |
files | usr/src/lib/libshare/common/libshare.c usr/src/lib/libshare/common/scfutil.c usr/src/lib/libshare/common/scfutil.h |
diffstat | 3 files changed, 39 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/lib/libshare/common/libshare.c Thu Apr 05 06:45:04 2007 -0700 +++ b/usr/src/lib/libshare/common/libshare.c Thu Apr 05 07:33:45 2007 -0700 @@ -735,18 +735,42 @@ (void) lockf(lockfd, F_ULOCK, 0); (void) close(lockfd); } - (void) sa_get_config(handle->scfhandle, &handle->tree, - &handle->doc, handle); - /* need to setup for later searchs when using group/share */ - err = add_handle_for_root(handle->tree, handle); + + /* + * It is essential that the document tree and + * the internal list of roots to handles be + * setup before anything that might try to + * create a new object is called. The document + * tree is the combination of handle->doc and + * handle->tree. This allows searches, + * etc. when all you have is an object in the + * tree. + */ + handle->doc = xmlNewDoc((xmlChar *)"1.0"); + handle->tree = xmlNewNode(NULL, (xmlChar *)"sharecfg"); + if (handle->doc != NULL && handle->tree != NULL) { + xmlDocSetRootElement(handle->doc, handle->tree); + err = add_handle_for_root(handle->tree, handle); + if (err == SA_OK) + err = sa_get_config(handle->scfhandle, + handle->tree, handle); + } else { + if (handle->doc != NULL) + xmlFreeDoc(handle->doc); + if (handle->tree != NULL) + xmlFreeNode(handle->tree); + err = SA_NO_MEMORY; + } + saunblocksigs(&old); if (err != SA_OK) { /* - * If we couldn't add the tree handle to the - * list, then things are going to fail - * badly. Might as well undo everything now - * and fail the sa_init(). + * If we couldn't add the tree handle + * to the list, then things are going + * to fail badly. Might as well undo + * everything now and fail the + * sa_init(). */ sa_fini(handle); return (NULL); @@ -764,6 +788,7 @@ opt = sa_create_optionset(defgrp, "nfs"); } } + if (updatelegacy == B_TRUE) { sablocksigs(&old); getlegacyconfig((sa_handle_t)handle,
--- a/usr/src/lib/libshare/common/scfutil.c Thu Apr 05 06:45:04 2007 -0700 +++ b/usr/src/lib/libshare/common/scfutil.c Thu Apr 05 07:33:45 2007 -0700 @@ -934,20 +934,16 @@ * below the groups based on property groups and properties. */ int -sa_get_config(scfutilhandle_t *handle, xmlNodePtr *root, xmlDocPtr *doc, - sa_handle_t sahandle) +sa_get_config(scfutilhandle_t *handle, xmlNodePtr root, sa_handle_t sahandle) { int ret = SA_OK; scf_instance_t *instance; scf_iter_t *iter; char buff[BUFSIZ * 2]; - *doc = xmlNewDoc((xmlChar *)"1.0"); - *root = xmlNewNode(NULL, (xmlChar *)"sharecfg"); instance = scf_instance_create(handle->handle); iter = scf_iter_create(handle->handle); - if (*doc != NULL && *root != NULL && instance != NULL && iter != NULL) { - xmlDocSetRootElement(*doc, *root); + if (instance != NULL && iter != NULL) { if ((ret = scf_iter_service_instances(iter, handle->service)) == 0) { while ((ret = scf_iter_next_instance(iter, @@ -955,21 +951,14 @@ if (scf_instance_get_name(instance, buff, sizeof (buff)) > 0) { if (strcmp(buff, "default") == 0) - sa_extract_defaults(*root, handle, instance); - ret = sa_extract_group(*root, handle, instance, + sa_extract_defaults(root, handle, instance); + ret = sa_extract_group(root, handle, instance, sahandle); } } } - } else { - /* if we can't create the document, cleanup */ - if (*doc != NULL) - xmlFreeDoc(*doc); - if (*root != NULL) - xmlFreeNode(*root); - *doc = NULL; - *root = NULL; } + /* always cleanup these */ if (instance != NULL) scf_instance_destroy(instance);
--- a/usr/src/lib/libshare/common/scfutil.h Thu Apr 05 06:45:04 2007 -0700 +++ b/usr/src/lib/libshare/common/scfutil.h Thu Apr 05 07:33:45 2007 -0700 @@ -55,8 +55,7 @@ extern void sa_scf_fini(scfutilhandle_t *); extern scfutilhandle_t *sa_scf_init(); -extern int sa_get_config(scfutilhandle_t *, xmlNodePtr *, xmlDocPtr *, - sa_handle_t); +extern int sa_get_config(scfutilhandle_t *, xmlNodePtr, sa_handle_t); extern int sa_get_instance(scfutilhandle_t *, char *); extern int sa_create_instance(scfutilhandle_t *, char *);