Ignore:
Timestamp:
Nov 21, 2017, 10:24:14 AM (6 years ago)
Author:
djay
Message:

HPC support update. Add inputs for create options in Gdal_Dem.

File:
1 edited

Legend:

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

    r851 r854  
    107107#include <dirent.h>
    108108#include <signal.h>
     109#include <execinfo.h>
    109110#include <unistd.h>
    110111#ifndef WIN32
     
    122123#include <time.h>
    123124#include <stdarg.h>
     125
     126#include <libxml/tree.h>
     127#include <libxml/parser.h>
     128#include <libxml/xpath.h>
     129#include <libxml/xpathInternals.h>
     130
     131#include <libxslt/xslt.h>
     132#include <libxslt/xsltInternals.h>
     133#include <libxslt/transform.h>
     134#include <libxslt/xsltutils.h>
    124135
    125136#ifndef WIN32
     
    385396sig_handler (int sig)
    386397{
     398 
    387399  char tmp[100];
    388400  const char *ssig;
     
    413425  sprintf (tmp,
    414426           _
    415            ("ZOO Kernel failed to process your request, receiving signal %d = %s"),
     427           ("ZOO Kernel failed to process your request, receiving signal %d = %s "),
    416428           sig, ssig);
    417429  errorException (NULL, tmp, "InternalError", NULL);
     
    9901002#ifdef ETC_DIR
    9911003#ifndef WIN32
    992     getcwd (ntmp, 1024);
     1004  getcwd (ntmp, 1024);
    9931005#else
    994     _getcwd (ntmp, 1024);
     1006  _getcwd (ntmp, 1024);
    9951007#endif
    9961008#endif
     
    11841196  fprintf(stderr," ** DEBUG %s %d \n",__FILE__,__LINE__);
    11851197  fflush(stderr);
    1186   dumpMap(r_inputs);
     1198  //dumpMap(r_inputs);
    11871199  fprintf(stderr," ** DEBUG %s %d \n",__FILE__,__LINE__);
    11881200  fflush(stderr);
     
    12941306  }
    12951307
     1308  dumpMap(request_inputs);
     1309
    12961310  if (strncasecmp (REQUEST, "GetCapabilities", 15) == 0)
    12971311    {
     
    13481362#ifdef META_DB
    13491363      fetchServicesFromDb(zooRegistry,m,doc,n,printGetCapabilitiesForProcess,1);
    1350       fprintf(stderr,"************************* %s %d\n\n",__FILE__,__LINE__);
    13511364      close_sql(m,0);
    13521365#endif     
     
    14301443            r_inputs = NULL;
    14311444            r_inputs = getMap (request_inputs, "version");
     1445            fprintf(stderr," ** DEBUG %s %d \n",__FILE__,__LINE__);
     1446            fflush(stderr);
    14321447            xmlNodePtr n = printWPSHeader(doc,m,"DescribeProcess",
    14331448                                          root_nodes[vid][1],(version!=NULL?version->value:"1.0.0"),1);
     
    15191534                              free (REQUEST);
    15201535                              closedir (dirp);
    1521                               xmlFreeDoc (doc);
     1536                              //xmlFreeDoc (doc);
    15221537                              xmlCleanupParser ();
    15231538                              zooXmlCleanupNs ();
     
    15501565                          addToMap (request_inputs, "metapath", tmpMap->value);
    15511566                        map *tmpMapI = getMapFromMaps (m, "lenv", "Identifier");
     1567                        /**
     1568                         * No support for dot in service name stored in metadb!?
    15521569#ifdef META_DB
    1553                         service* s2=extractServiceFromDb(m,tmpMapI->name,0);
     1570                        service* s2=extractServiceFromDb(m,tmpMapI->value,0);
    15541571                        if(s2==NULL){
    15551572#endif
     1573                        */
    15561574                          s1 = (service *) malloc (SERVICE_SIZE);
    15571575                          t = readServiceFile (m, buff1, &s1, tmpMapI->value);
     
    15851603                              free (s1);
    15861604                              closedir (dirp);
    1587                               xmlFreeDoc (doc);
     1605                              //xmlFreeDoc (doc);
    15881606                              xmlCleanupParser ();
    15891607                              zooXmlCleanupNs ();
     
    16041622                          hasVal = 1;
    16051623                          setMapInMaps (m, "lenv", "level", "0");
     1624                          /*
    16061625#ifdef META_DB
    16071626                        }
    16081627#endif
     1628                          */
    16091629                      }
    16101630                    else
     
    16881708                                      free (REQUEST);
    16891709                                      closedir (dirp);
    1690                                       xmlFreeDoc (doc);
     1710                                      //xmlFreeDoc (doc);
    16911711                                      xmlCleanupParser ();
    16921712                                      zooXmlCleanupNs ();
     
    17361756                        free (REQUEST);
    17371757                        closedir (dirp);
    1738                         xmlFreeDoc (doc);
     1758                        //xmlFreeDoc (doc);
    17391759                        xmlCleanupParser ();
    17401760                        zooXmlCleanupNs ();
     
    18431863  }
    18441864  s1 = NULL;
    1845   if(postRequest!=NULL)
    1846     setMapInMaps (m, "lenv", "xrequest", postRequest->value);
    1847  
     1865 
    18481866  r_inputs = getMap (request_inputs, "Identifier");
    18491867  map* import = getMapFromMaps (m, IMPORTSERVICE, r_inputs->value);
     
    18801898  fprintf(stderr,"CONNECTING METADB!\n");
    18811899  //FAILED CONNECTING DB
    1882   if(getMapFromMaps(m,"lenv","dbIssue")!=NULL){
     1900  if(getMapFromMaps(m,"lenv","dbIssue")!=NULL || metadb_id<0){
    18831901    fprintf(stderr,"ERROR CONNECTING METADB\n");
    18841902  }
    1885   s1=extractServiceFromDb(m,r_inputs->value,0);
     1903  if(metadb_id>=0)
     1904    s1=extractServiceFromDb(m,r_inputs->value,0);
    18861905  //close_sql(m,0);
    18871906  if(s1!=NULL){
     
    21812200    {
    21822201      int hasValidCookie = -1;
    2183       char *tcook = zStrdup (cgiCookie);
     2202      char *tcook = originalCookie = zStrdup (cgiCookie);
     2203      //fprintf(stderr,">>>>> %s %d %s\n",__FILE__,__LINE__,tcook );
    21842204      char *tmp = NULL;
    21852205      map *testing = getMapFromMaps (m, "main", "cookiePrefix");
     2206      parseCookie(&m,originalCookie);
    21862207      if (testing == NULL)
    21872208        {
     
    21972218        {
    21982219          char *token, *saveptr;
    2199           token = strtok_r (cgiCookie, ";", &saveptr);
     2220          token = strtok_r (tcook, ";", &saveptr);
    22002221          while (token != NULL)
    22012222            {
     
    22442265          if (istat == 0 && file_status.st_size > 0)
    22452266            {
     2267              int saved_stdout = dup (fileno (stdout));
     2268              dup2 (fileno (stderr), fileno (stdout));
    22462269              conf_read (session_file_path, tmpSess);
    22472270              addMapsToMaps (&m, tmpSess);
    22482271              freeMaps (&tmpSess);
     2272              fflush(stdout);
     2273              dup2 (saved_stdout, fileno (stdout));
     2274              close(saved_stdout);
    22492275            }
    22502276          free (tmpSess);
     
    22732299      char* tmpName=zStrdup(s);
    22742300      char* tmpValue=strstr(s,"=")+1;
    2275       char* tmpName1=(char*)malloc((1+(len-strlen(tmpValue)))*sizeof(char));
    2276       snprintf(tmpName1,(len-strlen(tmpValue))+1,"%s",tmpName);
     2301      char* tmpName1=(char*)malloc((1+(len-(strlen(tmpValue)+1)))*sizeof(char));
     2302      snprintf(tmpName1,(len-strlen(tmpValue)),"%s",tmpName);
    22772303      if(_tmpMaps->content == NULL)
    22782304        _tmpMaps->content = createMap (tmpName1,tmpValue);
     
    22852311  }
    22862312  if(_tmpMaps->content!=NULL && getMap(_tmpMaps->content,"HTTP_COOKIE")!=NULL){
    2287     /*map* tmpMap1=getMap(_tmpMaps->content,"HTTP_COOKIE");
    2288     free(tmpMap1->value);
    2289     tmpMap1->value=zStrdup(cgiCookie);*/
    2290     fprintf(stderr,"[%s]\n",cgiCookie);
    22912313    addToMap(_tmpMaps->content,"HTTP_COOKIE1",&cgiCookie[0]);
    2292     dumpMap(_tmpMaps->content);
    22932314  }
    22942315  addMapsToMaps (&m, _tmpMaps);
    22952316  freeMaps (&_tmpMaps);
    22962317  free (_tmpMaps);
    2297 
     2318  if(postRequest!=NULL)
     2319    setMapInMaps (m, "renv", "xrequest", postRequest->value);
     2320  //dumpMaps(m);
    22982321#ifdef WIN32
    22992322  char *cgiSidL = NULL;
     
    23342357                                  "ZooWPSClient\0",
    23352358                                  INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);*/
    2336 
    23372359      if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
    23382360        freeService (&s1);
     
    23502372        return -1;
    23512373      }
    2352       fprintf(stderr,"*************************\n\n");
    2353       //fprintf(stderr,"%s \n",json_object_to_json_string_ext(mapsToJson(request_input_real_format),JSON_C_TO_STRING_PLAIN));
    2354       fprintf(stderr,"*************************\n\n");
    23552374      loadServiceAndRun (&m, s1, request_inputs, &request_input_real_format,
    23562375                         &request_output_real_format, &eres);
    2357 #ifdef RELY_ON_DB
     2376
    23582377#ifdef META_DB
    2359       close_sql(m,1);
     2378      close_sql(m,0);     
     2379#endif     
     2380
     2381      /*#ifdef RELY_ON_DB
     2382      //close_sql(m,1);
    23602383      //end_sql();
    2361 #endif
    2362       close_sql(m,0);
    2363 #endif     
     2384      #endif*/
    23642385    }
    23652386  else
     
    23872408        }
    23882409#endif
     2410      //InternetCloseHandle (&hInternet);
    23892411      if (pid > 0)
    23902412        {
     
    24112433          setMapInMaps (m, "lenv", "async","true");
    24122434          map* r_inputs1 = createMap("ServiceName", s1->name);
     2435
     2436          /*hInternet = InternetOpen (
     2437#ifndef WIN32
     2438                                    (LPCTSTR)
     2439#endif
     2440                                    "ZooWPSClient\0",
     2441                                    INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
     2442#ifndef WIN32
     2443          if (!CHECK_INET_HANDLE (hInternet))
     2444            fprintf (stderr, "WARNING : hInternet handle failed to initialize");
     2445            #endif*/
    24132446
    24142447          // Create the filename for the result file (.res)
     
    25252558          invokeCallback(m,request_input_real_format,NULL,1,0);
    25262559          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     2560          dumpMaps(request_output_real_format);
    25272561          if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
    25282562            freeService (&s1);
    25292563            free (s1);
     2564            fflush (stdout);
     2565            fflush (stderr);
    25302566            fclose (f0);
    25312567            fclose (f1);
    25322568            if(dumpBackFinalFile(m,fbkp,fbkp1)<0)
    25332569              return -1;
     2570            //dumpBackFinalFile(m,fbkp,fbkp1);
     2571#ifndef RELY_ON_DB
     2572            dumpMapsToFile(bmap,fbkpres,1);
     2573            removeShmLock (m, 1);
     2574#else
     2575            recordResponse(m,fbkp1);
     2576            fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     2577            invokeCallback(m,NULL,NULL,7,0);
     2578            fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     2579#endif
    25342580            unlink (fbkpid);
    25352581            unhandleStatus (m);
     2582#ifdef RELY_ON_DB
     2583#ifdef META_DB
     2584            cleanupCallbackThreads();
     2585            close_sql(m,1);
     2586            //end_sql();
     2587#endif
     2588            close_sql(m,0);
     2589#endif
    25362590            freeMaps (&m);
    25372591            free (m);
     
    25442598            freeMaps (&tmpmaps);
    25452599            free (tmpmaps);
    2546             fflush (stdout);
    2547             fflush (stderr);
    25482600            return -1;
    25492601          }
     2602          dumpMaps(request_output_real_format);
    25502603          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    25512604          invokeCallback(m,request_input_real_format,NULL,1,1);
    25522605          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    2553           setMapInMaps(m,"lenv","ds_nb","1");
    2554           loadServiceAndRun (&m, s1, request_inputs,
    2555                              &request_input_real_format,
    2556                              &request_output_real_format, &eres);
     2606          if(getMapFromMaps(m,"lenv","mapError")!=NULL){
     2607                setMapInMaps(m,"lenv","message",_("Issue with geographic data"));
     2608                invokeCallback(m,NULL,NULL,7,0);
     2609                eres=-1;//SERVICE_FAILED;
     2610          }else{
     2611            setMapInMaps(m,"lenv","ds_nb","0");
     2612            close_sql(m,0);
     2613            loadServiceAndRun (&m, s1, request_inputs,
     2614                               &request_input_real_format,
     2615                               &request_output_real_format, &eres);
     2616            setMapInMaps(m,"lenv","ds_nb","2");
     2617          }
    25572618        }
    25582619      else
     
    25732634  fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__);
    25742635#endif
     2636fflush(stdout);
     2637rewind(stdout);
    25752638  if (eres != -1)
    25762639    outputResponse (s1, request_input_real_format,
     
    25952658  if (((int) getpid ()) != cpid || cgiSid != NULL)
    25962659    {
    2597       fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     2660      if (eres == SERVICE_SUCCEEDED)
     2661        invokeCallback(m,NULL,request_output_real_format,5,1);
     2662
    25982663      fflush(stderr);
    2599       invokeCallback(m,NULL,request_output_real_format,5,1);
    2600       fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    2601       fflush(stderr);
     2664      fflush(stdout);
    26022665
    26032666      fclose (stdout);
     
    26192682        setMapInMaps(m,"lenv","fstate",wpsStatus[0]);
    26202683        break;
    2621       }     
     2684      }
    26222685#ifndef RELY_ON_DB
    26232686      dumpMapsToFile(bmap,fbkpres,1);
     
    26252688#else
    26262689      recordResponse(m,fbkp1);
    2627       fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    2628       invokeCallback(m,NULL,request_output_real_format,6,0);
    2629       fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     2690      if (eres == SERVICE_SUCCEEDED)
     2691        invokeCallback(m,NULL,request_output_real_format,6,0);
    26302692#endif
    26312693      freeMaps(&bmap);
     
    26372699      cleanupCallbackThreads();
    26382700      close_sql(m,1);
    2639       //end_sql();
    26402701#endif
    26412702      close_sql(m,0);
    2642 #endif
    2643       unlink (flog);
     2703      end_sql();
     2704#endif
    26442705      free(fbkpid);
    26452706      free(fbkpres);
    2646       free (flog);           
    26472707      free (fbkp1);
    26482708      // free (tmps1); // tmps1 is stack memory and should not be freed
     
    26532713      fflush(stderr);
    26542714      fclose (stderr);
     2715      unlink (flog);
     2716      free (flog);
    26552717    }
    26562718  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