Ignore:
Timestamp:
Aug 29, 2017, 10:52:39 AM (7 years ago)
Author:
djay
Message:

Fix various memory leaks and enhance the callback support. Add the prohibited keyword to the callback section to avoid calling callback for such services.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/zoo-project/zoo-kernel/zoo_service_loader.c

    r839 r850  
    304304      {
    305305        char* extn = strstr(dp->d_name, ".zcfg");
    306         if(dp->d_name[0] != '.' && extn != NULL && strlen(extn) == 5)
     306        if(dp->d_name[0] != '.' && extn != NULL && strlen(extn) == 5 && strlen(dp->d_name)>6)
    307307          {
    308308            int t;
     
    311311            snprintf (tmps1, 1024, "%s/%s", conf_dir, dp->d_name);
    312312
    313             char *tmpsn = zStrdup (dp->d_name);
    314             tmpsn[strlen (tmpsn) - 5] = 0;
     313            char *tmpsn = (char*)malloc((strlen(dp->d_name)-4)*sizeof(char));//zStrdup (dp->d_name);
     314            memset (tmpsn, 0, strlen(dp->d_name)-4);
     315            snprintf(tmpsn,strlen(dp->d_name)-4,"%s",dp->d_name);
    315316           
    316317            map* import = getMapFromMaps (m, IMPORTSERVICE, tmpsn);
     
    11811182  };
    11821183  r_inputs = getMap (request_inputs, "Request");
    1183   REQUEST = zStrdup (r_inputs->value);
     1184  fprintf(stderr," ** DEBUG %s %d \n",__FILE__,__LINE__);
     1185  fflush(stderr);
     1186  dumpMap(r_inputs);
     1187  fprintf(stderr," ** DEBUG %s %d \n",__FILE__,__LINE__);
     1188  fflush(stderr);
     1189  if(r_inputs!=NULL)
     1190    REQUEST = zStrdup (r_inputs->value);
     1191  fprintf(stderr," ** DEBUG %s %d \n",__FILE__,__LINE__);
     1192  fflush(stderr);
    11841193  int reqId=-1;
    11851194  if (strncasecmp (REQUEST, "GetCapabilities", 15) != 0){
     
    11881197    for(j=0;j<nbSupportedRequests;j++){
    11891198      if(requests[vid][j]!=NULL && requests[vid][j+1]!=NULL){
    1190         if(j<nbReqIdentifier && strncasecmp(REQUEST,requests[vid][j+1],strlen(REQUEST))==0){
     1199        if(j<nbReqIdentifier && strncasecmp(REQUEST,requests[vid][j+1],strlen(requests[vid][j+1]))==0){
    11911200          checkValidValue(request_inputs,&err,"identifier",NULL,1);
    11921201          reqId=j+1;
     
    11951204        else
    11961205          if(j>=nbReqIdentifier && j<nbReqIdentifier+nbReqJob &&
    1197              strncasecmp(REQUEST,requests[vid][j+1],strlen(REQUEST))==0){
     1206             strncasecmp(REQUEST,requests[vid][j+1],strlen(requests[vid][j+1]))==0){
    11981207            checkValidValue(request_inputs,&err,"jobid",NULL,1);
    11991208            reqId=j+1;
     
    13581367      r_inputs = getMap (request_inputs, "JobId");
    13591368      if(reqId>nbReqIdentifier){
    1360         if (strncasecmp (REQUEST, "GetStatus", strlen(REQUEST)) == 0 ||
    1361             strncasecmp (REQUEST, "GetResult", strlen(REQUEST)) == 0){
     1369        if (strncasecmp (REQUEST, "GetStatus", 9) == 0 ||
     1370            strncasecmp (REQUEST, "GetResult", 9) == 0){
    13621371          runGetStatus(m,r_inputs->value,REQUEST);
     1372#ifdef RELY_ON_DB
     1373          map* dsNb=getMapFromMaps(m,"lenv","ds_nb");
     1374          if(dsNb!=NULL && atoi(dsNb->value)>1)
     1375            close_sql(m,1);
     1376          close_sql(m,0);
     1377#endif
     1378         
    13631379          freeMaps (&m);
    13641380          free(m);
     
    21602176    addToMap (_tmpMaps->content, "soap", "false");
    21612177
    2162   // Parse the session file and add it to the main maps
     2178  // Parse the session file and add it to the main maps
     2179  char* originalCookie=NULL;
    21632180  if (cgiCookie != NULL && strlen (cgiCookie) > 0)
    21642181    {
     
    22522269  _tmpMaps = createMaps("renv");
    22532270  for (; s; ei++) {
     2271    int len=strlen(s);
    22542272    char* tmpName=zStrdup(s);
    22552273    char* tmpValue=strstr(s,"=")+1;
    2256     char* tmpName1=(char*)malloc((1+(strlen(tmpName)-strlen(tmpValue)))*sizeof(char));
    2257     snprintf(tmpName1,(strlen(tmpName)-strlen(tmpValue)),"%s",tmpName);
     2274    char* tmpName1=(char*)malloc((1+(len-strlen(tmpValue)))*sizeof(char));
     2275    snprintf(tmpName1,(len-strlen(tmpValue))+1,"%s",tmpName);
    22582276    if(_tmpMaps->content == NULL)
    22592277      _tmpMaps->content = createMap (tmpName1,tmpValue);
     
    22632281    free(tmpName1);
    22642282    s = *(orig+ei);
     2283  }
     2284  if(_tmpMaps->content!=NULL && getMap(_tmpMaps->content,"HTTP_COOKIE")!=NULL){
     2285    /*map* tmpMap1=getMap(_tmpMaps->content,"HTTP_COOKIE");
     2286    free(tmpMap1->value);
     2287    tmpMap1->value=zStrdup(cgiCookie);*/
     2288    fprintf(stderr,"[%s]\n",cgiCookie);
     2289    addToMap(_tmpMaps->content,"HTTP_COOKIE1",&cgiCookie[0]);
     2290    dumpMap(_tmpMaps->content);
    22652291  }
    22662292  addMapsToMaps (&m, _tmpMaps);
     
    22922318  }
    22932319#endif
    2294   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    2295   invokeCallback(m,NULL,NULL,0,0);
    2296   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    22972320
    22982321  char *fbkp, *fbkpid, *fbkpres, *fbkp1, *flog;
     
    24462469          recordServiceStatus(m);
    24472470#endif
     2471          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     2472          invokeCallback(m,NULL,NULL,0,0);
     2473          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    24482474          if(vid==0){
    24492475            /**
     
    25132539            return -1;
    25142540          }
     2541          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     2542          invokeCallback(m,request_input_real_format,NULL,1,1);
     2543          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    25152544          setMapInMaps(m,"lenv","ds_nb","1");
    25162545          loadServiceAndRun (&m, s1, request_inputs,
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png