Commit c6bf7e04 authored by 's avatar
Browse files

fix in mapi_stats


git-svn-id: file:///home/svn/mapi/trunk@1308 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 57a2babc
......@@ -4400,9 +4400,6 @@ int mapi_apply_function_array(int fd, const char* funct, char** args, unsigned i
int mapi_stats(const char *dev, struct mapi_stat *stats)
{
struct mapiipcbuf qbuf;
struct devgroupdb *devgroupdb;
int devgroupid = 0;
char *mapidsocket, *mapidsocketglobal;
#ifdef DIMAPI
char *hostname=NULL, *s=NULL, *k=NULL;
......@@ -4419,45 +4416,8 @@ int mapi_stats(const char *dev, struct mapi_stat *stats)
return -1;
}
#ifndef DIMAPI
devgroupdb = devgroupdb_open(3); // try local, global
devgroupid = devgroupdb_getgroupidbydevice(devgroupdb, (char *) dev);
if(!devgroupid) {
mapidsocket = printf_string(MAPIDSOCKHOME, getenv("HOME"));
mapidsocketglobal = strdup(MAPIDSOCKGLOBAL);
}
else {
mapidsocket = printf_string(MAPIDGSOCKHOME, getenv("HOME"), devgroupid);
mapidsocketglobal = printf_string(MAPIDGSOCKGLOBAL, devgroupid);
}
mapiipc_set_socket_names(mapidsocket, mapidsocketglobal);
pthread_once(&mapi_is_initialized, (void*)mapi_init);
#endif
//check if flow is remote or not and call the appropriate init function
#ifdef DIMAPI
if ( strchr(dev,':')==NULL) {
devgroupdb = devgroupdb_open(3); // try local, global
devgroupid = devgroupdb_getgroupidbydevice(devgroupdb, (char *) dev);
if(!devgroupid) {
mapidsocket = printf_string(MAPIDSOCKHOME, getenv("HOME"));
mapidsocketglobal = strdup(MAPIDSOCKGLOBAL);
}
else {
mapidsocket = printf_string(MAPIDGSOCKHOME, getenv("HOME"), devgroupid);
mapidsocketglobal = printf_string(MAPIDGSOCKGLOBAL, devgroupid);
}
mapiipc_set_socket_names(mapidsocket, mapidsocketglobal);
pthread_once(&mapi_is_initialized, (void*)mapi_init);
}
else pthread_once(&dmapi_is_initialized, (void*)dmapi_init);
if ((s = strchr(dev,':'))!=NULL) {
devp=strdup(dev);
k=strtok(devp, ", ");
......@@ -4536,16 +4496,6 @@ int mapi_stats(const char *dev, struct mapi_stat *stats)
}
#endif
pthread_spin_lock(&mapi_lock);
if ((get_numflows() == 0) && !minit) { //create the socket
if(mapiipc_client_init()==-1){
local_err = MCOM_INIT_SOCKET_ERROR;
}
}
pthread_spin_unlock(&mapi_lock);
strncpy((char *)qbuf.data,dev,DATA_SIZE);
qbuf.mtype=1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment