diff --git include/libstoragemgmt/libstoragemgmt_plug_interface.h include/libstoragemgmt/libstoragemgmt_plug_interface.h index 24c84d0..c0e29a3 100644 --- include/libstoragemgmt/libstoragemgmt_plug_interface.h +++ include/libstoragemgmt/libstoragemgmt_plug_interface.h @@ -1016,6 +1016,7 @@ lsmDisk LSM_DLL_EXPORT **lsmDiskRecordAllocArray( uint32_t size ); * @param block_count Number of blocks for disk * @param disk_status Status * @param op OptionalData can be NULL if not available + * NOTE: op gets copied internally * @param system_id System id this disk resides in * @return Pointer to allocated disk record or NULL on memory error. */ diff --git plugin/simc_lsmplugin.c plugin/simc_lsmplugin.c index f9c4530..e12c630 100644 --- plugin/simc_lsmplugin.c +++ plugin/simc_lsmplugin.c @@ -567,7 +567,8 @@ static int _list_initiators(lsmPluginPtr c, lsmInitiator **initArray[], if( init_key && init_val ) { g_hash_table_insert(tmp_inits, init_key, init_val); } else { - g_hash_table_destroy(tmp_inits); + free(init_key); + lsmInitiatorRecordFree(init_val); rc = LSM_ERR_NO_MEMORY; } } @@ -652,12 +653,12 @@ static int list_disks(lsmPluginPtr c, lsmDisk **disks[], uint32_t *count, { int i; int rc = LSM_ERR_OK; - struct plugin_data *pd = (struct plugin_data*)lsmGetPrivateData(c); char name[17]; char sn[32]; + struct plugin_data *pd = (struct plugin_data*)lsmGetPrivateData(c); lsmOptionalData *od = lsmOptionalDataRecordAlloc(); - if(pd) { + if(pd && od) { // For now we are going to make up some disks to return. Later we will // try to make a simulated array that makes sense. *count = 10; @@ -672,11 +673,12 @@ static int list_disks(lsmPluginPtr c, lsmDisk **disks[], uint32_t *count, (*disks)[i] = lsmDiskRecordAlloc(md5(name), name, LSM_DISK_TYPE_SOP, 512, 0x8000000000000, LSM_DISK_STATUS_OK, od, sys_id); } - lsmOptionalDataRecordFree(od); + } else { rc = LSM_ERR_INVALID_PLUGIN; } + lsmOptionalDataRecordFree(od); return rc; } @@ -1593,6 +1595,7 @@ static int vol_accessible_by_init(lsmPluginPtr c, lsmVolumeRecordFreeArray(*volumes, alloc_count); *count = 0; *volumes = NULL; + break; } else { alloc_count += 1; } @@ -2220,8 +2223,25 @@ int load( lsmPluginPtr c, xmlURIPtr uri, const char *password, if( !data->system[0] || !data->pool[0] || !data->pool[1] || !data->pool[2] || !data->pool[3] || !data->access_groups || - !data->group_grant || !data->fs) { - rc = LSM_ERR_NO_MEMORY; + !data->group_grant || !data->fs || !data->jobs ) { + rc = LSM_ERR_NO_MEMORY; /* We need to free data and everything else */ + + if( data->jobs ) + g_hash_table_destroy(data->jobs); + if( data->fs ) + g_hash_table_destroy(data->fs); + if( data->group_grant ) + g_hash_table_destroy(data->group_grant); + if( data->access_groups ) + g_hash_table_destroy(data->access_groups); + lsmPoolRecordFree(data->pool[3]); + lsmPoolRecordFree(data->pool[2]); + lsmPoolRecordFree(data->pool[1]); + lsmPoolRecordFree(data->pool[0]); + lsmSystemRecordFree(data->system[0]); + memset(data, 0xAA, sizeof(struct plugin_data)); + free(data); + data = NULL; } else { rc = lsmRegisterPluginV1( c, data, &mgmOps, &sanOps, &fsOps, &nfsOps); diff --git src/lsm_convert.cpp src/lsm_convert.cpp index 54100a5..242efe9 100644 --- src/lsm_convert.cpp +++ src/lsm_convert.cpp @@ -95,6 +95,9 @@ lsmDisk *valueToDisk(Value &disk) op, d["system_id"].asString().c_str() ); + + /* Optional data gets copied in lsmDiskRecordAlloc */ + lsmOptionalDataRecordFree(op); } return rc; } diff --git src/lsm_daemon.c src/lsm_daemon.c index 670fb17..04eed85 100644 --- src/lsm_daemon.c +++ src/lsm_daemon.c @@ -42,6 +42,7 @@ #include #include #include +#include #define BASE_DIR "/var/run/lsm" #define SOCKET_DIR BASE_DIR"/ipc" @@ -379,7 +380,7 @@ void empty_plugin_list(struct plugin_list *list) free(item->file_path); item->file_path = NULL; - item->fd = -1; + item->fd = INT_MAX; free(item); } } diff --git src/lsm_datatypes.cpp src/lsm_datatypes.cpp index d989c32..7e6415d 100644 --- src/lsm_datatypes.cpp +++ src/lsm_datatypes.cpp @@ -1560,7 +1560,12 @@ static uint8_t *stringToBytes(const char *hex_string, uint32_t *l) *l = len; for( i = 0; i < len; ++i ) { - sscanf(t, "%02hhx", &rc[i]); + if( 1 != sscanf(t, "%02hhx", &rc[i])) { + free(rc); + rc = NULL; + *l = 0; + break; + } t += 2; } } diff --git src/lsm_ipc.cpp src/lsm_ipc.cpp index 355abee..4a2d07d 100644 --- src/lsm_ipc.cpp +++ src/lsm_ipc.cpp @@ -121,9 +121,13 @@ std::string Transport::recvMsg(int &error_code) { std::string msg; error_code = 0; + unsigned long int payload_len = 0; std::string len = readString(s, HDR_LEN, error_code); //Read the length if (len.size() && error_code == 0) { - msg = readString(s, strtoul(len.c_str(), NULL, 10), error_code); + payload_len = strtoul(len.c_str(), NULL, 10); + if( payload_len < 0x80000000 ) { /* Should be big enough */ + msg = readString(s, payload_len, error_code); + } //fprintf(stderr, "<<< %s\n", msg.c_str()); } return msg; @@ -147,6 +151,7 @@ int Transport::getSocket(const std::string& path, int &error_code) if (rc != 0) { error_code = errno; rc = -1; //Redundant, connect should set to -1 on error + ::close(sfd); } else { rc = sfd; //We are good to go. } diff --git src/lsm_mgmt.cpp src/lsm_mgmt.cpp index f5c96a1..694e10a 100644 --- src/lsm_mgmt.cpp +++ src/lsm_mgmt.cpp @@ -37,6 +37,7 @@ return LSM_ERR_INVALID_CONN; \ } \ lsmErrorFree(c->error); \ + c->error = NULL; \ } while (0) /** @@ -118,7 +119,7 @@ static lsmErrorNumber logException(lsmConnect *c, lsmErrorNumber error, LSM_ERR_LEVEL_ERROR, message, exception_msg, NULL, NULL, 0); - if( err && c ) { + if( err ) { lsmErrorLog(c, err); } return error; @@ -135,7 +136,7 @@ static int rpc(lsmConnect *c, const char *method, const Value ¶meters, } catch ( const LsmException &le ) { return logException(c, (lsmErrorNumber)le.error_code, le.what(), NULL); - } catch ( EOFException &eof ) { + } catch ( const EOFException &eof ) { return logException(c, LSM_ERR_TRANSPORT_COMMUNICATION, "Plug-in died", "Check syslog"); } catch (...) { @@ -145,30 +146,40 @@ static int rpc(lsmConnect *c, const char *method, const Value ¶meters, return LSM_ERR_OK; } -static int jobCheck( int rc, Value &response, char **job ) +static int jobCheck( lsmConnect *c, int rc, Value &response, char **job ) { - if( LSM_ERR_OK == rc ) { - //We get a value back, either null or job id. - if( Value::string_t == response.valueType() ) { - *job = strdup(response.asString().c_str()); - - if( *job ) { - rc = LSM_ERR_JOB_STARTED; + try { + if( LSM_ERR_OK == rc ) { + //We get a value back, either null or job id. + if( Value::string_t == response.valueType() ) { + *job = strdup(response.asString().c_str()); + + if( *job ) { + rc = LSM_ERR_JOB_STARTED; + } else { + rc = LSM_ERR_NO_MEMORY; + } } else { - rc = LSM_ERR_NO_MEMORY; + *job = NULL; } - } else { - *job = NULL; } + } catch (const ValueException &ve) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Wrong type", + ve.what()); } return rc; } -static int getAccessGroups( int rc, Value &response, lsmAccessGroup **groups[], - uint32_t *count) +static int getAccessGroups( lsmConnect *c, int rc, Value &response, + lsmAccessGroup **groups[], uint32_t *count) { - if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { - *groups = valueToAccessGroupList(response, count); + try { + if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { + *groups = valueToAccessGroupList(response, count); + } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; } @@ -197,6 +208,7 @@ int lsmConnectClose(lsmConnect *c, lsmFlag_t flags) int LSM_DLL_EXPORT lsmPluginGetInfo(lsmConnect *c, char **desc, char **version, lsmFlag_t flags) { + int rc = LSM_ERR_OK; CONN_SETUP(c); if( LSM_FLAG_UNUSED_CHECK(flags) ) { @@ -207,23 +219,32 @@ int LSM_DLL_EXPORT lsmPluginGetInfo(lsmConnect *c, char **desc, return LSM_ERR_INVALID_ARGUMENT; } - std::map p; - p["flags"] = Value(flags); - Value parameters(p); - Value response; + try { + std::map p; + p["flags"] = Value(flags); + Value parameters(p); + Value response; - int rc = rpc(c, "plugin_info", parameters, response); + rc = rpc(c, "plugin_info", parameters, response); - if( rc == LSM_ERR_OK ) { - std::vector j = response.asArray(); - *desc = strdup(j[0].asC_str()); - *version = strdup(j[1].asC_str()); + if( rc == LSM_ERR_OK ) { + std::vector j = response.asArray(); + *desc = strdup(j[0].asC_str()); + *version = strdup(j[1].asC_str()); - if( !*desc || !*version ) { - rc = LSM_ERR_NO_MEMORY; - free(*desc); - free(*version); + if( !*desc || !*version ) { + rc = LSM_ERR_NO_MEMORY; + free(*desc); + free(*version); + } } + } catch (const ValueException &ve) { + free(*desc); + *desc = NULL; + free(*version); + *version = NULL; + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; @@ -242,16 +263,17 @@ int LSM_DLL_EXPORT lsmGetAvailablePlugins(const char *sep, char *version = NULL; char *s = NULL; const char *uds_dir = uds_path(); - lsmStringList *plugin_list = lsmStringListAlloc(0); - - if( !plugin_list ) { - return LSM_ERR_NO_MEMORY; - } + lsmStringList *plugin_list = NULL; if( CHECK_STR(sep) || CHECK_RP(plugins) || LSM_FLAG_UNUSED_CHECK(flags)) { return LSM_ERR_INVALID_ARGUMENT; } + plugin_list = lsmStringListAlloc(0); + if( !plugin_list ) { + return LSM_ERR_NO_MEMORY; + } + dirp = opendir(uds_dir); if( dirp ) { for(;;) { @@ -277,28 +299,32 @@ int LSM_DLL_EXPORT lsmGetAvailablePlugins(const char *sep, if( -1 == format ) { rc = LSM_ERR_NO_MEMORY; - goto bail; + break; } rc = lsmStringListAppend(plugin_list, s); free(s); s = NULL; if( LSM_ERR_OK != rc ) { - goto bail; + break; } } } else { - goto bail; + break; } freeConnection(c); c = NULL; } } + } /* for(;;) */ + + if( e ) { + lsmErrorFree(e); + e = NULL; } - bail: if( c ) { freeConnection(c); c = NULL; @@ -309,7 +335,8 @@ int LSM_DLL_EXPORT lsmGetAvailablePlugins(const char *sep, //log the error rc = LSM_ERR_INTERNAL_ERROR; } - } else { + + } else { /* If dirp == NULL */ //Log the error rc = LSM_ERR_INTERNAL_ERROR; } @@ -318,6 +345,7 @@ int LSM_DLL_EXPORT lsmGetAvailablePlugins(const char *sep, *plugins = plugin_list; } else { lsmStringListFree(plugin_list); + plugin_list = NULL; } return rc; @@ -343,20 +371,27 @@ int lsmConnectSetTimeout(lsmConnect *c, uint32_t timeout, lsmFlag_t flags) int lsmConnectGetTimeout(lsmConnect *c, uint32_t *timeout, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( LSM_FLAG_UNUSED_CHECK(flags) ) { return LSM_ERR_INVALID_ARGUMENT; } - std::map p; - p["flags"] = Value(flags); - Value parameters(p); - Value response; - - int rc = rpc(c, "get_time_out", parameters, response); - if( rc == LSM_ERR_OK ) { - *timeout = response.asUint32_t(); + try { + std::map p; + p["flags"] = Value(flags); + Value parameters(p); + Value response; + + rc = rpc(c, "get_time_out", parameters, response); + if( rc == LSM_ERR_OK ) { + *timeout = response.asUint32_t(); + } + } + catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; } @@ -365,26 +400,32 @@ static int jobStatus( lsmConnect *c, const char *job, lsmJobStatus *status, uint8_t *percentComplete, Value &returned_value, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( !job || !status || !percentComplete ) { return LSM_ERR_INVALID_ARGUMENT; } - std::map p; - p["job_id"] = Value(job); - p["flags"] = Value(flags); - Value parameters(p); - Value response; - - int rc = rpc(c, "job_status", parameters, response); - if( LSM_ERR_OK == rc ) { - //We get back an array [status, percent, volume] - std::vector j = response.asArray(); - *status = (lsmJobStatus)j[0].asInt32_t(); - *percentComplete = (uint8_t)j[1].asUint32_t(); - - returned_value = j[2]; + try { + std::map p; + p["job_id"] = Value(job); + p["flags"] = Value(flags); + Value parameters(p); + Value response; + + rc = rpc(c, "job_status", parameters, response); + if( LSM_ERR_OK == rc ) { + //We get back an array [status, percent, volume] + std::vector j = response.asArray(); + *status = (lsmJobStatus)j[0].asInt32_t(); + *percentComplete = (uint8_t)j[1].asUint32_t(); + + returned_value = j[2]; + } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; } @@ -408,6 +449,7 @@ int lsmJobStatusVolumeGet( lsmConnect *c, const char *job, lsmVolume **vol, lsmFlag_t flags) { Value rv; + int rc = 0; CONN_SETUP(c); @@ -415,14 +457,20 @@ int lsmJobStatusVolumeGet( lsmConnect *c, const char *job, return LSM_ERR_INVALID_ARGUMENT; } - int rc = jobStatus(c, job, status, percentComplete, rv, flags); + try { - if( LSM_ERR_OK == rc ) { - if( Value::object_t == rv.valueType() ) { - *vol = valueToVolume(rv); - } else { - *vol = NULL; + rc = jobStatus(c, job, status, percentComplete, rv, flags); + + if( LSM_ERR_OK == rc ) { + if( Value::object_t == rv.valueType() ) { + *vol = valueToVolume(rv); + } else { + *vol = NULL; + } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; } @@ -431,20 +479,27 @@ int lsmJobStatusFsGet(lsmConnect *c, const char *job, lsmJobStatus *status, uint8_t *percentComplete, lsmFs **fs, lsmFlag_t flags) { + int rc = 0; Value rv; if( CHECK_RP(fs) || LSM_FLAG_UNUSED_CHECK(flags) ) { return LSM_ERR_INVALID_ARGUMENT; } - int rc = jobStatus(c, job, status, percentComplete, rv, flags); + try { - if( LSM_ERR_OK == rc ) { - if( Value::object_t == rv.valueType() ) { - *fs = valueToFs(rv); - } else { - *fs = NULL; + rc = jobStatus(c, job, status, percentComplete, rv, flags); + + if( LSM_ERR_OK == rc ) { + if( Value::object_t == rv.valueType() ) { + *fs = valueToFs(rv); + } else { + *fs = NULL; + } } + } catch( const ValueException &ve) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; } @@ -453,20 +508,27 @@ int lsmJobStatusSsGet(lsmConnect *c, const char *job, lsmJobStatus *status, uint8_t *percentComplete, lsmSs **ss, lsmFlag_t flags) { + int rc = 0; Value rv; if( CHECK_RP(ss) || LSM_FLAG_UNUSED_CHECK(flags) ) { return LSM_ERR_INVALID_ARGUMENT; } - int rc = jobStatus(c, job, status, percentComplete, rv, flags); + try { - if( LSM_ERR_OK == rc ) { - if( Value::object_t == rv.valueType() ) { - *ss = valueToSs(rv); - } else { - *ss = NULL; + rc = jobStatus(c, job, status, percentComplete, rv, flags); + + if( LSM_ERR_OK == rc ) { + if( Value::object_t == rv.valueType() ) { + *ss = valueToSs(rv); + } else { + *ss = NULL; + } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; } @@ -498,6 +560,7 @@ int lsmJobFree(lsmConnect *c, char **job, lsmFlag_t flags) int lsmCapabilities(lsmConnect *c, lsmSystem *system, lsmStorageCapabilities **cap, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( !LSM_IS_SYSTEM(system) ) { @@ -516,10 +579,15 @@ int lsmCapabilities(lsmConnect *c, lsmSystem *system, Value parameters(p); Value response; - int rc = rpc(c, "capabilities", parameters, response); + try { + rc = rpc(c, "capabilities", parameters, response); - if( LSM_ERR_OK == rc && Value::object_t == response.valueType() ) { - *cap = valueToCapabilities(response); + if( LSM_ERR_OK == rc && Value::object_t == response.valueType() ) { + *cap = valueToCapabilities(response); + } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; @@ -528,56 +596,76 @@ int lsmCapabilities(lsmConnect *c, lsmSystem *system, int lsmPoolList(lsmConnect *c, lsmPool **poolArray[], uint32_t *count, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( !poolArray || !count || CHECK_RP(poolArray) || LSM_FLAG_UNUSED_CHECK(flags) ) { return LSM_ERR_INVALID_ARGUMENT; } - std::map p; - p["flags"] = Value(flags); - Value parameters(p); - Value response; + try { + std::map p; + p["flags"] = Value(flags); + Value parameters(p); + Value response; - int rc = rpc(c, "pools", parameters, response); - if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { - std::vector pools = response.asArray(); + rc = rpc(c, "pools", parameters, response); + if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { + std::vector pools = response.asArray(); - *count = pools.size(); + *count = pools.size(); - if( pools.size() ) { - *poolArray = lsmPoolRecordAllocArray(pools.size()); + if( pools.size() ) { + *poolArray = lsmPoolRecordAllocArray(pools.size()); - for( size_t i = 0; i < pools.size(); ++i ) { - (*poolArray)[i] = valueToPool(pools[i]); + for( size_t i = 0; i < pools.size(); ++i ) { + (*poolArray)[i] = valueToPool(pools[i]); + } } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); + if( *poolArray && *count ) { + lsmPoolRecordFreeArray(*poolArray, *count); + *poolArray = NULL; + *count = 0; + } } return rc; } -static int get_initiator_array(int rc, Value &response, +static int get_initiator_array(lsmConnect *c, int rc, Value &response, lsmInitiator **initiators[], uint32_t *count) { - if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { - std::vector inits = response.asArray(); - - *count = inits.size(); - - if( inits.size() ) { + try { + if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { + std::vector inits = response.asArray(); - *initiators = lsmInitiatorRecordAllocArray(inits.size()); + *count = inits.size(); - if( *initiators ) { + if( inits.size() ) { + *initiators = lsmInitiatorRecordAllocArray(inits.size()); - for( size_t i = 0; i < inits.size(); ++i ) { - (*initiators)[i] = valueToInitiator(inits[i]); + if( *initiators ) { + for( size_t i = 0; i < inits.size(); ++i ) { + (*initiators)[i] = valueToInitiator(inits[i]); + } + } else { + rc = LSM_ERR_NO_MEMORY; } - } else { - rc = LSM_ERR_NO_MEMORY; } } + } catch ( const ValueException &ve ) { + if( *initiators && *count ) { + lsmInitiatorRecordFreeArray(*initiators, *count); + *initiators = NULL; + *count = 0; + } + + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; } @@ -598,28 +686,39 @@ int lsmInitiatorList(lsmConnect *c, lsmInitiator **initiators[], Value response; int rc = rpc(c, "initiators", parameters, response); - return get_initiator_array(rc, response, initiators, count); + return get_initiator_array(c, rc, response, initiators, count); } -static int get_volume_array(int rc, Value response, +static int get_volume_array(lsmConnect *c, int rc, Value response, lsmVolume **volumes[], uint32_t *count) { - if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { - std::vector vol = response.asArray(); + try { + if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { + std::vector vol = response.asArray(); - *count = vol.size(); + *count = vol.size(); - if( vol.size() ) { - *volumes = lsmVolumeRecordAllocArray(vol.size()); + if( vol.size() ) { + *volumes = lsmVolumeRecordAllocArray(vol.size()); - if( *volumes ){ - for( size_t i = 0; i < vol.size(); ++i ) { - (*volumes)[i] = valueToVolume(vol[i]); + if( *volumes ){ + for( size_t i = 0; i < vol.size(); ++i ) { + (*volumes)[i] = valueToVolume(vol[i]); + } + } else { + rc = LSM_ERR_NO_MEMORY; } - } else { - rc = LSM_ERR_NO_MEMORY; } } + } catch( const ValueException &ve) { + if( *volumes && *count ) { + lsmVolumeRecordFreeArray(*volumes, *count); + *volumes = NULL; + *count = 0; + } + + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; } @@ -641,28 +740,38 @@ int lsmVolumeList(lsmConnect *c, lsmVolume **volumes[], uint32_t *count, Value response; int rc = rpc(c, "volumes", parameters, response); - return get_volume_array(rc, response, volumes, count); + return get_volume_array(c, rc, response, volumes, count); } -static int get_disk_array(int rc, Value &response, lsmDisk **disks[], - uint32_t *count) +static int get_disk_array(lsmConnect *c, int rc, Value &response, + lsmDisk **disks[], uint32_t *count) { - if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { - std::vector d = response.asArray(); + try { + if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { + std::vector d = response.asArray(); - *count = d.size(); + *count = d.size(); - if( d.size() ) { - *disks = lsmDiskRecordAllocArray(d.size()); + if( d.size() ) { + *disks = lsmDiskRecordAllocArray(d.size()); - if( *disks ){ - for( size_t i = 0; i < d.size(); ++i ) { - (*disks)[i] = valueToDisk(d[i]); + if( *disks ){ + for( size_t i = 0; i < d.size(); ++i ) { + (*disks)[i] = valueToDisk(d[i]); + } + } else { + rc = LSM_ERR_NO_MEMORY; } - } else { - rc = LSM_ERR_NO_MEMORY; } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); + if( *disks && *count ) { + lsmDiskRecordFreeArray(*disks, *count); + *disks = NULL; + *count = 0; + } } return rc; @@ -684,30 +793,39 @@ int lsmDiskList(lsmConnect *c, lsmDisk **disks[], Value response; int rc = rpc(c, "disks", parameters, response); - return get_disk_array(rc, response, disks, count); + return get_disk_array(c, rc, response, disks, count); } typedef void* (*convert)(Value &v); -static void* parse_job_response(Value response, int &rc, char **job, convert conv) +static void* parse_job_response(lsmConnect *c, Value response, int &rc, + char **job, convert conv) { void *val = NULL; - //We get an array back. first value is job, second is data of interest. - if( Value::array_t == response.valueType() ) { - std::vector r = response.asArray(); - if( Value::string_t == r[0].valueType()) { - *job = strdup((r[0].asString()).c_str()); - if( *job ) { + + try { + //We get an array back. first value is job, second is data of interest. + if( Value::array_t == response.valueType() ) { + std::vector r = response.asArray(); + if( Value::string_t == r[0].valueType()) { + *job = strdup((r[0].asString()).c_str()); + if( *job ) { + rc = LSM_ERR_JOB_STARTED; + } else { + rc = LSM_ERR_NO_MEMORY; + } + rc = LSM_ERR_JOB_STARTED; - } else { - rc = LSM_ERR_NO_MEMORY; } - - rc = LSM_ERR_JOB_STARTED; - } - if( Value::object_t == r[1].valueType() ) { - val = conv(r[1]); + if( Value::object_t == r[1].valueType() ) { + val = conv(r[1]); + } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); + free(*job); + *job = NULL; } return val; } @@ -739,7 +857,7 @@ int lsmVolumeCreate(lsmConnect *c, lsmPool *pool, const char *volumeName, int rc = rpc(c, "volume_create", parameters, response); if( LSM_ERR_OK == rc ) { - *newVolume = (lsmVolume *)parse_job_response(response, rc, job, + *newVolume = (lsmVolume *)parse_job_response(c, response, rc, job, (convert)valueToVolume); } return rc; @@ -775,7 +893,7 @@ int lsmVolumeResize(lsmConnect *c, lsmVolume *volume, int rc = rpc(c, "volume_resize", parameters, response); if( LSM_ERR_OK == rc ) { - *resizedVolume = (lsmVolume *)parse_job_response(response, rc, job, + *resizedVolume = (lsmVolume *)parse_job_response(c, response, rc, job, (convert)valueToVolume); } return rc; @@ -813,7 +931,7 @@ int lsmVolumeReplicate(lsmConnect *c, lsmPool *pool, int rc = rpc(c, "volume_replicate", parameters, response); if( LSM_ERR_OK == rc ) { - *newReplicant = (lsmVolume *)parse_job_response(response, rc, job, + *newReplicant = (lsmVolume *)parse_job_response(c, response, rc, job, (convert)valueToVolume); } return rc; @@ -823,6 +941,7 @@ int lsmVolumeReplicate(lsmConnect *c, lsmPool *pool, int lsmVolumeReplicateRangeBlockSize(lsmConnect *c, lsmSystem *system, uint32_t *bs, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( !bs || LSM_FLAG_UNUSED_CHECK(flags) ) { @@ -833,17 +952,22 @@ int lsmVolumeReplicateRangeBlockSize(lsmConnect *c, lsmSystem *system, return LSM_ERR_INVALID_SYSTEM; } - std::map p; - p["system"] = systemToValue(system); - p["flags"] = Value(flags); - Value parameters(p); - Value response; - - int rc = rpc(c, "volume_replicate_range_block_size", parameters, response); - if( LSM_ERR_OK == rc ) { - if( Value::numeric_t == response.valueType() ) { - *bs = response.asUint32_t(); + try { + std::map p; + p["system"] = systemToValue(system); + p["flags"] = Value(flags); + Value parameters(p); + Value response; + + rc = rpc(c, "volume_replicate_range_block_size", parameters, response); + if( LSM_ERR_OK == rc ) { + if( Value::numeric_t == response.valueType() ) { + *bs = response.asUint32_t(); + } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; } @@ -879,12 +1003,13 @@ int lsmVolumeReplicateRange(lsmConnect *c, Value response; int rc = rpc(c, "volume_replicate_range", parameters, response); - return jobCheck(rc, response, job); + return jobCheck(c, rc, response, job); } int lsmVolumeDelete(lsmConnect *c, lsmVolume *volume, char **job, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( !LSM_IS_VOL(volume) ) { @@ -895,25 +1020,30 @@ int lsmVolumeDelete(lsmConnect *c, lsmVolume *volume, char **job, return LSM_ERR_INVALID_ARGUMENT; } - std::map p; - p["volume"] = volumeToValue(volume); - p["flags"] = Value(flags); - - Value parameters(p); - Value response; - - int rc = rpc(c, "volume_delete", parameters, response); - if( LSM_ERR_OK == rc ) { - //We get a value back, either null or job id. - if( Value::string_t == response.valueType() ) { - *job = strdup(response.asString().c_str()); - - if( *job ) { - rc = LSM_ERR_JOB_STARTED; - } else { - rc = LSM_ERR_NO_MEMORY; + try { + std::map p; + p["volume"] = volumeToValue(volume); + p["flags"] = Value(flags); + + Value parameters(p); + Value response; + + rc = rpc(c, "volume_delete", parameters, response); + if( LSM_ERR_OK == rc ) { + //We get a value back, either null or job id. + if( Value::string_t == response.valueType() ) { + *job = strdup(response.asString().c_str()); + + if( *job ) { + rc = LSM_ERR_JOB_STARTED; + } else { + rc = LSM_ERR_NO_MEMORY; + } } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; @@ -1026,7 +1156,7 @@ int lsmVolumesAccessibleByInitiator(lsmConnect *c, Value response; int rc = rpc(c, "volumes_accessible_by_initiator", parameters, response); - return get_volume_array(rc, response, volumes, count); + return get_volume_array(c, rc, response, volumes, count); } int lsmInitiatorsGrantedToVolume(lsmConnect *c, lsmVolume *volume, @@ -1050,7 +1180,7 @@ int lsmInitiatorsGrantedToVolume(lsmConnect *c, lsmVolume *volume, Value response; int rc = rpc(c, "initiators_granted_to_volume", parameters, response); - return get_initiator_array(rc, response, initiators, count); + return get_initiator_array(c, rc, response, initiators, count); } @@ -1101,7 +1231,7 @@ int lsmAccessGroupList( lsmConnect *c, lsmAccessGroup **groups[], Value response; int rc = rpc(c, "access_group_list", parameters, response); - return getAccessGroups(rc, response, groups, groupCount); + return getAccessGroups(c, rc, response, groups, groupCount); } int lsmAccessGroupCreate(lsmConnect *c, const char *name, @@ -1279,6 +1409,7 @@ int lsmVolumesAccessibleByAccessGroup(lsmConnect *c, lsmVolume **volumes[], uint32_t *count, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( !LSM_IS_ACCESS_GROUP(group)) { @@ -1289,26 +1420,36 @@ int lsmVolumesAccessibleByAccessGroup(lsmConnect *c, return LSM_ERR_INVALID_ARGUMENT; } - std::map p; - p["group"] = accessGroupToValue(group); - p["flags"] = Value(flags); + try { + std::map p; + p["group"] = accessGroupToValue(group); + p["flags"] = Value(flags); - Value parameters(p); - Value response; + Value parameters(p); + Value response; - int rc = rpc(c, "volumes_accessible_by_access_group", parameters, response); - if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { - std::vector vol = response.asArray(); + rc = rpc(c, "volumes_accessible_by_access_group", parameters, response); + if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { + std::vector vol = response.asArray(); - *count = vol.size(); + *count = vol.size(); - if( vol.size() ) { - *volumes = lsmVolumeRecordAllocArray(vol.size()); + if( vol.size() ) { + *volumes = lsmVolumeRecordAllocArray(vol.size()); - for( size_t i = 0; i < vol.size(); ++i ) { - (*volumes)[i] = valueToVolume(vol[i]); + for( size_t i = 0; i < vol.size(); ++i ) { + (*volumes)[i] = valueToVolume(vol[i]); + } } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); + if( *volumes && *count ) { + lsmVolumeRecordFreeArray(*volumes, *count); + *volumes = NULL; + *count = 0; + } } return rc; } @@ -1336,12 +1477,13 @@ int lsmAccessGroupsGrantedToVolume(lsmConnect *c, Value response; int rc = rpc(c, "access_groups_granted_to_volume", parameters, response); - return getAccessGroups(rc, response, groups, groupCount); + return getAccessGroups(c, rc, response, groups, groupCount); } int lsmVolumeChildDependency(lsmConnect *c, lsmVolume *volume, uint8_t *yes, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( !LSM_IS_VOL(volume)) { @@ -1352,25 +1494,30 @@ int lsmVolumeChildDependency(lsmConnect *c, lsmVolume *volume, return LSM_ERR_INVALID_ARGUMENT; } - std::map p; - p["volume"] = volumeToValue(volume); - p["flags"] = Value(flags); + try { + std::map p; + p["volume"] = volumeToValue(volume); + p["flags"] = Value(flags); - Value parameters(p); - Value response; + Value parameters(p); + Value response; - *yes = 0; + *yes = 0; - int rc = rpc(c, "volume_child_dependency", parameters, response); - if( LSM_ERR_OK == rc ) { - //We should be getting a boolean value back. - if( Value::boolean_t == response.valueType() ) { - if( response.asBool() ) { - *yes = 1; + rc = rpc(c, "volume_child_dependency", parameters, response); + if( LSM_ERR_OK == rc ) { + //We should be getting a boolean value back. + if( Value::boolean_t == response.valueType() ) { + if( response.asBool() ) { + *yes = 1; + } + } else { + rc = LSM_ERR_INTERNAL_ERROR; } - } else { - rc = LSM_ERR_INTERNAL_ERROR; } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; } @@ -1396,45 +1543,56 @@ int lsmVolumeChildDependencyRm(lsmConnect *c, lsmVolume *volume, Value response; int rc = rpc(c, "volume_child_dependency_rm", parameters, response); - return jobCheck(rc, response, job); + return jobCheck(c, rc, response, job); } int lsmSystemList(lsmConnect *c, lsmSystem **systems[], uint32_t *systemCount, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( !systems || ! systemCount || LSM_FLAG_UNUSED_CHECK(flags) ) { return LSM_ERR_INVALID_ARGUMENT; } - std::map p; - p["flags"] = Value(flags); - Value parameters(p); - Value response; - - int rc = rpc(c, "systems", parameters, response); - if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { - std::vector sys = response.asArray(); - - *systemCount = sys.size(); - - if( sys.size() ) { - *systems = lsmSystemRecordAllocArray(sys.size()); - - if( *systems ) { - for( size_t i = 0; i < sys.size(); ++i ) { - (*systems)[i] = valueToSystem(sys[i]); - if( !(*systems)[i] ) { - lsmSystemRecordFreeArray(*systems, i); - rc = LSM_ERR_NO_MEMORY; - break; + try { + std::map p; + p["flags"] = Value(flags); + Value parameters(p); + Value response; + + rc = rpc(c, "systems", parameters, response); + if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { + std::vector sys = response.asArray(); + + *systemCount = sys.size(); + + if( sys.size() ) { + *systems = lsmSystemRecordAllocArray(sys.size()); + + if( *systems ) { + for( size_t i = 0; i < sys.size(); ++i ) { + (*systems)[i] = valueToSystem(sys[i]); + if( !(*systems)[i] ) { + lsmSystemRecordFreeArray(*systems, i); + rc = LSM_ERR_NO_MEMORY; + break; + } } + } else { + rc = LSM_ERR_NO_MEMORY; } - } else { - rc = LSM_ERR_NO_MEMORY; } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); + if( *systems ) { + lsmSystemRecordFreeArray( *systems, *systemCount); + *systems = NULL; + *systemCount = 0; + } } return rc; } @@ -1442,30 +1600,45 @@ int lsmSystemList(lsmConnect *c, lsmSystem **systems[], int lsmFsList(lsmConnect *c, lsmFs **fs[], uint32_t *fsCount, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( !fs || !fsCount || LSM_FLAG_UNUSED_CHECK(flags) ) { return LSM_ERR_INVALID_ARGUMENT; } - std::map p; - p["flags"] = Value(flags); - Value parameters(p); - Value response; + try { + std::map p; + p["flags"] = Value(flags); + Value parameters(p); + Value response; - int rc = rpc(c, "fs", parameters, response); - if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { - std::vector sys = response.asArray(); + rc = rpc(c, "fs", parameters, response); + if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { + std::vector sys = response.asArray(); - *fsCount = sys.size(); + *fsCount = sys.size(); - if( sys.size() ) { - *fs = lsmFsRecordAllocArray(sys.size()); + if( sys.size() ) { + *fs = lsmFsRecordAllocArray(sys.size()); - for( size_t i = 0; i < sys.size(); ++i ) { - (*fs)[i] = valueToFs(sys[i]); + if( *fs ) { + for( size_t i = 0; i < sys.size(); ++i ) { + (*fs)[i] = valueToFs(sys[i]); + } + } else { + rc = LSM_ERR_NO_MEMORY; + } } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); + if( *fs && *fsCount) { + lsmFsRecordFreeArray(*fs, *fsCount); + *fs = NULL; + *fsCount = 0; + } } return rc; @@ -1497,7 +1670,7 @@ int lsmFsCreate(lsmConnect *c, lsmPool *pool, const char *name, int rc = rpc(c, "fs_create", parameters, response); if( LSM_ERR_OK == rc ) { - *fs = (lsmFs *)parse_job_response(response, rc, job, + *fs = (lsmFs *)parse_job_response(c, response, rc, job, (convert)valueToFs); } return rc; @@ -1523,7 +1696,7 @@ int lsmFsDelete(lsmConnect *c, lsmFs *fs, char **job, lsmFlag_t flags) Value response; int rc = rpc(c, "fs_delete", parameters, response); - return jobCheck(rc, response, job); + return jobCheck(c, rc, response, job); } @@ -1551,7 +1724,7 @@ int lsmFsResize(lsmConnect *c, lsmFs *fs, int rc = rpc(c, "fs_resize", parameters, response); if( LSM_ERR_OK == rc ) { - *rfs = (lsmFs *)parse_job_response(response, rc, job, + *rfs = (lsmFs *)parse_job_response(c, response, rc, job, (convert)valueToFs); } return rc; @@ -1583,7 +1756,7 @@ int lsmFsClone(lsmConnect *c, lsmFs *src_fs, int rc = rpc(c, "fs_clone", parameters, response); if( LSM_ERR_OK == rc ) { - *cloned_fs = (lsmFs *)parse_job_response(response, rc, job, + *cloned_fs = (lsmFs *)parse_job_response(c, response, rc, job, (convert)valueToFs); } return rc; @@ -1615,12 +1788,13 @@ int lsmFsFileClone(lsmConnect *c, lsmFs *fs, const char *src_file_name, Value response; int rc = rpc(c, "file_clone", parameters, response); - return jobCheck(rc, response, job); + return jobCheck(c, rc, response, job); } int lsmFsChildDependency( lsmConnect *c, lsmFs *fs, lsmStringList *files, uint8_t *yes, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( !LSM_IS_FS(fs) ) { @@ -1637,26 +1811,31 @@ int lsmFsChildDependency( lsmConnect *c, lsmFs *fs, lsmStringList *files, return LSM_ERR_INVALID_ARGUMENT; } - std::map p; - p["fs"] = fsToValue(fs); - p["files"] = stringListToValue(files); - p["flags"] = Value(flags); - - Value parameters(p); - Value response; - - *yes = 0; - - int rc = rpc(c, "fs_child_dependency", parameters, response); - if( LSM_ERR_OK == rc ) { - //We should be getting a boolean value back. - if( Value::boolean_t == response.valueType() ) { - if( response.asBool() ) { - *yes = 1; + try { + std::map p; + p["fs"] = fsToValue(fs); + p["files"] = stringListToValue(files); + p["flags"] = Value(flags); + + Value parameters(p); + Value response; + + *yes = 0; + + rc = rpc(c, "fs_child_dependency", parameters, response); + if( LSM_ERR_OK == rc ) { + //We should be getting a boolean value back. + if( Value::boolean_t == response.valueType() ) { + if( response.asBool() ) { + *yes = 1; + } + } else { + rc = LSM_ERR_INTERNAL_ERROR; } - } else { - rc = LSM_ERR_INTERNAL_ERROR; } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); } return rc; } @@ -1689,12 +1868,13 @@ int lsmFsChildDependencyRm( lsmConnect *c, lsmFs *fs, lsmStringList *files, Value response; int rc = rpc(c, "fs_child_dependency_rm", parameters, response); - return jobCheck(rc, response, job); + return jobCheck(c, rc, response, job); } int lsmFsSsList(lsmConnect *c, lsmFs *fs, lsmSs **ss[], uint32_t *ssCount, lsmFlag_t flags ) { + int rc = 0; CONN_SETUP(c); if( !LSM_IS_FS(fs) ) { @@ -1712,19 +1892,33 @@ int lsmFsSsList(lsmConnect *c, lsmFs *fs, lsmSs **ss[], Value parameters(p); Value response; - int rc = rpc(c, "fs_snapshots", parameters, response); - if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { - std::vector sys = response.asArray(); + try { + rc = rpc(c, "fs_snapshots", parameters, response); + if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { + std::vector sys = response.asArray(); - *ssCount = sys.size(); + *ssCount = sys.size(); - if( sys.size() ) { - *ss = lsmSsRecordAllocArray(sys.size()); + if( sys.size() ) { + *ss = lsmSsRecordAllocArray(sys.size()); - for( size_t i = 0; i < sys.size(); ++i ) { - (*ss)[i] = valueToSs(sys[i]); + if( *ss ) { + for( size_t i = 0; i < sys.size(); ++i ) { + (*ss)[i] = valueToSs(sys[i]); + } + } else { + rc = LSM_ERR_NO_MEMORY; + } } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); + if( *ss && *ssCount ) { + lsmSsRecordFreeArray(*ss, *ssCount); + *ss = NULL; + *ssCount = 0; + } } return rc; @@ -1761,7 +1955,7 @@ int lsmFsSsCreate(lsmConnect *c, lsmFs *fs, const char *name, int rc = rpc(c, "fs_snapshot_create", parameters, response); if( LSM_ERR_OK == rc ) { - *snapshot = (lsmSs *)parse_job_response(response, rc, job, + *snapshot = (lsmSs *)parse_job_response(c, response, rc, job, (convert)valueToSs); } return rc; @@ -1793,7 +1987,7 @@ int lsmFsSsDelete(lsmConnect *c, lsmFs *fs, lsmSs *ss, char **job, Value response; int rc = rpc(c, "fs_snapshot_delete", parameters, response); - return jobCheck(rc, response, job); + return jobCheck(c, rc, response, job); } int lsmFsSsRevert(lsmConnect *c, lsmFs *fs, lsmSs *ss, @@ -1839,37 +2033,52 @@ int lsmFsSsRevert(lsmConnect *c, lsmFs *fs, lsmSs *ss, Value response; int rc = rpc(c, "fs_snapshot_revert", parameters, response); - return jobCheck(rc, response, job); + return jobCheck(c, rc, response, job); } int lsmNfsList( lsmConnect *c, lsmNfsExport **exports[], uint32_t *count, lsmFlag_t flags) { + int rc = 0; CONN_SETUP(c); if( CHECK_RP(exports) || !count || LSM_FLAG_UNUSED_CHECK(flags) ) { return LSM_ERR_INVALID_ARGUMENT; } - std::map p; - p["flags"] = Value(flags); - Value parameters(p); - Value response; + try { + std::map p; + p["flags"] = Value(flags); + Value parameters(p); + Value response; - int rc = rpc(c, "exports", parameters, response); - if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { - std::vector exps = response.asArray(); + rc = rpc(c, "exports", parameters, response); + if( LSM_ERR_OK == rc && Value::array_t == response.valueType()) { + std::vector exps = response.asArray(); - *count = exps.size(); + *count = exps.size(); - if( *count ) { - *exports = lsmNfsExportRecordAllocArray(*count); + if( *count ) { + *exports = lsmNfsExportRecordAllocArray(*count); - for( size_t i = 0; i < *count; ++i ) { - (*exports)[i] = valueToNfsExport(exps[i]); + if( *exports ) { + for( size_t i = 0; i < *count; ++i ) { + (*exports)[i] = valueToNfsExport(exps[i]); + } + } else { + rc = LSM_ERR_NO_MEMORY; + } } } + } catch( const ValueException &ve ) { + rc = logException(c, LSM_ERR_INTERNAL_ERROR, "Unexpected type", + ve.what()); + if( *exports && *count ) { + lsmNfsExportRecordFreeArray( *exports, *count ); + *exports = NULL; + *count = 0; + } } return rc; } diff --git src/lsm_plugin_ipc.cpp src/lsm_plugin_ipc.cpp index c23806c..c68a742 100644 --- src/lsm_plugin_ipc.cpp +++ src/lsm_plugin_ipc.cpp @@ -257,20 +257,20 @@ static int handle_startup(lsmPluginPtr p, Value ¶ms, Value &response) { int rc = LSM_ERR_NO_SUPPORT; xmlURIPtr uri = NULL; + std::string uri_string = params["uri"].asString(); + std::string password; if( p ) { - uri = xmlParseURI(params["uri"].asString().c_str()); + uri = xmlParseURI(uri_string.c_str()); if( uri ) { - const char *pass = NULL; - lsmFlag_t flags = LSM_FLAG_GET_VALUE(params); if( Value::string_t == params["password"].valueType() ) { - pass = params["password"].asString().c_str(); + password = params["password"].asString(); } //Let the plug-in initialize itself. - rc = p->reg(p, uri, pass, params["timeout"].asUint32_t(), + rc = p->reg(p, uri, password.c_str(), params["timeout"].asUint32_t(), flags); xmlFreeURI(uri); uri = NULL; @@ -314,7 +314,7 @@ static int handle_get_time_out( lsmPluginPtr p, Value ¶ms, Value &response) static int handle_job_status( lsmPluginPtr p, Value ¶ms, Value &response) { - const char *job_id = NULL; + std::string job_id; lsmJobStatus status; uint8_t percent; lsmDataType t = LSM_DATA_TYPE_UNKNOWN; @@ -328,9 +328,9 @@ static int handle_job_status( lsmPluginPtr p, Value ¶ms, Value &response) rc = LSM_ERR_TRANSPORT_INVALID_ARG; } else { - job_id = params["job_id"].asString().c_str(); + job_id = params["job_id"].asString(); - rc = p->mgmtOps->job_status(p, job_id, &status, &percent, &t, + rc = p->mgmtOps->job_status(p, job_id.c_str(), &status, &percent, &t, &value, LSM_FLAG_GET_VALUE(params)); if( LSM_ERR_OK == rc) {