Ignore:
Timestamp:
Jun 11, 2015, 3:07:11 PM (9 years ago)
Author:
djay
Message:

Better concurrency gesture for asynchronous requests, add db backend support for status informations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/response_print.c

    r651 r652  
    15151515      int lpid;
    15161516      map* tmpm2=getMapFromMaps(m,"lenv","usid");
    1517       lpid=atoi(tmpm2->value);
    1518       tmpm2=getMap(tmp_maps->content,"tmpUrl");
    1519       if(tmpm1!=NULL && tmpm2!=NULL){
    1520         if( strncasecmp( tmpm2->value, "http://", 7) == 0 ||
    1521             strncasecmp( tmpm2->value, "https://", 8 ) == 0 ){
    1522           sprintf(url,"%s/%s_%i.xml",tmpm2->value,service,lpid);
     1517      map* tmpm3=getMap(tmp_maps->content,"tmpUrl");
     1518      if(tmpm1!=NULL && tmpm3!=NULL){
     1519        if( strncasecmp( tmpm3->value, "http://", 7) == 0 ||
     1520            strncasecmp( tmpm3->value, "https://", 8 ) == 0 ){
     1521          sprintf(url,"%s/%s_%s.xml",tmpm3->value,service,tmpm2->value);
    15231522        }else
    1524           sprintf(url,"%s/%s/%s_%i.xml",tmpm1->value,tmpm2->value,service,lpid);
     1523          sprintf(url,"%s/%s_%s.xml",tmpm1->value,service,tmpm2->value);
    15251524      }
    15261525    }
     
    15291528    }
    15301529    int lpid;
    1531     tmpm1=getMapFromMaps(m,"lenv","usid");
    1532     lpid=atoi(tmpm1->value);
     1530    map* tmpm2=getMapFromMaps(m,"lenv","usid");
    15331531    tmpm1=getMapFromMaps(m,"main","TmpPath");
    1534     sprintf(stored_path,"%s/%s_%i.xml",tmpm1->value,service,lpid);
     1532    sprintf(stored_path,"%s/%s_%s.xml",tmpm1->value,service,tmpm2->value);
    15351533  }
    15361534
     
    16831681  }
    16841682
    1685   if(hasStoredExecuteResponse==true && status!=SERVICE_STARTED){
    1686     semid lid=getShmLockId(m,1);
     1683  if(hasStoredExecuteResponse==true && status!=SERVICE_STARTED && status!=SERVICE_ACCEPTED){
     1684#ifndef RELY_ON_DB
     1685    semid lid=acquireLock(m);//,1);
    16871686    if(lid<0){
    16881687      /* If the lock failed */
     
    16941693    }
    16951694    else{
    1696 #ifdef DEBUG
    1697       fprintf(stderr,"LOCK %s %d !\n",__FILE__,__LINE__);
    16981695#endif
    1699       lockShm(lid);
    17001696      /* We need to write the ExecuteResponse Document somewhere */
    17011697      FILE* output=fopen(stored_path,"w");
     
    17091705        xmlCleanupParser();
    17101706        zooXmlCleanupNs();
     1707#ifndef RELY_ON_DB
    17111708        unlockShm(lid);
     1709#endif
    17121710        return;
    17131711      }
     
    17181716      xmlFree(xmlbuff);
    17191717      fclose(output);
     1718#ifndef RELY_ON_DB
    17201719#ifdef DEBUG
    17211720      fprintf(stderr,"UNLOCK %s %d !\n",__FILE__,__LINE__);
    17221721#endif
    17231722      unlockShm(lid);
    1724       map* test1=getMap(request,"status");
    1725       if(test1==NULL || strcasecmp(test1->value,"true")!=0){
    1726         removeShmLock(m,1);
    1727       }
    1728     }
     1723      map* v=getMapFromMaps(m,"lenv","sid");
     1724      // Remove the lock when running as a normal task
     1725      if(getpid()==atoi(v->value)){
     1726        removeShmLock (m, 1);
     1727      }
     1728    }
     1729#endif
    17291730  }
    17301731  printDocument(m,doc,pid);
     
    23162317#endif
    23172318    maps* tmpI=request_outputs;
    2318 
     2319    map* usid=getMapFromMaps(m,"lenv","usid");
     2320    int itn=0;
    23192321    while(tmpI!=NULL){
    23202322#ifdef USE_MS
     
    23542356          }
    23552357
    2356           if(gfile==NULL){
     2358          if(gfile==NULL) {
    23572359            map *ext=getMap(tmpI->content,"extension");
    23582360            char *file_path;
     
    23692371            }
    23702372               
    2371             file_name=(char*)malloc((strlen(s->name)+strlen(file_ext)+strlen(tmpI->name)+1024)*sizeof(char));
    2372             int cpid0=cpid+time(NULL);     
    2373             sprintf(file_name,"%s_%s_%i.%s",s->name,tmpI->name,cpid0,file_ext);
     2373            file_name=(char*)malloc((strlen(s->name)+strlen(usid->value)+strlen(file_ext)+strlen(tmpI->name)+45)*sizeof(char));
     2374            sprintf(file_name,"%s_%s_%s_%d.%s",s->name,tmpI->name,usid->value,itn,file_ext);
     2375            itn++;
    23742376            file_path=(char*)malloc((strlen(tmp1->value)+strlen(file_name)+2)*sizeof(char));
    23752377            sprintf(file_path,"%s/%s",tmp1->value,file_name);
    23762378   
    2377                 FILE *ofile=fopen(file_path,"wb");
     2379            FILE *ofile=fopen(file_path,"wb");
    23782380            if(ofile==NULL){
    23792381              char tmpMsg[1024];
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