Changeset 860 for branches


Ignore:
Timestamp:
Dec 12, 2017, 4:09:47 PM (6 years ago)
Author:
djay
Message:

Add status_code key to the lenv section to support returning a specific HTTP error code from the service code. Fix callback invocation to support inputs arrays at step 1 and 2. Fix issue with cpu usage. Fix issue with mapserver publication when an input is optional. Fix callback invocation at step 7 in case the service has failed on the HPC side.

Location:
branches/prototype-v0/zoo-project/zoo-kernel
Files:
12 edited

Legend:

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

    r854 r860  
    272272   
    273273    if(i>0){
     274      sprintf(cname,"cache_file_%d",i);
    274275      tmp1=getMap(content->content,cname);
    275       sprintf(cname,"cache_file_%d",i);
    276276      sprintf(vname,"value_%d",i);
    277277      sprintf(sname,"size_%d",i);
  • branches/prototype-v0/zoo-project/zoo-kernel/response_print.c

    r854 r860  
    24652465  else
    24662466    exceptionCode="501 Internal Server Error";
    2467 
     2467  tmp=getMapFromMaps(m,"lenv","status_code");
     2468  if(tmp!=NULL)
     2469    exceptionCode=tmp->value;
    24682470  if(m!=NULL){
    24692471    map *tmpSid=getMapFromMaps(m,"lenv","sid");
     
    26052607void outputResponse(service* s,maps* request_inputs,maps* request_outputs,
    26062608                    map* request_inputs1,int cpid,maps* m,int res){
    2607                
    26082609#ifdef DEBUG
    26092610  dumpMaps(request_inputs);
     
    26592660    }
    26602661  }
    2661                  
    26622662  if(res==SERVICE_FAILED){
    26632663    map *lenv;
     
    27182718      toto=getMap(tmpI->content,"asReference");
    27192719#ifdef USE_MS
    2720       restartNoMS:
     2720    restartNoMS:
    27212721      map* geodatatype=getMap(tmpI->content,"geodatatype");
    27222722     
     
    27782778
    27792779            toto=getMap(tmpI->content,"value");
     2780            if(toto==NULL){
     2781              char tmpMsg[1024];
     2782              sprintf(tmpMsg,_("No value found for the requested output %s."),tmpI->name);
     2783              errorException(m,tmpMsg,"InternalError",NULL);
     2784              fclose(ofile);
     2785              free(file_name);
     2786              free(file_path);
     2787              return;
     2788            }
    27802789            if(strcasecmp(format,"BoundingBoxData")!=0){
    27812790              map* size=getMap(tmpI->content,"size");
  • branches/prototype-v0/zoo-project/zoo-kernel/service.c

    r854 r860  
    865865  else
    866866    addToMap(m,tmp,value);
     867}
     868
     869/**
     870 * Add a key and an integer value to an existing map array.
     871 *
     872 * @param m the map to add the KVP
     873 * @param n the key to add
     874 * @param index the index of the MapArray
     875 * @param v the corresponding value to add
     876 */
     877void addIntToMapArray(map* m,const char* n,int index,const int v){
     878  char svalue[10];
     879  sprintf(svalue,"%d",v);
     880  setMapArray(m,n,index,svalue);
    867881}
    868882
  • branches/prototype-v0/zoo-project/zoo-kernel/service.h

    r850 r860  
    8181 */
    8282#define zWrite write
     83#include "unistd.h"
    8384/**
    8485 * The crossplatform sleep alias
    8586 */
    86 #define zSleep sleep
     87static int zSleep(const long millisecond){
     88  return usleep(millisecond*1000);
     89}
    8790/**
    8891 * The crossplatform gettimeofday alias
  • branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c

    r857 r860  
    142142           ( cStep!=arg->step || (arg->state!=0 && steps[arg->step][0]==false) )
    143143           ){
    144       struct timespec tv;
    145       tv.tv_sec = 0;
    146       tv.tv_nsec = (long) 5*1e+9;
    147       nanosleep(&tv, &tv);
    148       //sleep(1);
     144      zSleep(100);
    149145    }
    150146    isOngoing=1;
     
    307303     
    308304    case 1: {
    309       // Fetching data inputs
    310       maps* curs=inputs;
    311       dumpMaps(curs);
    312       char *keys[10][2]={
    313         {
    314           "href",
    315           "ref"
    316         },
    317         {
    318           "cache_file",
    319           "cachefile"
    320         },
    321         {
    322           "fmimeType",
    323           "mimetype"
    324         },
    325         {
    326           "size",
    327           "size"
    328         },
    329         {
    330           "ref_wms_link",
    331           "ref_wms_link"
    332         },
    333         {
    334           "ref_wcs_link",
    335           "ref_wcs_link"
    336         },
    337         {
    338           "ref_wcs_link",
    339           "ref_wcs_link"
    340         },
    341         {
    342           "ref_wcs_preview_link",
    343           "ref_wcs_preview_link"
    344         },
    345         {
    346           "geodatatype",
    347           "datatype"
    348         },
    349         {
    350           "wcs_extent",
    351           "boundingbox"
    352         }       
    353       };
    354       json_object *res1=json_object_new_object();
    355       while(curs!=NULL){
    356         map* tmpMap=getMap(curs->content,"cache_file");
    357         sid=getMap(curs->content,"ref_wms_link");
    358         json_object *res2=json_object_new_object();
    359         if(tmpMap!=NULL){
    360           if(sid==NULL){
    361             addToMap(curs->content,"generated_file",tmpMap->value);
    362             addToMap(curs->content,"storage",tmpMap->value);
    363           }
    364           fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    365           dumpMap(curs->content);
    366           struct stat buf;
    367           char timeStr[ 100 ] = "";
    368           if (stat(tmpMap->value, &buf)==0){
    369             strftime(timeStr, 100, "%d-%m-%Y %H:%M:%S", localtime( &buf.st_mtime));
    370             json_object *jsStr=json_object_new_string(timeStr);
    371             json_object_object_add(res2,"creation_date",jsStr);
    372           }
    373           tmpMap=getMap(curs->content,"fmimeType");
    374           if(tmpMap!=NULL){
    375             addToMap(curs->content,"mimeType",tmpMap->value);
    376           }
    377           setReferenceUrl(conf,curs);
    378         }
    379         int i=0;
    380         int hasRef=-1;
    381         for(;i<10;i++){
    382           sid=getMap(curs->content,keys[i][0]);
    383           if(sid!=NULL){
    384             json_object *jsStr=json_object_new_string(sid->value);
    385             json_object_object_add(res2,keys[i][1],jsStr);
    386             if(i==0){
    387               hasRef=1;
    388               json_object *jsStr1=json_object_new_string(getProvenance(conf,url->value));
    389               json_object_object_add(res2,"dataOrigin",jsStr1);
    390             }
    391           }
    392         }
    393         if(hasRef<0)
    394           json_object_put(res2);
    395         else
    396           json_object_object_add(res1,curs->name,res2);
    397         curs=curs->next;
    398       }
    399       json_object_object_add(res,"inputs",res1);
    400       break;
    401     }
    402      
    403     case 2: {
    404       // Update the execute request stored on disk at step 1,1 to modify the references used.
    405       if(state==0){
     305      // Update the execute request stored on disk at step 0,0 to modify the references used.
     306      if(state==1){
    406307        fprintf(stderr,"%s %d \n",__FILE__,__LINE__);
    407308        fflush(stderr);
     
    424325          //if(bvMap!=NULL && strncasecmp(bvMap->value,"true",4)==0){
    425326          if(getMap(curs->content,"href")==NULL && getMap(curs->content,"mimeType")!=NULL){
    426             map* tmpMap=getMap(curs->content,"cache_file");
     327            map* tmpMap=getMap(curs->content,"value");
     328            char tmpStr[100];
     329            sprintf(tmpStr,"%d",strlen(tmpMap->value));
     330            addToMap(curs->content,"size",tmpStr);
     331            tmpMap=getMap(curs->content,"mimeType");
     332            addToMap(curs->content,"fmimeType",tmpMap->value);
     333            tmpMap=getMap(curs->content,"cache_file");
    427334            addToMap(curs->content,"generated_file",tmpMap->value);
    428335            addToMap(curs->content,"storage",tmpMap->value);
     
    459366            char *tmpParam=(char*)malloc((strlen(curs->name)+11)*sizeof(char));
    460367            char *tmpParam1=(char*)malloc((strlen(filePath->value)+11)*sizeof(char));
    461             sprintf(tmpParam,"string(\"%s\")",curs->name);         
    462             sprintf(tmpParam1,"string(\"%s\")",filePath->value);           
     368            addToMap(curs->content,"href",filePath->value);
     369            addToMap(curs->content,"xlink:href",filePath->value);
     370            sprintf(tmpParam,"string(\"%s\")",curs->name);
     371            sprintf(tmpParam1,"string(\"%s\")",filePath->value);
    463372            params[0]="attr";
    464373            params[1]=tmpParam;
     
    538447      }
    539448
     449      // Fetching data inputs
     450      maps* curs=inputs;
     451      dumpMaps(curs);
     452      char *keys[11][2]={
     453        {
     454          "xlink:href",
     455          "ref"
     456        },
     457        {
     458          "cache_file",
     459          "cachefile"
     460        },
     461        {
     462          "fmimeType",
     463          "mimetype"
     464        },
     465        {
     466          "size",
     467          "size"
     468        },
     469        {
     470          "ref_wms_link",
     471          "ref_wms_link"
     472        },
     473        {
     474          "ref_wfs_link",
     475          "ref_wfs_link"
     476        },
     477        {
     478          "ref_wcs_link",
     479          "ref_wcs_link"
     480        },
     481        {
     482          "ref_wcs_link",
     483          "ref_wcs_link"
     484        },
     485        {
     486          "ref_wcs_preview_link",
     487          "ref_wcs_preview_link"
     488        },
     489        {
     490          "geodatatype",
     491          "datatype"
     492        },
     493        {
     494          "wgs84_extent",
     495          "boundingbox"
     496        }       
     497      };
     498      json_object *res1=json_object_new_object();
     499      while(curs!=NULL){
     500        if(getMap(curs->content,"length")==NULL){
     501          addToMap(curs->content,"length","1");
     502        }
     503        map* length=getMap(curs->content,"length");
     504        int len=atoi(length->value);
     505        json_object *res3;
     506        int hasRef=-1;
     507        for(int ii=0;ii<len;ii++){
     508          map* tmpMap=getMapArray(curs->content,"cache_file",ii);
     509          sid=getMapArray(curs->content,"ref_wms_link",ii);
     510          json_object *res2=json_object_new_object();
     511          if(tmpMap!=NULL){
     512            if(sid==NULL){
     513              setMapArray(curs->content,"generated_file",ii,tmpMap->value);
     514              setMapArray(curs->content,"storage",ii,tmpMap->value);
     515            }
     516            fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     517            dumpMap(curs->content);
     518            struct stat buf;
     519            char timeStr[ 100 ] = "";
     520            if (stat(tmpMap->value, &buf)==0){
     521              strftime(timeStr, 100, "%d-%m-%Y %H:%M:%S", localtime( &buf.st_mtime));
     522              json_object *jsStr=json_object_new_string(timeStr);
     523              json_object_object_add(res2,"creation_date",jsStr);
     524            }
     525            tmpMap=getMapArray(curs->content,"fmimeType",ii);
     526            if(tmpMap!=NULL){
     527              setMapArray(curs->content,"mimeType",ii,tmpMap->value);
     528            }
     529            setReferenceUrl(conf,curs);
     530          }else{         
     531          }
     532          addIntToMap(curs->content,"published_id",ii+1);
     533          int i=0;
     534          for(;i<11;i++){
     535            sid=getMapArray(curs->content,keys[i][0],ii);
     536            if(sid!=NULL){
     537              json_object *jsStr=json_object_new_string(sid->value);
     538              json_object_object_add(res2,keys[i][1],jsStr);
     539              if(i==0){
     540                hasRef=1;
     541                json_object *jsStr1=json_object_new_string(getProvenance(conf,sid->value));
     542                json_object_object_add(res2,"dataOrigin",jsStr1);
     543              }
     544            }
     545          }
     546          if(len>1){
     547            if(ii==0)
     548              res3=json_object_new_array();
     549            json_object_array_add(res3,res2);
     550          }else
     551            res3=res2;
     552        }
     553        if(hasRef<0)
     554          json_object_put(res3);
     555        else
     556          json_object_object_add(res1,curs->name,res3);
     557        addIntToMap(curs->content,"published_id",0);
     558        curs=curs->next;
     559      }
     560      json_object_object_add(res,"inputs",res1);
     561      break;
     562    }
     563     
     564    case 2: {
    540565      // Uploading data input to cluster
    541566      maps* in=getMaps(conf,"uploadQueue");
     
    545570        if(length!=NULL){
    546571          json_object *res1=json_object_new_object();
    547           json_object *res2=json_object_new_object();
     572          json_object *res3=json_object_new_array();
    548573          int limit=atoi(length->value);
    549574          int i=0;
     
    555580            map* tmp2=getMapArray(tmp,"targetPath",i);
    556581            if(tmp0!=NULL && tmp1!=NULL && tmp2!=NULL){
     582              json_object *res2=json_object_new_object();
    557583              json_object *jsStr=json_object_new_string(tmp1->value);
    558584              json_object_object_add(res2,"local_path",jsStr);
    559585              jsStr=json_object_new_string(tmp2->value);
    560586              json_object_object_add(res2,"target_path",jsStr);
    561               json_object_object_add(res1,tmp0->value,res2);
     587              json_object *res4=json_object_object_get(res1,tmp0->value);
     588              if(json_object_is_type(res4,json_type_null)){
     589                json_object_object_add(res1,tmp0->value,res2);
     590              }else{
     591                if(json_object_is_type(res4,json_type_object)){
     592                  json_object_array_add(res3,res4);
     593                }
     594                json_object_array_add(res3,res2);
     595                if(json_object_is_type(res4,json_type_object)){
     596                  json_object_object_del(res1,tmp0->value);
     597                  json_object_object_add(res1,tmp0->value,res3);
     598                }
     599              }
    562600            }
    563601          }
     602          if(json_object_array_length(res3)==0)
     603            json_object_put(res3);
    564604          json_object_object_add(res,"inputs",res1);
    565605        }
     
    616656        },
    617657        {
    618           "wcs_extent",
     658          "wgs84_extent",
    619659          "boundingbox"
    620660        },
     
    684724              int i0=0;
    685725              for(;i0<6;i0++){
    686                 sid=getMap(specificMaps->content,keys[i0][0]);
     726                if(i0==0)
     727                  sid=getMap(specificMaps->content,specifics[i][1]);
     728                else
     729                  sid=getMap(specificMaps->content,keys[i0][0]);
    687730                if(sid!=NULL){
    688731                  json_object *jsStr=json_object_new_string(sid->value);
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal.c

    r854 r860  
    649649              fprintf(stderr,"Retry to access the semaphore later ...\n");
    650650#endif
    651               zSleep(1);
     651              zSleep(1000);
    652652            }
    653653        }
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c

    r854 r860  
    285285 * @param real_inputs the maps containing the inputs
    286286 * @param real_outputs the maps containing the outputs
     287 * @return SERVICE_SUCCEEDED in case of success, -1 or SERVICE_FAILED when failing.
    287288 */
    288289int zoo_hpc_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){
     
    391392  }
    392393
    393   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    394   invokeCallback(m,inputs,NULL,2,0);
    395   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    396   dumpMaps(inputs);
     394#ifdef HPC_DEBUG
     395  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     396#endif
     397  invokeCallback(m,inputs,NULL,1,1);
    397398  if(getMapFromMaps(m,"lenv","mapError")!=NULL){
    398399    invokeCallback(m,inputs,NULL,7,0);
    399400    return -1;
    400401  }
     402  invokeCallback(m,inputs,NULL,2,0);
     403#ifdef HPC_DEBUG
     404  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     405  dumpMaps(inputs);
     406#endif
    401407
    402408  // Upload data on HPC
     
    404410    errorException (m, _("Unable to lock the file for upload!"),
    405411                    "InternalError", NULL);
    406     fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     412#ifdef HPC_DEBUG
     413    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     414#endif
    407415    invokeCallback(m,inputs,NULL,7,0);
    408     fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     416#ifdef HPC_DEBUG
     417    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     418#endif
    409419    return -1;
    410420  }
    411   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     421#ifdef HPC_DEBUG
     422  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     423#endif
    412424  invokeCallback(m,inputs,NULL,2,1);
    413   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     425#ifdef HPC_DEBUG
     426  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     427#endif
    414428
    415429  // Add the filename to generate for every output to parameters
     
    417431  // TODO: fix appendOutputParameters
    418432  //appendOutputParameters(input,parameters,&parameters_cnt,s,uuid,targetPathMap);
     433#ifdef HPC_DEBUG
    419434  dumpMaps(input);
     435#endif
    420436  while(input!=NULL){
    421437    // TODO: parse all outputs including inner outputs if required.
     
    509525  sprintf(scriptPath,"%s/zoo_%s_%s.sh",tmpPath->value,s->name,uuid->value);
    510526  setMapInMaps(*main_conf,"lenv","local_script",scriptPath);
     527#ifdef HPC_DEBUG
    511528  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    512529  fflush(stderr);
     530#endif
    513531  invokeCallback(m,inputs,NULL,3,0);
     532#ifdef HPC_DEBUG
    514533  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    515534  fflush(stderr);
     535#endif
    516536  FILE* scriptFile=fopen(scriptPath,"w+");
    517537  map* headerMap=getMapFromMaps(*main_conf,configurationId,"jobscript_header");
     
    562582      free(fcontent);
    563583    }else
    564       fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service BODY (no body found) *** ###\n\n");
     584      fprintf(scriptFile,"\n### *** Default ZOO-Service BODY (no body found) *** ###\n\n");
    565585  }else
    566     fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service BODY *** ###\n\n");
     586    fprintf(scriptFile,"\n### *** Default ZOO-Service BODY *** ###\n\n");
    567587
    568588  map* sp=getMap(s->content,"serviceProvider");
     
    583603  fflush(scriptFile);
    584604  fclose(scriptFile);
    585   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     605#ifdef HPC_DEBUG
     606  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     607#endif
    586608  invokeCallback(m,inputs,NULL,3,1);
    587   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     609#ifdef HPC_DEBUG
     610  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     611#endif
    588612
    589613  // Upload the SBATCH File to the remote host
    590   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     614#ifdef HPC_DEBUG
     615  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     616#endif
    591617  invokeCallback(m,inputs,NULL,4,0);
    592   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     618#ifdef HPC_DEBUG
     619  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     620#endif
    593621  targetPathMap=getMapFromMaps(*main_conf,configurationId,"remote_work_path");
    594622  if(targetPathMap==NULL){
     
    597625    errorException (m, _("There is no remote_work_path defined in your section!"),
    598626                    "InternalError", NULL);
     627#ifdef HPC_DEBUG
    599628    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    600629    fflush(stderr);
     630#endif
    601631    invokeCallback(m,NULL,NULL,7,0);
     632#ifdef HPC_DEBUG
    602633    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    603634    fflush(stderr);
     635#endif
    604636    return SERVICE_FAILED;
    605637  }
     
    609641  setMapInMaps(*main_conf,"lenv","remote_script",targetPath);
    610642  SSHCON *test=ssh_connect(*main_conf);
    611   ssh_copy(*main_conf,scriptPath,targetPath,ssh_get_cnt(*main_conf));
     643  int copy0=ssh_copy(*main_conf,scriptPath,targetPath,ssh_get_cnt(*main_conf));
    612644  unlink(scriptPath);
    613645  free(scriptPath);
     646  if(copy0!=true){
     647    setMapInMaps(m,"lenv","message",_("Unable to upload the script"));
     648    invokeCallback(m,NULL,NULL,7,0);
     649    errorException(m,_("Unable to upload the script"),"NoApplicableCode",NULL);
     650    return -1;
     651  }
    614652  // Execute the SBATCH script remotely
    615653  addReadLocks(main_conf);
     
    617655  char *command=(char*)malloc((strlen(targetPath)+strlen(targetPathMap->value)+strlen(subStr->value)+strlen(uuid->value)+137)*sizeof(char));
    618656  sprintf(command,"sbatch %s 2> %s/error_%s.log | sed \"s:%s::g\"",targetPath,targetPathMap->value,uuid->value,subStr->value);
    619   if(ssh_exec(*main_conf,command,ssh_get_cnt(m))==0){
     657  if(ssh_exec(*main_conf,command,ssh_get_cnt(m))<=0){
    620658    // The sbatch command has failed!
    621659    // Download the error log file from the HPC server
     
    645683    }else
    646684      setMapInMaps(*main_conf,"lenv","message",_("Unable to fetch the remote error log file"));
    647     tmpPath=getMapFromMaps(*main_conf,"lenv","message");
     685    tmpPath=getMapFromMaps(m,"lenv","message");
     686#ifdef HPC_DEBUG
    648687    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    649688    fflush(stderr);
     689#endif
    650690    invokeCallback(m,NULL,NULL,7,0);
     691#ifdef HPC_DEBUG
    651692    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    652693    fflush(stderr);
    653     sprintf(tmpS, "Cannot execute the HPC ZOO-Service %s: %s", s->name, tmpPath->value);
     694#endif
     695    sprintf(tmpS, "Cannot execute the HPC ZOO-Service %s using %s: %s", s->name, configurationId, tmpPath->value);
    654696    errorException(m,tmpS,"NoApplicableCode",NULL);
    655697    free(command);
    656698    free(targetPath);
    657699    ssh_close(*main_conf);
     700    removeReadLocks(main_conf);
    658701    sleep(1);
    659702    return -1;
    660703  }
    661704  free(targetPath);
     705#ifdef HPC_DEBUG
    662706  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    663707  fflush(stderr);
     708#endif
    664709  invokeCallback(m,NULL,NULL,4,1);
     710#ifdef HPC_DEBUG
    665711  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    666712  fflush(stderr);
     713#endif
    667714  free(command);
     715#ifdef HPC_DEBUG
    668716  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    669717  fflush(stderr);
     718#endif
    670719
    671720  struct sockaddr_un addr;
    672   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    673   fflush(stderr);
    674721  memset(&addr, 0, sizeof(addr));
    675   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    676   fflush(stderr);
    677722  addr.sun_family = AF_UNIX;
    678   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    679   fflush(stderr);
    680723  int rc, cl, fd = socket(AF_UNIX, SOCK_STREAM, 0);
    681   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    682   fflush(stderr);
    683724  char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(uuid->value)+20));
    684   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    685   fflush(stderr);
    686725  sprintf(sname,"%s/.wait_socket_%s.sock",tmpPath->value,uuid->value);
    687   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    688   fflush(stderr);
    689726  strncpy(addr.sun_path, sname, sizeof(addr.sun_path)-1);
    690   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    691   fflush(stderr);
    692727 
    693728  if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
     
    696731    errorException (m, _("Unable to bind socket!"),
    697732                    "InternalError", NULL);
     733#ifdef HPC_DEBUG
    698734    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    699735    fflush(stderr);
     736#endif
    700737    invokeCallback(m,NULL,NULL,7,0);
     738    removeReadLocks(main_conf);
     739#ifdef HPC_DEBUG
    701740    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    702741    fflush(stderr);
    703     sleep(120);
     742#endif
    704743    return -1;
    705744  }
     745#ifdef HPC_DEBUG
    706746  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    707747  fflush(stderr);
     748#endif
    708749  if (listen(fd, 5) == -1) {
    709750    setMapInMaps(*main_conf,"lenv","message",_("Listen error"));
    710751    errorException (m, _("Listen error"),
    711752                    "InternalError", NULL);
     753#ifdef HPC_DEBUG
    712754    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    713755    fflush(stderr);
     756#endif
    714757    invokeCallback(m,NULL,NULL,7,0);
     758    removeReadLocks(main_conf);
     759#ifdef HPC_DEBUG
    715760    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    716761    fflush(stderr);
     762#endif
    717763    return -1;
    718764  }
    719   fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    720   fflush(stderr);
    721765  if ( (cl = accept(fd, NULL, NULL)) == -1) {
    722766    setMapInMaps(*main_conf,"lenv","message",_("Accept error"));
    723767    errorException (m, _("Accept error"),
    724768                    "InternalError", NULL);
     769#ifdef HPC_DEBUG
    725770    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    726771    fflush(stderr);
     772#endif
    727773    invokeCallback(m,NULL,NULL,7,0);
     774    removeReadLocks(main_conf);
     775#ifdef HPC_DEBUG
    728776    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    729777    fflush(stderr);
     778#endif
    730779    return -1;
    731780  }else{
     781#ifdef HPC_DEBUG
    732782    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    733783    fflush(stderr);
     784#endif
    734785    int hasPassed=-1;
    735786    char buf[11];
     
    741792        errorException (m, _("Read closed"),
    742793                        "InternalError", NULL);
     794#ifdef HPC_DEBUG
    743795        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    744796        fflush(stderr);
     797#endif
    745798        invokeCallback(m,NULL,NULL,7,0);
     799        removeReadLocks(main_conf);
     800#ifdef HPC_DEBUG
    746801        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    747802        fflush(stderr);
     803#endif
    748804        return -1;
    749805      }else{
     
    752808          errorException (m, _("Read error"),
    753809                          "InternalError", NULL);
     810#ifdef HPC_DEBUG
    754811          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    755812          fflush(stderr);
     813#endif
    756814          invokeCallback(m,NULL,NULL,7,0);
     815          removeReadLocks(main_conf);
     816#ifdef HPC_DEBUG
    757817          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    758818          fflush(stderr);
     819#endif
    759820          return -1;
    760821        }
    761822      }
    762823      hasPassed=1;
    763       fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    764       fflush(stderr);
    765824      res=atoi(buf);
    766       fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    767       fflush(stderr);
    768825      unlink(sname);
    769       fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    770       fflush(stderr);
    771826      free(sname);
    772       fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    773       fflush(stderr);
    774827      removeReadLocks(main_conf);
    775       fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    776       fflush(stderr);
    777828 
    778829      if(res==3){
     830#ifdef HPC_DEBUG
    779831        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    780832        fflush(stderr);
     833#endif
    781834        invokeCallback(m,NULL,outputs,5,0);
     835#ifdef HPC_DEBUG
    782836        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    783837        fflush(stderr);
     838#endif
     839
     840        // Read informations provided by FinalizeHPC as a configuration file
     841        // then, remove the file.
     842        map* jobid=getMapFromMaps(*main_conf,"lenv","usid");
     843        map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath");
     844        char *filePath=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+15)*sizeof(char));
     845        sprintf(filePath,"%s/exec_status_%s",tmpPath->value,jobid->value);
     846        maps* m = (maps *) malloc (MAPS_SIZE);
     847        m->child=NULL;
     848        m->next=NULL;
     849        int saved_stdout = dup (fileno (stdout));
     850        dup2 (fileno (stderr), fileno (stdout));
     851        conf_read(filePath,m);
     852        fflush(stdout);
     853        dup2 (saved_stdout, fileno (stdout));
     854        close(saved_stdout);
     855        unlink(filePath);
     856        free(filePath);
     857        addMapsToMaps(main_conf,m);
     858        freeMaps(&m);
     859        free(m);
     860
    784861        input=*real_outputs;
    785862        while(input!=NULL){
     
    797874                char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));
    798875                sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename);
    799                 setMapInMaps(*main_conf,"lenv","message",tmpStr);
     876                setMapInMaps(m,"lenv","message",tmpStr);
    800877                free(tmpStr);
    801878                invokeCallback(m,NULL,NULL,7,0);
     
    804881            }       
    805882          }else{
    806             fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    807             fflush(stderr);
    808883            map* generatedFile=getMap(input->content,"generated_file");
    809884            if(generatedFile!=NULL){
     
    834909                  sprintf(serviceName,"wcs_link");
    835910                  setMapInMaps(output->child,serviceName,"msOgc","WCS");
     911                  setMapInMaps(output->child,serviceName,"requestedMimeType","image/tiff");
    836912                }
    837913                else{
    838914                  sprintf(serviceName,"wfs_link");
    839915                  setMapInMaps(output->child,serviceName,"msOgc","WFS");
     916                  setMapInMaps(output->child,serviceName,"requestedMimeType","text/xml");
    840917                }
    841918                setMapInMaps(output->child,serviceName,"storage",targetPath);
     
    844921                setMapInMaps(output->child,serviceName,"asReference","true");
    845922              }else{
    846                 char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));
    847                 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename);
    848                 setMapInMaps(*main_conf,"lenv","message",tmpStr);
    849                 free(tmpStr);
    850                 invokeCallback(m,NULL,NULL,7,0);
     923                map* hpcStdErr=getMapFromMaps(*main_conf,"henv","StdErr");
     924                if(hpcStdErr!=NULL && ssh_fetch(*main_conf,targetPath,hpcStdErr->value,ssh_get_cnt(m))==0){
     925                  struct stat f_status;
     926                  int ts=stat(targetPath, &f_status);
     927                  if(ts==0) {
     928                    char* fcontent = NULL;
     929                    fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
     930                    FILE* f=fopen(targetPath,"rb");
     931                    fread(fcontent,f_status.st_size,1,f);
     932                    int fsize=f_status.st_size;
     933                    fcontent[fsize]=0;
     934                    fclose(f);
     935                    setMapInMaps(*main_conf,"lenv","message",fcontent);
     936                    free(fcontent);
     937                  }else{
     938                    char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));
     939                    sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename);
     940                    setMapInMaps(*main_conf,"lenv","message",tmpStr);
     941                    free(tmpStr);
     942                  }
     943                }else{
     944                  char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));
     945                  sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename);
     946                  setMapInMaps(*main_conf,"lenv","message",tmpStr);
     947                  free(tmpStr);
     948                }
     949                invokeCallback(*main_conf,NULL,NULL,7,0);
    851950                return SERVICE_FAILED;
    852951              }
     
    857956        }
    858957
    859         // Read informations provided by FinalizeHPC as a configuration file
    860         // then, remove the file.
    861         map* jobid=getMapFromMaps(*main_conf,"lenv","usid");
    862         map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath");
    863         char *filePath=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+15)*sizeof(char));
    864         sprintf(filePath,"%s/exec_status_%s",tmpPath->value,jobid->value);
    865         maps* m = (maps *) malloc (MAPS_SIZE);
    866         m->child=NULL;
    867         m->next=NULL;
    868         int saved_stdout = dup (fileno (stdout));
    869         dup2 (fileno (stderr), fileno (stdout));
    870         conf_read(filePath,m);
    871         fflush(stdout);
    872         dup2 (saved_stdout, fileno (stdout));
    873         close(saved_stdout);
    874         unlink(filePath);
    875         free(filePath);
    876         addMapsToMaps(main_conf,m);
    877         freeMaps(&m);
    878         free(m);
    879958      }else{
    880959        // Try to access remotely to the log file and return a more relevant error message
     
    882961        errorException (m, _("HPC Execution failed!"),
    883962                        "InternalError", NULL);
     963#ifdef HPC_DEBUG
    884964        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    885965        fflush(stderr);
     966#endif
    886967        invokeCallback(m,NULL,NULL,7,0);
     968#ifdef HPC_DEBUG
    887969        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    888970        fflush(stderr);
     971#endif
    889972      }
    890973      //free(buf);
     
    895978      errorException (m, _("Unable to parse the value returned by remote execution"),
    896979                      "InternalError", NULL);
     980#ifdef HPC_DEBUG
    897981      fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    898982      fflush(stderr);
     983#endif
    899984      invokeCallback(m,NULL,NULL,7,0);
     985#ifdef HPC_DEBUG
    900986      fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    901987      fflush(stderr);
    902       sleep(120);
     988#endif
    903989      return SERVICE_FAILED;
    904990    }
    905991  }
     992#ifdef HPC_DEBUG
    906993  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    907994  fflush(stderr);
     995#endif
    908996  ssh_close(*main_conf);
     997#ifdef HPC_DEBUG
    909998  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    910999  fflush(stderr);
     1000#endif
    9111001  return res;
    9121002}
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c

    r854 r860  
    7676
    7777/**
     78 * Return the current publish_id value
     79 * @param elem and maps pointer on which the search occur
     80 * @return the integer value of the publish_id field, if any, 0 otherwise
     81 */
     82int getPublishedId(maps* elem){
     83  map* myIndex=getMap(elem->content,"published_id");
     84  if(myIndex!=NULL){
     85    return atoi(myIndex->value);
     86  }
     87  return 0;
     88}
     89/**
    7890 * Add width and height keys to an output maps containing the maximum width
    7991 * and height for displaying the full data extent.
     
    8799 */
    88100void setMapSize(maps* output,double minx,double miny,double maxx,double maxy){
     101  int imyIndex=getPublishedId(output);
    89102  double maxWidth=640;
    90103  double maxHeight=480;
     
    118131#endif
    119132  if(output!=NULL){
    120     addToMap(output->content,"width",sWidth);
    121     addToMap(output->content,"height",sHeight);
     133    setMapArray(output->content,"width",imyIndex,sWidth);
     134    setMapArray(output->content,"height",imyIndex,sHeight);
    122135  }
    123136}
     
    131144 */
    132145void setReferenceUrl(maps* m,maps* tmpI){
    133   outputMapfile(m,tmpI);
    134146  map *msUrl=getMapFromMaps(m,"main","mapserverAddress");
    135147  if(msUrl==NULL){
     
    138150    exit(-1);
    139151  }
     152  int imyIndex=getPublishedId(tmpI);
     153  if(getMapArray(tmpI->content,"ref_wms_link",imyIndex)!=NULL)
     154    return;
     155  outputMapfile(m,tmpI);
    140156  int finalProto=-1;
    141157  map *msOgcVersion=getMapFromMaps(m,"main","msOgcVersion");
    142158  map *dataPath=getMapFromMaps(m,"main","dataPath");
    143159  map *sid=getMapFromMaps(m,"lenv","usid");
    144   map* format=getMap(tmpI->content,"mimeType");
    145   map* rformat=getMap(tmpI->content,"requestedMimeType");
    146   map* width=getMap(tmpI->content,"width");
    147   map* height=getMap(tmpI->content,"height");
    148   map* protoMap=getMap(tmpI->content,"msOgc");
    149   map* versionMap=getMap(tmpI->content,"msOgcVersion");
     160  map* format=getMapArray(tmpI->content,"mimeType",imyIndex);
     161  map* rformat=getMapArray(tmpI->content,"requestedMimeType",imyIndex);
     162  map* width=getMapArray(tmpI->content,"width",imyIndex);
     163  map* height=getMapArray(tmpI->content,"height",imyIndex);
     164  map* protoMap=getMapArray(tmpI->content,"msOgc",imyIndex);
     165  map* versionMap=getMapArray(tmpI->content,"msOgcVersion",imyIndex);
     166  map* datatype=getMapArray(tmpI->content,"geodatatype",imyIndex);
    150167  char options[4][5][25]={
    151168    {"WMS","1.3.0","GetMap","layers=%s","wms_extent"},
     
    154171    {"WCS","1.1.0","GetCoverage","coverage=%s","wcs_extent"}
    155172  };
    156   map* datatype=getMap(tmpI->content,"geodatatype");
    157173  if(datatype==NULL || strncmp(datatype->value,"other",5)==0){
    158     setMapInMaps(m,"lenv","mapError","true");
    159     setMapInMaps(m,"lenv","locator",tmpI->name);
    160     setMapInMaps(m,"lenv","message",_("The ZOO-Kernel was able to retrieve the data but could not read it as geographic data."));
    161     if(getMapFromMaps(m,"lenv","state")==NULL)
    162       errorException (m, _("Unable to find any geographic data"), "WrongInputData", tmpI->name);
     174    map* minNb=getMap(tmpI->content,"minoccurs");
     175    if(minNb==NULL || atoi(minNb->value)>=1){
     176      setMapInMaps(m,"lenv","mapError","true");
     177      setMapInMaps(m,"lenv","locator",tmpI->name);
     178      setMapInMaps(m,"lenv","message",_("The ZOO-Kernel was able to retrieve the data but could not read it as geographic data."));
     179      if(getMapFromMaps(m,"lenv","state")==NULL)
     180        errorException (m, _("Unable to find any geographic data"), "WrongInputData", tmpI->name);
     181    }
    163182    return;
    164183  }
    165184  int proto=0;
    166185  if(rformat==NULL){
    167     rformat=getMap(tmpI->content,"mimeType");
     186    rformat=getMapArray(tmpI->content,"mimeType",imyIndex);
    168187  }
    169188  if(strncasecmp(rformat->value,"text/xml",8)==0)
     
    172191     strncasecmp(rformat->value,"image/geotiff",10)==0)
    173192    proto=2;
     193  int hasFormat=-1;
    174194  if(protoMap!=NULL){
    175     if(strncasecmp(protoMap->value,"WMS",3)==0)
     195    hasFormat=1;
     196    if(strncasecmp(protoMap->value,"WMS",3)==0){
    176197      proto=0;
     198      rformat=createMap("value","image/png");
     199    }
    177200    else{
    178       if(strncasecmp(protoMap->value,"WFS",3)==0)
     201      if(strncasecmp(protoMap->value,"WFS",3)==0){
    179202        proto=1;
    180       else
     203        rformat=createMap("value","text/xml");
     204      }
     205      else {
    181206        proto=2;
     207        rformat=createMap("value","image/tiff");
     208      }
    182209    }
    183210  }
     
    190217  }
    191218
    192   map* extent=getMap(tmpI->content,options[proto][4]);
    193   map* crs=getMap(tmpI->content,"crs");
     219
     220  map* extent=getMapArray(tmpI->content,options[proto][4],imyIndex);
     221  map* crs=getMapArray(tmpI->content,"crs",imyIndex);
    194222  int hasCRS=1;
    195223  if(crs==NULL){
     
    203231  sprintf(layers,options[proto][3],tmpI->name);
    204232
    205   char* webService_url=(char*)malloc((strlen(msUrl->value)+strlen(format->value)+strlen(tmpI->name)+strlen(width->value)+strlen(height->value)+strlen(extent->value)+256)*sizeof(char));
     233  if(format==NULL || width==NULL || height==NULL || extent==NULL){
     234    char tmpStr[1024];
     235    sprintf(tmpStr,_("Unable to create the mapfile for %s because of missing values."),tmpI->name);
     236    errorException (m, tmpStr,
     237                    "InternalError", NULL);
     238    exit(-1);
     239    return;
     240  }
     241
     242  if(proto==0){
     243    hasFormat=1;
     244    rformat=createMap("mimeType","image/png");
     245  }else{
     246    if(proto==1){
     247      rformat=createMap("mimeType","text/xml");
     248      hasFormat=1;
     249    }
     250    else
     251      if(proto==2){
     252        rformat=createMap("mimeType","image/tiff");
     253        hasFormat=1;
     254        finalProto=1;
     255      }
     256  }
    206257 
     258  char* webService_url=(char*)malloc((strlen(msUrl->value)+strlen(rformat->value)+strlen(tmpI->name)+strlen(width->value)+strlen(height->value)+strlen(extent->value)+256)*sizeof(char));
     259
     260
    207261  if(proto>0){
    208262    if(proto==2)
    209263      finalProto=1;
    210264    sprintf(webService_url,
    211             "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",
     265            "%s?map=%s/%s_%d_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",
    212266            msUrl->value,
    213267            dataPath->value,
    214268            tmpI->name,
     269            imyIndex,
    215270            sid->value,
    216271            options[proto][2],
     
    223278            );
    224279    if(datatype!=NULL && strncasecmp(datatype->value,"raster",6)==0){
    225       addToMap(tmpI->content,"ref_wcs_link",webService_url);
     280      setMapArray(tmpI->content,"ref_wcs_link",imyIndex,webService_url);
    226281    }
    227282    else{
    228       addToMap(tmpI->content,"ref_wfs_link",webService_url);
     283      setMapArray(tmpI->content,"ref_wfs_link",imyIndex,webService_url);
    229284    }
    230285    proto=0;
     286    freeMap(&rformat);
     287    free(rformat);
    231288    rformat=createMap("mimeType","image/png");
    232289  }
    233290  else{
    234291    sprintf(webService_url,
    235             "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s",
     292            "%s?map=%s/%s_%d_%s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s",
    236293            msUrl->value,
    237294            dataPath->value,
    238295            tmpI->name,
     296            imyIndex,
    239297            sid->value,
    240298            options[proto][2],
     
    248306            crs->value
    249307            );
    250     addToMap(tmpI->content,"ref_wms_link",webService_url);
     308    setMapArray(tmpI->content,"ref_wms_link",imyIndex,webService_url);
    251309    if(datatype!=NULL && strncasecmp(datatype->value,"raster",6)==0){
    252310      proto=2;
     311      freeMap(&rformat);
     312      free(rformat);
    253313      rformat=createMap("mimeType","image/tiff");
    254314    }
    255315    else{
    256316      proto=1;
     317      freeMap(&rformat);
     318      free(rformat);
    257319      rformat=createMap("mimeType","text/xml");
    258320    }
    259321  }
    260   addToMap(tmpI->content,"Reference",webService_url);
     322  setMapArray(tmpI->content,"Reference",imyIndex,webService_url);
    261323  memset(layers,0,128);
    262324  sprintf(layers,options[proto][3],tmpI->name);
    263325  protoVersion=options[proto][1];
    264   extent=getMap(tmpI->content,options[proto][4]);
     326  extent=getMapArray(tmpI->content,options[proto][4],imyIndex);
    265327  memset(webService_url,0,strlen(webService_url));
    266328  if(proto>0){
     
    268330      finalProto=1;
    269331    sprintf(webService_url,
    270             "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",
     332            "%s?map=%s/%s_%d_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",
    271333            msUrl->value,
    272334            dataPath->value,
    273335            tmpI->name,
     336            imyIndex,
    274337            sid->value,
    275338            options[proto][2],
     
    282345            );
    283346    if(datatype!=NULL && strncasecmp(datatype->value,"raster",6)==0){
    284       addToMap(tmpI->content,"ref_wcs_link",webService_url);
     347      setMapArray(tmpI->content,"ref_wcs_link",imyIndex,webService_url);
    285348    }
    286349    else{
    287       addToMap(tmpI->content,"ref_wfs_link",webService_url);
     350      setMapArray(tmpI->content,"ref_wfs_link",imyIndex,webService_url);
    288351    }
    289352  }else{
    290353    sprintf(webService_url,
    291             "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s",
     354            "%s?map=%s/%s_%d_%s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s",
    292355            msUrl->value,
    293356            dataPath->value,
    294357            tmpI->name,
     358            imyIndex,
    295359            sid->value,
    296360            options[proto][2],
     
    304368            crs->value
    305369            );
    306     addToMap(tmpI->content,"ref_wms_link",webService_url);
     370    setMapArray(tmpI->content,"ref_wms_link",imyIndex,webService_url);
    307371  }
    308372  if(finalProto>0){
     
    311375    sprintf(layers,options[proto][3],tmpI->name);
    312376    protoVersion=options[proto][1];
    313     extent=getMap(tmpI->content,options[proto][4]);
     377    extent=getMapArray(tmpI->content,options[proto][4],imyIndex);
    314378    memset(webService_url,0,strlen(webService_url));
     379    freeMap(&rformat);
     380    free(rformat);
     381    rformat=createMap("value","image/tiff");
    315382    sprintf(webService_url,
    316             "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",
     383            "%s?map=%s/%s_%d_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",
    317384            msUrl->value,
    318385            dataPath->value,
    319386            tmpI->name,
     387            imyIndex,
    320388            sid->value,
    321389            options[proto][2],
     
    327395            crs->value
    328396            );
    329     addToMap(tmpI->content,"ref_wcs_preview_link",webService_url);
     397    setMapArray(tmpI->content,"ref_wcs_preview_link",imyIndex,webService_url);
    330398  }
    331399  if(hasCRS==0){
     
    352420  OGRSpatialReferenceH  hSRS;
    353421  map* msSrs=NULL;
     422  int imyIndex=getPublishedId(output);
    354423  hSRS = OSRNewSpatialReference(NULL);
    355424  if( pszProjection!=NULL && strlen(pszProjection)>1){
     
    375444        if(output!=NULL){
    376445          if(OSRIsGeographic(hSRS)==TRUE)
    377             addToMap(output->content,"crs_isGeographic","true");
     446            setMapArray(output->content,"crs_isGeographic",imyIndex,"true");
    378447          else
    379             addToMap(output->content,"crs_isGeographic","false");
    380           addToMap(output->content,"crs",tmpSrs);
     448            setMapArray(output->content,"crs_isGeographic",imyIndex,"false");
     449          setMapArray(output->content,"crs",imyIndex,tmpSrs);
    381450        }
    382451      }
     
    391460          if(output!=NULL){
    392461            if(OSRIsGeographic(hSRS)==TRUE)
    393               addToMap(output->content,"crs_isGeographic","true");
     462              setMapArray(output->content,"crs_isGeographic",imyIndex,"true");
    394463            else
    395               addToMap(output->content,"crs_isGeographic","false");
     464              setMapArray(output->content,"crs_isGeographic",imyIndex,"false");
    396465          }
    397466          free(proj4Str);
     
    401470          msLoadProjectionStringEPSG(&myLayer->projection,"EPSG:4326");
    402471          if(output!=NULL){
    403             addToMap(output->content,"crs_isGeographic","true");
     472            setMapArray(output->content,"crs_isGeographic",imyIndex,"true");
    404473          }
    405474        }
    406475        if(output!=NULL){
    407           addToMap(output->content,"crs","EPSG:4326");
    408           addToMap(output->content,"real_extent","true");
     476          setMapArray(output->content,"crs",imyIndex,"EPSG:4326");
     477          setMapArray(output->content,"real_extent",imyIndex,"true");
    409478        }
    410479        msInsertHashTable(&(m->web.metadata),"ows_srs", "EPSG:4326 EPSG:900913 EPSG:3857");
     
    415484  else{
    416485    if(output!=NULL){
    417       msSrs=getMap(output->content,"msSrs");
     486      msSrs=getMapArray(output->content,"msSrs",imyIndex);
    418487    }
    419488    if(msSrs!=NULL){
     
    431500    }
    432501    if(output!=NULL){
    433       addToMap(output->content,"crs",msSrs->value);
    434       addToMap(output->content,"crs_isGeographic","true");
     502      setMapArray(output->content,"crs",imyIndex,msSrs->value);
     503      setMapArray(output->content,"crs_isGeographic",imyIndex,"true");
    435504    }
    436505  }
     
    454523void setMsExtent(maps* output,mapObj* m,layerObj* myLayer,
    455524                 double minX,double minY,double maxX,double maxY){
     525  int imyIndex=getPublishedId(output);
    456526  msMapSetExtent(m,minX,minY,maxX,maxY);
    457527#ifdef DEBUGMS
     
    466536 
    467537  if(output!=NULL){
    468     map* test=getMap(output->content,"real_extent");
     538    map* test=getMapArray(output->content,"real_extent",imyIndex);
     539    pointObj min, max;
     540    projectionObj tempSrs;
     541    min.x = m->extent.minx;
     542    min.y = m->extent.miny;
     543    max.x = m->extent.maxx;
     544    max.y = m->extent.maxy;
     545    char tmpSrsStr[1024];
     546    msInitProjection(&tempSrs);
     547    msLoadProjectionStringEPSG(&tempSrs,"EPSG:4326");
     548
     549    msProjectPoint(&(myLayer->projection),&tempSrs,&min);
     550    msProjectPoint(&myLayer->projection,&tempSrs,&max);
     551 
    469552    if(test!=NULL){
    470       pointObj min, max;
    471       projectionObj tempSrs;
    472       min.x = m->extent.minx;
    473       min.y = m->extent.miny;
    474       max.x = m->extent.maxx;
    475       max.y = m->extent.maxy;
    476       char tmpSrsStr[1024];
    477       msInitProjection(&tempSrs);
    478       msLoadProjectionStringEPSG(&tempSrs,"EPSG:4326");
    479 
    480       msProjectPoint(&(m->projection),&tempSrs,&min);
    481       msProjectPoint(&m->projection,&tempSrs,&max);
    482      
    483553      sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",min.y,min.x,max.y,max.x);
    484       map* isGeo=getMap(output->content,"crs_isGeographic");
     554      map* isGeo=getMapArray(output->content,"crs_isGeographic",imyIndex);
    485555#ifdef DEBUGMS
    486556      fprintf(stderr,"isGeo = %s\n",isGeo->value);
    487557#endif
    488       if(isGeo!=NULL && strcasecmp("true",isGeo->value)==0)
     558      if(isGeo!=NULL && strcasecmp("true",isGeo->value)==0){
     559        sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",min.y,min.x,max.y,max.x);
     560        setMapArray(output->content,"wgs84_extent",imyIndex,tmpExtent);
    489561        sprintf(tmpExtent,"%f,%f,%f,%f", minY,minX, maxY, maxX);
    490       addToMap(output->content,"wms_extent",tmpExtent);
     562      }else{
     563        sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",min.x,min.y,max.x,max.y);
     564        setMapArray(output->content,"wgs84_extent",imyIndex,tmpExtent);
     565      }
     566      setMapArray(output->content,"wms_extent",imyIndex,tmpExtent);
    491567      sprintf(tmpSrsStr,"%.3f,%.3f,%.3f,%.3f",min.x,min.y,max.x,max.y);
    492       addToMap(output->content,"wcs_extent",tmpExtent);
     568      setMapArray(output->content,"wcs_extent",imyIndex,tmpExtent);
    493569    }else{
     570      sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",min.x,min.y,max.x,max.y);
     571      setMapArray(output->content,"wgs84_extent",imyIndex,tmpExtent);
    494572      sprintf(tmpExtent,"%f,%f,%f,%f",minX, minY, maxX, maxY);
    495       map* isGeo=getMap(output->content,"crs_isGeographic");
     573      map* isGeo=getMapArray(output->content,"crs_isGeographic",imyIndex);
    496574      if(isGeo!=NULL){
    497575#ifdef DEBUGMS
     
    501579          sprintf(tmpExtent,"%f,%f,%f,%f", minY,minX, maxY, maxX);
    502580      }
    503       addToMap(output->content,"wms_extent",tmpExtent);
     581      setMapArray(output->content,"wms_extent",imyIndex,tmpExtent);
    504582      sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",minX,minY,maxX,maxY);
    505       addToMap(output->content,"wcs_extent",tmpExtent);
     583      setMapArray(output->content,"wcs_extent",imyIndex,tmpExtent);
    506584    }
    507585  }
     
    518596 */
    519597int tryOgr(maps* conf,maps* output,mapObj* m){
    520 
    521   map* tmpMap=getMap(output->content,"storage");
     598  int imyIndex=getPublishedId(output);
     599  map* tmpMap=getMapArray(output->content,"storage",imyIndex);
    522600  char *pszDataSource=tmpMap->value;
    523601
     
    643721#endif
    644722    setMapInMaps(conf,"lenv","message","Unable to open datasource in read only mode");
    645     //OGR_DS_Destroy(poDS);
    646     //OGRCleanupAll();
    647723#ifdef DEBUGMS
    648724    fprintf(stderr,"Unable to access the DataSource, exit! \n");
     
    651727  }
    652728
    653   addToMap(output->content,"geodatatype","vector");
     729  setMapArray(output->content,"geodatatype",imyIndex,"vector");
    654730  int iLayer = 0;
    655731  for( iLayer=0; iLayer < OGR_DS_GetLayerCount(poDS); iLayer++ ){
     
    687763    msConnectLayer(myLayer,MS_OGR,pszDataSource);
    688764
    689     addIntToMap(output->content,"nb_features",OGR_L_GetFeatureCount(poLayer,1));
     765    addIntToMapArray(output->content,"nb_features",imyIndex,OGR_L_GetFeatureCount(poLayer,1));
    690766
    691767    /**
     
    739815    }
    740816    else{
    741       addToMap(output->content,"crs","EPSG:4326");
    742       addToMap(output->content,"crs_isGeographic","true");
     817      setMapArray(output->content,"crs",imyIndex,"EPSG:4326");
     818      setMapArray(output->content,"crs_isGeographic",imyIndex,"true");
    743819      msLoadProjectionStringEPSG(&m->projection,"EPSG:4326");
    744820      msInsertHashTable(&(m->web.metadata), "ows_srs", "EPSG:4326 EPSG:900913 EPSG:3857");
     
    752828      memset(&extent,0,1024);
    753829      sprintf(extent,"%d,%d,%d,%d",oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY);
    754       addToMap(output->content,"boundingbox",extent);
     830      setMapArray(output->content,"boundingbox",imyIndex,extent);
    755831    }
    756832 
     
    771847    msInsertHashTable(&(myLayer->metadata), "gml_include_items", "all");
    772848    msInsertHashTable(&(myLayer->metadata), "ows_name", output->name);
    773     map* tmpMap=getMap(output->content,"title");
     849    map* tmpMap=getMapArray(output->content,"title",imyIndex);
    774850    if(tmpMap!=NULL)
    775851      msInsertHashTable(&(myLayer->metadata), "ows_title", tmpMap->value);
     
    839915 */
    840916int tryGdal(maps* conf,maps* output,mapObj* m){
    841   map* tmpMap=getMap(output->content,"storage");
     917  int imyIndex=getPublishedId(output);
     918  map* tmpMap=getMapArray(output->content,"storage",imyIndex);
    842919  char *pszFilename=tmpMap->value;
    843920  GDALDatasetH hDataset;
     
    855932    fprintf(stderr,"Unable to access the DataSource %s \n",pszFilename);
    856933#endif
    857     addToMap(output->content,"geodatatype","other");
     934    setMapArray(output->content,"geodatatype",imyIndex,"other");
    858935    setMapInMaps(conf,"lenv","message","gdalinfo failed - unable to open");
    859936    GDALDestroyDriverManager();
     
    864941#endif
    865942
    866   addToMap(output->content,"geodatatype","raster");
     943  setMapArray(output->content,"geodatatype",imyIndex,"raster");
    867944  /**
    868945   * Add a new layer set name, data
     
    886963
    887964  char *title=output->name;
    888   tmpMap=getMap(output->content,"title");
     965  tmpMap=getMapArray(output->content,"title",imyIndex);
    889966  if(tmpMap!=NULL)
    890967    title=tmpMap->value;
    891968  char *abstract=output->name;
    892   tmpMap=getMap(output->content,"abstract");
     969  tmpMap=getMapArray(output->content,"abstract",imyIndex);
    893970  if(tmpMap!=NULL)
    894971    abstract=tmpMap->value;
     
    905982  m->width=GDALGetRasterXSize( hDataset );
    906983  m->height=GDALGetRasterYSize( hDataset );
    907   addIntToMap(output->content,"nb_pixels",GDALGetRasterXSize( hDataset )*GDALGetRasterYSize( hDataset ));
     984  addIntToMapArray(output->content,"nb_pixels",imyIndex,GDALGetRasterXSize( hDataset )*GDALGetRasterYSize( hDataset ));
    908985 
    909986  /**
     
    9471024      memset(&extent,0,1024);
    9481025      sprintf(extent,"%d,%d,%d,%d",minX,minY,maxX,maxY);
    949       addToMap(output->content,"boundingbox",extent);
     1026      setMapArray(output->content,"boundingbox",imyIndex,extent);
    9501027    }
    9511028  }else{
    9521029    int scale=1;
    9531030    if(m->width>2048){
    954       addIntToMap(output->content,"width",2048);
     1031      addIntToMapArray(output->content,"width",imyIndex,2048);
    9551032      scale=2048/m->width;
    9561033    }else
    957       addIntToMap(output->content,"width",m->width);
    958     addIntToMap(output->content,"height",m->height*scale);
     1034      addIntToMapArray(output->content,"width",imyIndex,m->width);
     1035    addIntToMapArray(output->content,"height",imyIndex,m->height*scale);
    9591036  }
    9601037
     
    11301207   * First store the value on disk
    11311208   */
    1132   map* mime=getMap(outputs->content,"mimeType");
     1209  int imyIndex=getPublishedId(outputs);
     1210  map* mime=getMapArray(outputs->content,"mimeType",imyIndex);
    11331211  char *ext="data";
    11341212  if(mime!=NULL)
     
    11361214      ext="json";
    11371215
    1138   map* storage=getMap(outputs->content,"storage");
     1216  map* storage=getMapArray(outputs->content,"storage",imyIndex);
    11391217  if(storage==NULL){
    11401218    map* tmpMap=getMapFromMaps(conf,"main","dataPath");
    11411219    map* sidMap=getMapFromMaps(conf,"lenv","usid");
    11421220    char *pszDataSource=(char*)malloc((strlen(tmpMap->value)+strlen(sidMap->value)+strlen(outputs->name)+17)*sizeof(char));
    1143     sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext);
     1221    sprintf(pszDataSource,"%s/ZOO_DATA_%d_%s_%s.%s",tmpMap->value,imyIndex,outputs->name,sidMap->value,ext);
    11441222    int f=zOpen(pszDataSource,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
    1145     map *gfile=getMap(outputs->content,"generated_file");
     1223    map *gfile=getMapArray(outputs->content,"generated_file",imyIndex);
    11461224    if(gfile!=NULL){
    11471225      readGeneratedFile(conf,outputs->content,gfile->value);       
    11481226    }
    1149     map* sizeMap=getMap(outputs->content,"size");
    1150     map* vData=getMap(outputs->content,"value");
     1227    map* sizeMap=getMapArray(outputs->content,"size",imyIndex);
     1228    map* vData=getMapArray(outputs->content,"value",imyIndex);
    11511229    if(sizeMap!=NULL){
    11521230      zWrite(f,vData->value,atoi(sizeMap->value)*sizeof(char));
     
    11561234    }
    11571235    close(f);
    1158     addToMap(outputs->content,"storage",pszDataSource);
     1236    setMapArray(outputs->content,"storage",imyIndex,pszDataSource);
    11591237    free(pszDataSource);
    11601238  }
     
    13271405  map* sid=getMapFromMaps(conf,"lenv","usid");
    13281406  char *mapPath=
    1329     (char*)malloc((7+strlen(sid->value)+strlen(outputs->name)+strlen(tmp1->value))*sizeof(char));
    1330   sprintf(mapPath,"%s/%s_%s.map",tmp1->value,outputs->name,sid->value);
     1407    (char*)malloc((14+strlen(sid->value)+strlen(outputs->name)+strlen(tmp1->value))*sizeof(char));
     1408  sprintf(mapPath,"%s/%s_%d_%s.map",tmp1->value,outputs->name,imyIndex,sid->value);
    13311409  msSaveMap(myMap,mapPath);
    13321410  free(mapPath);
  • branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.c

    r854 r860  
    121121int _init_sql(maps* conf,const char* key){
    122122  char* sqlInitString=_createInitString(conf,key);
     123#ifdef SQL_DEBUG
    123124  fprintf(stderr,"Try to connect to: %s %s !\n",key,sqlInitString);
    124125  fflush(stderr); 
     126#endif
    125127  if(strncmp(sqlInitString,"-1",2)==0)
    126128    return -1;
    127   fprintf(stderr,"Try to connect to: %s !\n",key);
    128   fflush(stderr); 
    129129  OGRSFDriver *poDriver = NULL;
    130130  OGRRegisterAll();
     
    165165#endif
    166166  if( zoo_DS[zoo_ds_nb] == NULL ){
    167 #ifdef DEBUG
     167#ifdef SQL_DEBUG
    168168    fprintf(stderr,"sqlInitString: %s FAILED !\n",sqlInitString);
    169169    fflush(stderr);
     
    174174    return -2;
    175175  }
    176 #ifdef DEBUG
     176#ifdef SQL_DEBUG
    177177  fprintf(stderr,"sqlInitString: %s SUCEED !\n",sqlInitString);
    178178  fflush(stderr);
    179179#endif
    180   fprintf(stderr,"sqlInitString: %s SUCEED %d !\n",sqlInitString,zoo_ds_nb);
    181   fflush(stderr); 
    182180  free(sqlInitString);
    183181  zoo_ds_nb++;
     
    234232    return NULL;
    235233  OGRLayer *res=NULL;
    236 #ifdef DEBUG
     234#ifdef SQL_DEBUG
    237235  fprintf(stderr,"************************* %s %s %d\n\n",sqlQuery,__FILE__,__LINE__);
    238236  fflush(stderr);
     
    381379  char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(msg->value)+strlen(p->value)+strlen(sid->value)+64+1)*sizeof(char));
    382380  sprintf(sqlQuery,"UPDATE %s.services set status=$$%s$$,message=$$%s$$ where uuid=$$%s$$;",schema->value,p->value,msg->value,sid->value);
    383   if(zoo_ds_nb==0){
     381  if( zoo_ds_nb==
     382#ifdef META_DB
     383      1
     384#else
     385      0
     386#endif     
     387     ){
    384388    init_sql(conf);
    385389    zoo_ds_nb++;
  • branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c

    r854 r860  
    283283    }
    284284  }while(!sftp_handle);
     285#ifdef SSH_DEBUG
    285286  fprintf(stderr, "libssh2_sftp_open() is done, get file information\n");
     287#endif
    286288  do {
    287289  rc = libssh2_sftp_stat_ex(sessions[cnt]->sftp_session, targetPath, strlen(targetPath),
     
    295297  else
    296298    {
     299#ifdef SSH_DEBUG
    297300      fprintf(stderr, "Stat Data: RetCode=%d\n", rc);
    298301      fprintf(stderr, "Stat Data: Size=%llu\n", attrs.filesize);
    299302      fprintf(stderr, "Stat Data: Perm=%lx\n",  attrs.permissions);
    300303      fprintf(stderr, "Stat Data: mtime=%lu\n",  attrs.mtime);
     304#endif
    301305      if(rc==0)
    302306        break;
     
    348352      return false;
    349353    }
     354    if(!sessions[cnt]->sftp_session)
     355      zSleep(10);
    350356  } while (!sessions[cnt]->sftp_session);
    351357
     
    363369      return false;
    364370    }
     371    if(!sftp_handle)
     372      zSleep(10);
    365373  } while (!sftp_handle);
    366374  start = time(NULL);
     
    432440      return -1;
    433441    }
     442    if(!sessions[cnt]->sftp_session)
     443      zSleep(10);
    434444  } while (!sessions[cnt]->sftp_session);
    435445  do {
     
    482492      return -1;
    483493    }
    484  
     494    
    485495  } while (1);
    486496  duration = (int)(time(NULL)-start);
     
    503513  int exitcode;
    504514  char *exitsignal=(char *)"none";
    505   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    506   fflush(stderr);
    507515  while( (channel = libssh2_channel_open_session(sessions[cnt]->session)) == NULL &&
    508516         libssh2_session_last_error(sessions[cnt]->session,NULL,NULL,0) == LIBSSH2_ERROR_EAGAIN ) {
    509     fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    510     fflush(stderr);
    511       waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session);
    512   }
    513   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    514   fflush(stderr);
     517    waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session);
     518  }
    515519  if( channel == NULL ){
    516520    fprintf(stderr,"Error\n");
    517521    return -1;
    518522  }
    519   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    520   fflush(stderr);
    521523  while( (rc = libssh2_channel_exec(channel, command)) == LIBSSH2_ERROR_EAGAIN ) {
    522     fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    523     fflush(stderr);
    524524    waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session);
    525525  }
    526   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    527   fflush(stderr);
    528526  if( rc != 0 ) {
    529527    fprintf(stderr,"Error\n");
    530528    return -1;
    531529  }
    532   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    533   fflush(stderr);
    534530
    535531  map* tmpPath=getMapFromMaps(conf,"main","tmpPath");
     
    539535  FILE* logFile=fopen(logPath,"wb");
    540536  free(logPath);
    541   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    542   fflush(stderr);
    543537  while(true){
    544538    int rc;
     
    563557      break;
    564558  }
    565   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    566   fflush(stderr);
    567559  fclose(logFile);
    568   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    569   fflush(stderr);
    570560  exitcode = 127;
    571   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    572   fflush(stderr);
    573561  while( (rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN )
    574562    waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session);
    575   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    576   fflush(stderr);
    577563 
    578564  if( rc == 0 ) {
     
    581567                                    NULL, NULL, NULL, NULL, NULL);
    582568  }
    583   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    584   fflush(stderr);
    585569 
    586570  if (exitsignal)
     
    588572  else
    589573    fprintf(stderr, "\nEXIT: %d bytecount: %d\n", exitcode, bytecount);
    590   fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    591   fflush(stderr);
    592574 
    593575  libssh2_channel_free(channel);
     
    664646    }
    665647  }
    666 #ifdef DEBUG 
     648#ifdef SSH_DEBUG 
    667649  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    668650  fflush(stderr);
     
    682664    return false;
    683665  }
    684 #ifdef DEBUG
     666#ifdef SSH_DEBUG
    685667  fprintf(stderr,"*** %s %d\n",__FILE__,__LINE__);
    686668  fflush(stderr);
     
    700682        getMapArray(queueMaps->content,"targetPath",i)
    701683      };
     684#ifdef SSH_DEBUG     
    702685      fprintf(stderr,"*** %s %d %s %s\n",__FILE__,__LINE__,argv[1]->value,argv[2]->value);
     686#endif     
    703687      /**/zooLock* lck;
    704688      if((lck=lockFile(*conf,argv[1]->value,'w'))!=NULL){/**/
  • branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c

    r859 r860  
    316316  if(passThrough!=NULL && targetHosts!=NULL){
    317317    char *tmp=zStrdup(passThrough->value);
    318     char *token, *saveptr;
    319     token = strtok_r (tmp, ",", &saveptr);
    320318    int i;
    321319    for(i=0;i<handle->nb;i++){
    322320      if(strstr(targetHosts->value,"*")!=NULL || isProtectedHost(targetHosts->value,handle->ihandle[i].url)==1){
     321        char *token, *saveptr;
     322        token = strtok_r (tmp, ",", &saveptr);
    323323        while (token != NULL){
    324324          int length=strlen(token)+6;
     
    338338            AddMissingHeaderEntry(&handle->ihandle[i],token,tmpMap->value);
    339339          }
    340           free(tmp1);
    341340          if(handle->ihandle[i].header!=NULL)
    342341            curl_easy_setopt(handle->ihandle[i].handle,CURLOPT_HTTPHEADER,handle->ihandle[i].header);
     342          free(tmp1);
    343343          cnt+=1;
    344344          token = strtok_r (NULL, ",", &saveptr);
     
    520520    if(curl_multi_perform(hInternet->handle, &still_running)==CURLM_OK)
    521521      if(still_running){
    522         struct timespec tv;
    523         tv.tv_sec = 0;
    524         tv.tv_nsec = (long) 100;
    525         nanosleep(&tv, &tv);
     522        zSleep(10);
    526523      }
    527524  }while(still_running); 
  • branches/prototype-v0/zoo-project/zoo-kernel/zoo_service_loader.c

    r854 r860  
    22012201      int hasValidCookie = -1;
    22022202      char *tcook = originalCookie = zStrdup (cgiCookie);
    2203       //fprintf(stderr,">>>>> %s %d %s\n",__FILE__,__LINE__,tcook );
    2204       char *tmp = NULL;
    22052203      map *testing = getMapFromMaps (m, "main", "cookiePrefix");
    22062204      parseCookie(&m,originalCookie);
    2207       if (testing == NULL)
     2205      map *sessId=getMapFromMaps(m,"cookies",(testing==NULL?"ID":testing->value));
     2206      if (sessId!=NULL)
    22082207        {
    2209           tmp = zStrdup ("ID=");
    2210         }
    2211       else
    2212         {
    2213           tmp =
    2214             (char *) malloc ((strlen (testing->value) + 2) * sizeof (char));
    2215           sprintf (tmp, "%s=", testing->value);
    2216         }
    2217       if (strstr (cgiCookie, ";") != NULL)
    2218         {
    2219           char *token, *saveptr;
    2220           token = strtok_r (tcook, ";", &saveptr);
    2221           while (token != NULL)
    2222             {
    2223               if (strcasestr (token, tmp) != NULL)
    2224                 {
    2225                   if (tcook != NULL)
    2226                     free (tcook);
    2227                   tcook = zStrdup (token);
    2228                   hasValidCookie = 1;
    2229                 }
    2230               token = strtok_r (NULL, ";", &saveptr);
    2231             }
    2232         }
    2233       else
    2234         {
    2235           if (strstr (cgiCookie, "=") != NULL
    2236               && strcasestr (cgiCookie, tmp) != NULL)
    2237             {
    2238               tcook = zStrdup (cgiCookie);
    2239               hasValidCookie = 1;
    2240             }
    2241           if (tmp != NULL)
    2242             {
    2243               free (tmp);
    2244             }
    2245         }
    2246       if (hasValidCookie > 0)
    2247         {
    2248           addToMap (_tmpMaps->content, "sessid", strstr (tcook, "=") + 1);
     2208          addToMap (_tmpMaps->content, "sessid", sessId->value);
    22492209          char session_file_path[1024];
    22502210          map *tmpPath = getMapFromMaps (m, "main", "sessPath");
     
    22542214          if (tmp1 != NULL)
    22552215            sprintf (session_file_path, "%s/sess_%s.cfg", tmpPath->value,
    2256                      strstr (tmp1, "=") + 1);
     2216                     sessId->value);
    22572217          else
    22582218            sprintf (session_file_path, "%s/sess_%s.cfg", tmpPath->value,
    2259                      strstr (cgiCookie, "=") + 1);
     2219                     sessId->value);
    22602220          free (tcook);
    22612221          maps *tmpSess = (maps *) malloc (MAPS_SIZE);
     
    23512311  if (status == NULLMAP)
    23522312    {
    2353       /*        hInternet = InternetOpen (
    2354 #ifndef WIN32
    2355                                   (LPCTSTR)
    2356 #endif
    2357                                   "ZooWPSClient\0",
    2358                                   INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);*/
    23592313      if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
    23602314        freeService (&s1);
     
    23782332      close_sql(m,0);     
    23792333#endif     
    2380 
    2381       /*#ifdef RELY_ON_DB
    2382       //close_sql(m,1);
    2383       //end_sql();
    2384       #endif*/
    23852334    }
    23862335  else
     
    24332382          setMapInMaps (m, "lenv", "async","true");
    24342383          map* r_inputs1 = createMap("ServiceName", s1->name);
    2435 
    2436           /*hInternet = InternetOpen (
    2437 #ifndef WIN32
    2438                                     (LPCTSTR)
    2439 #endif
    2440                                     "ZooWPSClient\0",
    2441                                     INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
    2442 #ifndef WIN32
    2443           if (!CHECK_INET_HANDLE (hInternet))
    2444             fprintf (stderr, "WARNING : hInternet handle failed to initialize");
    2445             #endif*/
    24462384
    24472385          // Create the filename for the result file (.res)
     
    25582496          invokeCallback(m,request_input_real_format,NULL,1,0);
    25592497          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    2560           dumpMaps(request_output_real_format);
     2498          //dumpMaps(request_output_real_format);
    25612499          if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
    25622500            freeService (&s1);
     
    26002538            return -1;
    26012539          }
    2602           dumpMaps(request_output_real_format);
    2603           fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    2604           invokeCallback(m,request_input_real_format,NULL,1,1);
    2605           fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    26062540          if(getMapFromMaps(m,"lenv","mapError")!=NULL){
    26072541                setMapInMaps(m,"lenv","message",_("Issue with geographic data"));
     
    26342568  fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__);
    26352569#endif
    2636 fflush(stdout);
    2637 rewind(stdout);
     2570  fflush(stdout);
     2571  rewind(stdout);
     2572
    26382573  if (eres != -1)
    26392574    outputResponse (s1, request_input_real_format,
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