Changeset 554 for trunk/zoo-project


Ignore:
Timestamp:
Feb 5, 2015, 7:17:31 PM (10 years ago)
Author:
knut
Message:

Changed the WIN32 version of function zGettimeofday. Changed return type for getShmLockId (WIN32). Changed type of _HINTERNET.mimeType from unsigned char* to char*. Fixed interconnected memory issues in functions getKeyValue and getShmLockId (WIN32). Added code to transfer the correct unique process identifier (usid) to background processes (applies to WIN32 version).

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

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/service.h

    r550 r554  
    4646  long tv_usec; /* and microseconds */
    4747};
    48 void zGettimeofday(struct mstimeval* tp, void* tzp)
     48static int zGettimeofday(struct ztimeval* tp, void* tzp)
    4949{
     50  if (tp == 0) {
     51    return -1;
     52  }
     53 
    5054  struct _timeb theTime;
    5155  _ftime(&theTime);
    5256  tp->tv_sec = theTime.time;
    5357  tp->tv_usec = theTime.millitm * 1000;
     58 
     59  return 0; // The gettimeofday() function shall return 0 on success
    5460}
    5561#else
  • trunk/zoo-project/zoo-kernel/service_internal.c

    r550 r554  
    124124#define SHMEMSIZE 4096
    125125
    126 char* getKeyValue(maps* conf){
    127   if(conf==NULL)
    128      return "700666";
     126size_t getKeyValue(maps* conf, char* key, size_t length){
     127 
     128  if(conf==NULL) {
     129         strncpy(key, "700666", length);
     130         return strlen(key);
     131  }
     132 
    129133  map *tmpMap=getMapFromMaps(conf,"lenv","lid");
    130134  if(tmpMap==NULL)
    131     tmpMap=getMapFromMaps(conf,"lenv","usid");
    132   char* key="-1";
     135        tmpMap=getMapFromMaps(conf,"lenv","usid");
     136
    133137  if(tmpMap!=NULL){
    134     key=(char*)malloc((strlen(tmpMap->value)+9)*sizeof(char));
    135     sprintf(key,"zoo_sem_%s",tmpMap->value);
    136   }
    137   return key;
    138 }
    139 
    140 
     138        snprintf(key, length, "zoo_sem_%s", tmpMap->value);     
     139  }
     140  else {
     141        strncpy(key, "-1", length); 
     142  }
     143  return strlen(key);
     144}
    141145semid getShmLockId(maps* conf, int nsems){
    142146    semid sem_id;
    143     char* key=getKeyValue(conf);
     147        char key[MAX_PATH];
     148        getKeyValue(conf, key, MAX_PATH);
    144149   
    145150    sem_id = CreateSemaphore( NULL, nsems, nsems+1, key);
    146151    if(sem_id==NULL){
    147       if(strncmp(key,"-1",2)!=0)
    148         free(key);
     152
    149153#ifdef DEBUG
    150154      fprintf(stderr,"Semaphore failed to create ! %s\n",GetLastError());
     
    155159    fprintf(stderr,"%s Accessed !\n",key);
    156160#endif
    157     if(strncmp(key,"-1",2)!=0)
    158       free(key);
     161
    159162    return sem_id;
    160163}
     
    33353338              mimeType=strdup("none");
    33363339            else
    3337               mimeType=strdup((char*)hInternet->ihandle[index].mimeType);
     3340                  mimeType=strdup(hInternet->ihandle[index].mimeType);       
    33383341           
    33393342            map* tmpMap=getMapOrFill(&content->content,vname,"");
  • trunk/zoo-project/zoo-kernel/ulinet.h

    r507 r554  
    8080  size_t size;
    8181  unsigned char *pabyData;
    82   unsigned char *mimeType;
     82  char *mimeType;
    8383  int hasCacheFile;
    8484  int nDataLen;
  • trunk/zoo-project/zoo-kernel/zoo_loader.c

    r516 r554  
    3737#include <unistd.h>
    3838#include "service_internal.h"
     39
     40
    3941#ifdef WIN32
    4042#include "windows.h"
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r550 r554  
    781781  fprintf (stderr, "REQUEST IS : %s \n", tmp);
    782782#endif
     783
     784  map* usid = getMapFromMaps (m, "lenv", "usid");
     785  if (usid != NULL && usid->value != NULL) {
     786    SetEnvironmentVariable("USID", TEXT (usid->value));
     787  }
     788
    783789  SetEnvironmentVariable ("CGISID", TEXT (sid->value));
    784790  SetEnvironmentVariable ("QUERY_STRING", TEXT (tmpq));
     
    824830
    825831#ifndef USE_GDB
     832#ifndef WIN32
    826833  signal (SIGCHLD, SIG_IGN);
     834#endif 
    827835  signal (SIGSEGV, sig_handler);
    828836  signal (SIGTERM, sig_handler);
     
    32033211  _tmpMaps->name = zStrdup ("lenv");
    32043212  char tmpBuff[100];
    3205   int lid = getShmLockId (NULL, 1);
     3213  semid lid = getShmLockId (NULL, 1);
    32063214  lockShm (lid);
    32073215  struct ztimeval tp;
     
    33073315  if (getenv ("CGISID") != NULL)
    33083316    addToMap (request_inputs, "cgiSid", getenv ("CGISID"));
     3317
     3318  char* usidp;
     3319  if ( (usidp = getenv("USID")) != NULL ) {
     3320    setMapInMaps (m, "lenv", "usid", usidp);
     3321  }
     3322
    33093323  map *test1 = getMap (request_inputs, "cgiSid");
    33103324  if (test1 != NULL)
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