Changeset 880 for branches


Ignore:
Timestamp:
Sep 12, 2018, 4:02:49 PM (6 years ago)
Author:
djay
Message:

Modify memory configuration option gesture. Now, in case you don't have setup memory option in the main section your main.cfg file then, the ZOO-Kernel will load everything in memory and will also store the file containing the input. In case you want the old mode, you have to set memory option to 'load' in your main.cfg file. Fix issue with loading R ZOO-Service located in a subdirectory. Support for XML Execute request containing TEXT_NODE when CDATA_NODE should be used.

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

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/zoo-project/zoo-kernel/Makefile.in

    r873 r880  
    129129zcfg2yaml: zcfg2yaml.c service.h lex.sr.o service_conf.tab.o service_conf.y main_conf_read.tab.o lex.cr.o response_print.o server_internal.o service_internal.o ${MS_FILE} ${YAML_FILE}
    130130        g++ -g -O2 ${JSCFLAGS} ${RUBYCFLAGS} ${XML2CFLAGS} ${CFLAGS} -c zcfg2yaml.c  -fno-common -DPIC -o zcfg2yaml.o
    131         g++  ${XML2CFLAGS} ${CFLAGS} zcfg2yaml.o ulinet.o service_callback.o server_internal.o service_internal.o ${MS_FILE} response_print.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o  ${YAML_FILE} -o zcfg2yaml -L. ${LDFLAGS}
     131        g++  ${XML2CFLAGS} ${CFLAGS} zcfg2yaml.o caching.o ulinet.o service_callback.o server_internal.o service_internal.o ${MS_FILE} response_print.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o  ${YAML_FILE} -o zcfg2yaml -L. ${LDFLAGS}
    132132
    133133install: zoo_loader.cgi
  • branches/prototype-v0/zoo-project/zoo-kernel/caching.c

    r877 r880  
    6767 */
    6868char* getMd5f(char* file){
    69   EVP_MD_CTX md5ctx;
     69  EVP_MD_CTX *md5ctx=EVP_MD_CTX_create();
    7070  char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char));
    7171  unsigned char result[EVP_MAX_MD_SIZE];
    7272  unsigned int len;
    7373  int bytes;
    74   unsigned char data[1024];
     74  int dlen=65536;
     75  unsigned char data[dlen+1];
    7576  FILE *inFile = fopen (file, "rb");
    76   EVP_DigestInit(&md5ctx, EVP_md5());
    77   while ((bytes = fread (data, 1, 1024, inFile)) != 0)
    78     EVP_DigestUpdate(&md5ctx, data, bytes);
    79   EVP_DigestFinal_ex(&md5ctx,result,&len);
    80   EVP_MD_CTX_cleanup(&md5ctx);
     77  EVP_DigestInit(md5ctx, EVP_md5());
     78  while ((bytes = fread (data, sizeof(unsigned char), dlen, inFile)) != 0)
     79    EVP_DigestUpdate(md5ctx, data, bytes);
     80  EVP_DigestFinal_ex(md5ctx,result,&len);
     81  EVP_MD_CTX_cleanup(md5ctx);
     82  EVP_MD_CTX_destroy(md5ctx);
    8183  int i;
    8284  for(i = 0; i < len; i++){
     
    162164
    163165/**
     166 * Store MD5 of the content of a file
     167 * @file char* the full path of the file
     168 */
     169int storeMd5(char* file){
     170  char* storage=zStrdup(file);
     171  char* md5fstr=getMd5f(file);
     172  storage[strlen(storage)-2]='m';
     173  storage[strlen(storage)-1]='d';
     174  FILE* fo=fopen(storage,"w+");
     175  if(fo==NULL)
     176    return 1;
     177  fwrite(md5fstr,sizeof(char),strlen(md5fstr),fo);
     178  free(md5fstr);
     179  fclose(fo);
     180  return 0;
     181}
     182
     183/**
    164184 * Cache a file for a given request.
    165185 * For each cached file, the are two files stored, a .zca and a .zcm containing
     
    177197  map* tmp=getMapFromMaps(conf,"main","cacheDir");
    178198  char contentr[4096];
    179   char* md5fstr=NULL;
    180199  int cred=0;
    181200  if(tmp!=NULL){
     
    184203    free(myRequest);
    185204    char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6));
     205    // Store md5
     206    char* md5fstr=getMd5f(filename);
     207    sprintf(fname,"%s/%s.zmd",tmp->value,md5str);
     208    FILE* fo=fopen(fname,"w+");
     209#ifdef DEBUG
     210    fprintf(stderr,"filename: %s\n",filename);
     211    fprintf(stderr,"MD5: %s\n",md5fstr);
     212#endif
     213    fwrite(md5fstr,sizeof(char),strlen(md5fstr),fo);
     214    free(md5fstr);
     215    fclose(fo);
     216   
    186217    sprintf(fname,"%s/%s.zca",tmp->value,md5str);
    187218    zooLock* lck=lockFile(conf,fname,'w');
     
    192223#endif
    193224      FILE* fi=fopen(filename,"rb");
    194       FILE* fo=fopen(fname,"w+");
     225      sprintf(fname,"%s/%s.zca",tmp->value,md5str);
     226      fo=fopen(fname,"w+");
    195227      if(fo==NULL){
    196228#ifdef DEBUG
     
    236268      fclose(fo);
    237269
    238       // Store md5
    239       sprintf(fname,"%s/%s.zca",tmp->value,md5str);
    240       md5fstr=getMd5f(fname);
    241       sprintf(fname,"%s/%s.zmd",tmp->value,md5str);
    242       fo=fopen(fname,"w+");
    243 #ifdef DEBUG
    244       fprintf(stderr,"MD5: %s\n",md5fstr);
    245 #endif
    246       fwrite(md5fstr,sizeof(char),strlen(md5fstr),fo);
    247       free(md5fstr);
    248       fclose(fo);
    249 
    250270      free(md5str);
    251       free(fname);
    252     }
     271
     272    }
     273    free(fname);
    253274  }
    254275}
     
    342363    }
    343364    else{
    344 
    345365      char* myRequest=getFilenameForRequest(conf,request);
    346366      char* md5str=getMd5(myRequest);
     
    436456
    437457      if(getMap(content->content,icname)==NULL) {
    438         if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){
     458        if(memUse==NULL || strcasecmp(memUse->value,"load")==0){
    439459          fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char));
    440460          if(fcontent == NULL){
     
    456476       
    457477        map* tmpMap=getMapOrFill(&(*in)->content,vname,"");
    458         if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){
     478        if(memUse==NULL || strcasecmp(memUse->value,"load")==0){
    459479          free(tmpMap->value);
    460480          tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));
     
    518538        addToMap((*in)->content,sname,ltmp1);
    519539        addToMap((*in)->content,mname,mimeType);
    520         if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){
     540        if(memUse==NULL || strcasecmp(memUse->value,"load")==0){
    521541          addToCache(*m,request,fcontent,mimeType,fsize, NULL, 0);
    522542          free(fcontent);
     
    628648        return -1;
    629649      fsize=f_status.st_size;
    630       if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){
     650      if(memUse==NULL || strcasecmp(memUse->value,"load")==0){
    631651        fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
    632652        FILE* f=fopen(cached,"rb");
     
    665685
    666686  map* tmpMap=getMapOrFill(content,"value","");
    667   if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){
     687  if(memUse==NULL || strcasecmp(memUse->value,"load")==0){
    668688    free(tmpMap->value);
    669689    tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));
     
    677697  addToMap(*content,"size",ltmp1);
    678698  if(cached==NULL){
    679     if(memUse!=NULL && strcasecmp(memUse->value,"load")==0)
     699    if(memUse==NULL || strcasecmp(memUse->value,"load")==0)
    680700      addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0);
    681701    else
  • branches/prototype-v0/zoo-project/zoo-kernel/caching.h

    r797 r880  
    3535  void addRequestToQueue(maps**,HINTERNET*,const char*,bool);
    3636  int loadRemoteFile(maps**,map**,HINTERNET*,char*);
    37 
     37  char* getMd5f(char*);
     38  int storeMd5(char*);
     39 
    3840#ifdef __cplusplus
    3941}
  • branches/prototype-v0/zoo-project/zoo-kernel/request_parser.c

    r877 r880  
    978978
    979979                      map *test = getMap (tmpmaps->content, "encoding");
    980                      
    981980                      if (test == NULL)
    982981                        {
     
    992991                      if (getMap(tmpmaps->content,"dataType")==NULL && test!=NULL && strcasecmp (test->value, "base64") != 0)
    993992                        {
    994                           xmlChar *mv = xmlNodeListGetString (doc,
    995                                                               cur4->xmlChildrenNode,
    996                                                               1);
     993                          xmlChar *mv = NULL;
     994                          /*if(cur4!=NULL && cur4->xmlChildrenNode!=NULL)
     995                            xmlChar *mv = xmlNodeListGetString (doc,
     996                                                                cur4->xmlChildrenNode,
     997                                                                1);*/
    997998                          map *ltmp =
    998                             getMap (tmpmaps->content, "mimeType");                       
    999                           if (mv == NULL
    1000                               ||
     999                            getMap (tmpmaps->content, "mimeType");
     1000                          if (/*mv == NULL
     1001                              ||*/
    10011002                              (xmlStrcasecmp
    10021003                               (cur4->name, BAD_CAST "ComplexData") == 0
     
    10361037                                           buffersize);
    10371038                            }else{
     1039
    10381040                            if(xmlStrcasecmp
    10391041                               (cur4->name, BAD_CAST "BoundingBoxData") == 0){
     
    10511053                              while (cur5 != NULL
    10521054                                     && cur5->type != XML_ELEMENT_NODE
     1055                                     && cur5->type != XML_TEXT_NODE
    10531056                                     && cur5->type != XML_CDATA_SECTION_NODE)
    10541057                                cur5 = cur5->next;
    10551058                              if (cur5 != NULL
    1056                                   && cur5->type != XML_CDATA_SECTION_NODE)
     1059                                  && cur5->type != XML_CDATA_SECTION_NODE
     1060                                  && cur5->type != XML_TEXT_NODE)
    10571061                                {
    10581062                                  xmlDocPtr doc1 = xmlNewDoc (BAD_CAST "1.0");
     
    10651069                                               buffersize);
    10661070                                }
    1067                               else /*if (cur5 != NULL
     1071                              else if (cur5 != NULL)/*
    10681072                                     && cur5->type == XML_CDATA_SECTION_NODE)*/{
    10691073                                xmlFree(mv);
    1070                                 mv=xmlStrdup(cur5->content);
     1074                                if(cur5->content!=NULL){
     1075                                  mv=xmlStrdup(cur5->content);
     1076                                }
    10711077                              }
    10721078                            }
     
    11501156                  }
    11511157              }
    1152             else
     1158            else{
    11531159              addMapsToMaps (request_output, tmpmaps);
     1160            }
    11541161          }
    11551162          freeMaps (&tmpmaps);
  • branches/prototype-v0/zoo-project/zoo-kernel/response_print.h

    r877 r880  
    3838
    3939#include <libintl.h>
    40 #include <locale.h>
     40#include <xlocale.h>
    4141/**
    4242 * ZOO-Kernel internal messages translation function
     
    8080#endif
    8181#ifndef WIN32
    82 #include <xlocale.h>
     82#include <locale.h>
    8383#endif
    8484#include "ulinet.h"
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal.h

    r877 r880  
    3838
    3939#include <libintl.h>
    40 #include <locale.h>
     40#include <xlocale.h>
    4141/**
    4242 * ZOO-Kernel internal messages translation function
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c

    r877 r880  
    3434#include "server_internal.h"
    3535#include "response_print.h"
     36#include "caching.h"
    3637
    3738/**
     
    12351236  GDALDestroyDriverManager();
    12361237  CPLCleanupTLS();
     1238  storeMd5(pszFilename);
    12371239  return 1;
    12381240}
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_r.c

    r877 r880  
    110110  if(tmp!=NULL){
    111111    if(mp!=NULL && strlen(mp->value)>0){
    112       char *mps=zStrdup(mp->value);
    113       int i,len=strlen(mps);
    114       int j=0;
    115       for(i=0;i<len;i++){
    116         if(mps[i]=='/'){
    117           mps[i]='.';
    118         }
    119       }
    120       char *mn=(char*)malloc((strlen(mps)+strlen(tmp->value)+2)*sizeof(char));
    121       sprintf(mn,"%s.%s",mps,tmp->value);
     112      char *mn=(char*)malloc((strlen(mp->value)+strlen(tmp->value)+2)*sizeof(char));
     113      sprintf(mn,"%s/%s",mp->value,tmp->value);
    122114      pName = mkString(mn);
    123115      free(mn);
    124       free(mps);
    125116    }
    126117    else{
    127       dumpMap(tmp);
    128118      char *tmpStr=(char*)malloc((strlen(r_path)+strlen(tmp->value)+2)*sizeof(char));
    129119      sprintf(tmpStr,"%s/%s",r_path,tmp->value);
     
    189179        char* finalStr=(char*)malloc((strlen(tmpStr)+strlen(_("Unable to run your R service: "))+2)*sizeof(char));
    190180        sprintf(finalStr,"%s %s",_("Unable to run your R service: "),tmpStr);
    191         fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,tmpStr);
    192         fflush(stderr);
    193181        errorException(*main_conf,finalStr,"NoApplicableCode",NULL);
    194182        free(finalStr);
  • branches/prototype-v0/zoo-project/zoo-kernel/ulinet.h

    r871 r880  
    4545#include "jsapi.h"
    4646#endif
     47#ifndef __cplusplus
    4748#ifndef bool
    4849#define bool int
     
    5152#define true 1
    5253#define false 0
     54#endif
    5355#endif
    5456
  • branches/prototype-v0/zoo-project/zoo-kernel/zoo_service_loader.c

    r877 r880  
    107107#endif
    108108
     109#ifdef USE_HPC
    109110#include "service_json.h"
    110111#include "service_callback.h"
     112#endif
    111113
    112114#include <dirent.h>
     
    23472349      }
    23482350      map* testMap=getMapFromMaps(m,"main","memory");
    2349       if(testMap!=NULL && strcasecmp(testMap->value,"load")!=0)
     2351      if(testMap==NULL || strcasecmp(testMap->value,"load")!=0)
    23502352        dumpMapsValuesToFiles(&m,&request_input_real_format);
    23512353      loadServiceAndRun (&m, s1, request_inputs, &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