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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
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