[ 3586680 ] improve error reporting in cmciConnect2
diff --git a/NEWS b/NEWS index b47e19e..d586380 100644 --- a/NEWS +++ b/NEWS
@@ -13,6 +13,7 @@ - 3547832: memory leak in backend/cimxml/grammer.c - 3555103: wrong declaration of release attribute in _CIMCArgsFT - 3566968: sfcc enumInstances fails to parse the xml +- 3586680: improve error reporting in cmciConnect2 Changes in 2.2.3 ================
diff --git a/contributions.txt b/contributions.txt index 3629fae..c08b7e1 100644 --- a/contributions.txt +++ b/contributions.txt
@@ -39,6 +39,7 @@ 03/23/2011 [ 2990315 ] cmciRelease not called in case of error 04/25/2011 [ 2967265 ] code cleanup in sfcclient 05/29/2012 [ 3528819 ] Crash in getInstance when instance has NULL properties +12/04/2012 [ 3586680 ] improve error reporting in cmciConnect2 Suresh Sundriyal, VMWare ------------------------
diff --git a/frontend/sfcc/sfcclient.c b/frontend/sfcc/sfcclient.c index 2eed047..adbe355 100644 --- a/frontend/sfcc/sfcclient.c +++ b/frontend/sfcc/sfcclient.c
@@ -76,10 +76,11 @@ CMPIStatus *rc) { CMCIClient *cc = NULL; - char *msg; + char *msg = NULL; int retc = 0; char *client; + if (rc) rc->rc = CMPI_RC_OK; pthread_mutex_lock(&ConnectionControl.ccMux); if (ConnectionControl.ccCount == 0) { client = getenv("SFCC_CLIENT"); @@ -94,8 +95,15 @@ } if (retc || ConnectionControl.ccEnv == NULL) { if(rc) { - rc->rc=CMPI_RC_ERR_FAILED; - rc->msg=NULL; + rc->rc = CMPI_RC_ERR_FAILED; + if (msg) { + fprintf(stderr, "sfcc: NewCIMCEnv failed: %s\n", msg); + free(msg); + } + else { + fprintf(stderr, "sfcc: NewCIMCEnv failed without message\n"); + } + rc->msg = NULL; /* Can't create CMPIString without ConnectionControl.ccEnv ! */ } cc=NULL; } else { @@ -113,8 +121,10 @@ /* cleanup ccEnv after pthread_mutex_unlock */ cmciRelease(NULL); if (rc) { - rc->rc = CMPI_RC_ERR_FAILED; - rc->msg = NULL; + if (rc->rc == CMPI_RC_OK) + rc->rc = CMPI_RC_ERR_FAILED; + if (rc->msg == NULL && ConnectionControl.ccEnv != NULL) + rc->msg = native_new_CMPIString("Connection failed", NULL); } }