Changeset 470


Ignore:
Timestamp:
May 2, 2014, 11:19:03 AM (10 years ago)
Author:
djay
Message:

Remove memory leaks in parseIdentifier and use thread safe CURL version.

Location:
trunk/zoo-project/zoo-kernel
Files:
3 edited

Legend:

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

    r469 r470  
    29252925    setMapInMaps(conf,"lenv",key,tmps2);
    29262926    free(tmps2);
     2927    free(test);
    29272928    level++;
    29282929    tmps1=strtok_r(NULL,".",&saveptr1);
     
    29532954      }
    29542955    }else{
    2955       char *tmp0=zStrdup(tmp00->value);
    2956       tmp0[strlen(tmp0)-1]=0;
    2957       setMapInMaps(conf,"lenv","Identifier",tmp0);
    2958       free(tmp0);
     2956      char *tmp01=zStrdup(tmp00->value);
     2957      tmp01[strlen(tmp01)-1]=0;
     2958      setMapInMaps(conf,"lenv","Identifier",tmp01);
     2959      free(tmp01);
    29592960    }
    29602961  }
  • trunk/zoo-project/zoo-kernel/ulinet.c

    r446 r470  
    170170  ret.mimeType = NULL;
    171171
    172   ret.handle=curl_easy_init();
    173 
    174   curl_easy_setopt(ret.handle, CURLOPT_COOKIEFILE, "ALL");
     172  ret.handle=curl_share_init();
     173
     174  curl_share_setopt(ret.handle, CURLOPT_COOKIEFILE, "ALL");
    175175#ifndef TIGER
    176   curl_easy_setopt(ret.handle, CURLOPT_COOKIELIST, "ALL");
    177 #endif
    178   curl_easy_setopt(ret.handle, CURLOPT_USERAGENT, lpszAgent);
    179  
    180   curl_easy_setopt(ret.handle,CURLOPT_FOLLOWLOCATION,1);
    181   curl_easy_setopt(ret.handle,CURLOPT_MAXREDIRS,3);
     176  curl_share_setopt(ret.handle, CURLOPT_COOKIELIST, "ALL");
     177#endif
     178  curl_share_setopt(ret.handle, CURLOPT_USERAGENT, lpszAgent);
     179 
     180  curl_share_setopt(ret.handle,CURLOPT_FOLLOWLOCATION,1);
     181  curl_share_setopt(ret.handle,CURLOPT_MAXREDIRS,3);
    182182 
    183183  header.memory=NULL;
    184184  header.size = 0;
    185185
    186   curl_easy_setopt(ret.handle, CURLOPT_HEADERFUNCTION, header_write_data);
    187   curl_easy_setopt(ret.handle, CURLOPT_WRITEHEADER, (void *)&header);
    188 
    189 #ifdef MSG_LAF_VERBOSE
    190   curl_easy_setopt(ret.handle, CURLOPT_VERBOSE, 1);
     186  curl_share_setopt(ret.handle, CURLOPT_HEADERFUNCTION, header_write_data);
     187  curl_share_setopt(ret.handle, CURLOPT_WRITEHEADER, (void *)&header);
     188
     189#ifdef MSG_LAF_VERBOSE
     190  curl_share_setopt(ret.handle, CURLOPT_VERBOSE, 1);
    191191#endif
    192192
     
    206206  }
    207207  if(handle.handle)
    208     curl_easy_cleanup(handle.handle);
     208    curl_share_cleanup(handle.handle);
    209209  curl_global_cleanup();
    210210}
     
    222222    case INTERNET_FLAG_NO_CACHE_WRITE:   
    223223      hInternet.hasCacheFile=-1;
    224       curl_easy_setopt(hInternet.handle, CURLOPT_WRITEFUNCTION, write_data_into);
    225       curl_easy_setopt(hInternet.handle, CURLOPT_WRITEDATA, &hInternet);
     224      curl_share_setopt(hInternet.handle, CURLOPT_WRITEFUNCTION, write_data_into);
     225      curl_share_setopt(hInternet.handle, CURLOPT_WRITEDATA, &hInternet);
    226226      break;
    227227    default:
     
    236236   
    237237      hInternet.hasCacheFile=1;
    238       curl_easy_setopt(hInternet.handle, CURLOPT_WRITEFUNCTION, NULL);
    239       curl_easy_setopt(hInternet.handle, CURLOPT_WRITEDATA, hInternet.file);
     238      curl_share_setopt(hInternet.handle, CURLOPT_WRITEFUNCTION, NULL);
     239      curl_share_setopt(hInternet.handle, CURLOPT_WRITEDATA, hInternet.file);
    240240      hInternet.nDataLen=0;
    241241      break;
     
    250250#endif
    251251    //curl_easy_setopt(hInternet.handle,CURLOPT_COOKIE,lpszHeaders);
    252     curl_easy_setopt(hInternet.handle,CURLOPT_POST,1);
     252    curl_share_setopt(hInternet.handle,CURLOPT_POST,1);
    253253#ifdef ULINET_DEBUG
    254254    fprintf(stderr,"** (%s) %d **\n",lpszHeaders,dwHeadersLength);
    255     curl_easy_setopt(hInternet.handle,CURLOPT_VERBOSE,1);
    256 #endif
    257     curl_easy_setopt(hInternet.handle,CURLOPT_POSTFIELDS,lpszHeaders);
     255    curl_share_setopt(hInternet.handle,CURLOPT_VERBOSE,1);
     256#endif
     257    curl_share_setopt(hInternet.handle,CURLOPT_POSTFIELDS,lpszHeaders);
    258258    //curl_easy_setopt(hInternet.handle,CURLOPT_POSTFIELDSIZE,dwHeadersLength+1);
    259259    if(hInternet.header!=NULL)
    260       curl_easy_setopt(hInternet.handle,CURLOPT_HTTPHEADER,hInternet.header);
    261   }
    262 
    263   curl_easy_setopt(hInternet.handle,CURLOPT_URL,lpszUrl);
     260      curl_share_setopt(hInternet.handle,CURLOPT_HTTPHEADER,hInternet.header);
     261  }
     262
     263  curl_share_setopt(hInternet.handle,CURLOPT_URL,lpszUrl);
    264264  curl_easy_perform(hInternet.handle);
    265265  curl_easy_getinfo(hInternet.handle,CURLINFO_CONTENT_TYPE,&hInternet.mimeType);
     
    273273  memset(&CCookie[0],0,1024);
    274274#ifndef TIGER
    275   curl_easy_setopt(hInternet.handle, CURLOPT_COOKIELIST, "ALL");
     275  curl_share_setopt(hInternet.handle, CURLOPT_COOKIELIST, "ALL");
    276276#endif
    277277  return 1;
  • trunk/zoo-project/zoo-kernel/ulinet.h

    r453 r470  
    6464
    6565typedef struct {
    66   CURL *handle;
     66  CURLSH *handle;
    6767  struct curl_slist *header;
    6868  char* filename;
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