我正在使用Aerospike的C客户端库。给定的代码给我带来很多麻烦:
xpath
}
我在这里很机智。我一直在尝试在客户端代码中查找问题,但仍然没有成功。我得到奇怪的发现。上面的API第一次调用时运行良好,但是当我第二次调用时,会出现细分错误。以下是Valgrind输出的摘要:
RtCliErrors RtZonalDao::rtDispZonalCodes(char * p_ZnCodeListName, vector <struct RtDispRgZnCode> & dispRgZnCodeVec)
{
printf("\n[%s::%d] === Inside rtDispZonalCodes() === \n",__FILE__,__LINE__);
as_error l_asError;
as_key l_key ;
as_record l_rec;
try{
if(aerospike_cluster_is_connected(&RtDbConnection::ms_aerospikeIns) == true)
{
printf("\n[%s::%d] === aerospike connection OK ===",__FILE__,__LINE__);
}
else{
printf("\n[%s::%d] aerospike is not connected",__FILE__,__LINE__);
return RT_FAILURE;
}
if(p_ZnCodeListName==NULL)
{
printf("\n[%s::%d] Error: Null value of ZnCodeListName \n",__FILE__,__LINE__);
return RT_FAILURE;
}
if(p_ZnCodeListName!=NULL&&p_ZnCodeListName[0]==0)
{
printf("\n[%s::%d] Error: Null value of ZnCodeListName \n",__FILE__,__LINE__);
return RT_FAILURE;
}
as_key_init_str(&l_key, "bar", "rg_zn_cd_list_id_name", p_ZnCodeListName);
printf("\n[%s::%d] Key initialised successfully\n",__FILE__,__LINE__);
as_record* p_rec=&l_rec;
if (aerospike_key_exists(&RtDbConnection::ms_aerospikeIns, &l_asError, NULL, &l_key, &p_rec) == AEROSPIKE_ERR_RECORD_NOT_FOUND)
{
as_record_destroy(&l_rec);
as_key_destroy(&l_key);
printf("\n[ %s::%d ]--> Exception: , RG_ZN_CD_LIST not present in Db\n",__FILE__,__LINE__);
return RT_RG_ZN_CD_LST_NOT;
}
else
printf("\n[%s::%d] Primary Key found\n",__FILE__,__LINE__);
if (aerospike_key_get(&RtDbConnection::ms_aerospikeIns, &l_asError, NULL, &l_key, &p_rec) != AEROSPIKE_OK)
{
as_record_destroy(&l_rec);
as_key_destroy(&l_key);
printf("\n[%s::%d] Exception! Error Code: %d, Error Msg: %s\n",__FILE__,__LINE__, l_asError.code, l_asError.message);
return RT_FAILURE;
}
printf("\n[%s::%d] Fetch success\n",__FILE__,__LINE__);
as_record_destroy(&l_rec);
as_key_destroy(&l_key);
return RT_SUCCESS;
}//end of try
catch(...)
{
printf("\n[%s::%d] Default Exeption Caught \n",__FILE__,__LINE__);
as_record_destroy(&l_rec);
as_key_destroy(&l_key);
return RT_FAILURE;
}