Ignore:
Timestamp:
Aug 16, 2018, 8:00:56 AM (6 years ago)
Author:
djay
Message:

Fixes for supporting properly the memory=protect which force the ZOO-Kernel to not store any downloaded files in memory. Add footer to the HPC support. Fix the autotools to build service_json and sshapi only when required so, when HPC support is activated, this also avoid adding too much dependencies at compilation time. Store md5 of the downloaded files to avoid uploading on HPC server the same file more than once, in case the md5 correspond.

File:
1 edited

Legend:

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

    r872 r877  
    2323 */
    2424
     25#include <openssl/md5.h>
     26#include <openssl/evp.h>
    2527#include "caching.h"
    2628#include "service.h"
    2729#include "service_internal.h"
    2830#include "response_print.h"
    29 #include <openssl/md5.h>
    30 #include <openssl/hmac.h>
    31 #include <openssl/evp.h>
    32 #include <openssl/bio.h>
    33 #include <openssl/buffer.h>
    3431
    3532/**
     
    6158  return fresult;
    6259}
     60
     61/**
     62 * Compute md5 of a file
     63 *
     64 * @param file the char*
     65 * @return a char* representing the md5 of the url
     66 * @warning make sure to free resources returned by this function
     67 */
     68char* getMd5f(char* file){
     69  EVP_MD_CTX md5ctx;
     70  char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char));
     71  unsigned char result[EVP_MAX_MD_SIZE];
     72  unsigned int len;
     73  int bytes;
     74  unsigned char data[1024];
     75  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);
     81  int i;
     82  for(i = 0; i < len; i++){
     83    if(i>0){
     84      char *tmp=zStrdup(fresult);
     85      sprintf(fresult,"%s%02x", tmp,result[i]);
     86      free(tmp);
     87    }
     88    else
     89      sprintf(fresult,"%02x",result[i]);
     90  }
     91  fclose (inFile);
     92  return fresult;
     93}
     94
    6395
    6496
     
    145177  map* tmp=getMapFromMaps(conf,"main","cacheDir");
    146178  char contentr[4096];
     179  char* md5fstr=NULL;
    147180  int cred=0;
    148181  if(tmp!=NULL){
     
    183216      fclose(fo);
    184217      fclose(fi);
    185        
     218
     219      // Store mimeType
    186220      sprintf(fname,"%s/%s.zcm",tmp->value,md5str);
    187221      fo=fopen(fname,"w+");
     
    192226      fclose(fo);
    193227
     228      // Store provenance
    194229      sprintf(fname,"%s/%s.zcp",tmp->value,md5str);
    195230      fo=fopen(fname,"w+");
     
    199234#endif
    200235      fwrite(origin,sizeof(char),strlen(origin),fo);
     236      fclose(fo);
     237
     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);
    201248      fclose(fo);
    202249
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