Changeset 865 for branches/prototype-v0/zoo-project/zoo-kernel
- Timestamp:
- Feb 8, 2018, 12:37:09 PM (7 years ago)
- Location:
- branches/prototype-v0/zoo-project/zoo-kernel
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/caching.c
r863 r865 480 480 free(length); 481 481 } 482 dumpMaps(*in);483 482 return 0; 484 483 } -
branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c
r863 r865 424 424 char *req=(char*)malloc((flen+strlen(schema->value)+strlen(sid->value)+66)*sizeof(char)); 425 425 sprintf(req,"UPDATE %s.services set request_execute_content=$$%s$$ WHERE uuid=$$%s$$",schema->value,fcontent,sid->value); 426 #ifdef RELY_ON_DB 426 427 execSql(conf,1,req); 428 #endif 427 429 free(fcontent); 428 430 free(req); -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c
r862 r865 1381 1381 myMap->transparent=1; 1382 1382 1383 /**1384 * Set metadata extracted from main.cfg file maps1385 */1386 maps* cursor=conf;1387 map* correspondance=getCorrespondance();1388 while(cursor!=NULL){1389 map* _cursor=cursor->content;1390 map* vMap;1391 while(_cursor!=NULL){1392 if((vMap=getMap(correspondance,_cursor->name))!=NULL){1393 if (msInsertHashTable(&(myMap->web.metadata), vMap->value, _cursor->value) == NULL){1394 #ifdef DEBUGMS1395 fprintf(stderr,"Unable to add metadata");1396 #endif1397 return;1398 }1399 }1400 _cursor=_cursor->next;1401 }1402 cursor=cursor->next;1403 }1404 freeMap(&correspondance);1405 free(correspondance);1406 1407 1383 /* 1408 1384 * Set mapserver PROJ_LIB/GDAL_DATA or any other config parameter from … … 1445 1421 } 1446 1422 msInsertHashTable(&(myMap->web.metadata), "ows_srs", "EPSG:4326"); 1423 1424 /** 1425 * Set metadata extracted from main.cfg file maps 1426 */ 1427 maps* cursor=conf; 1428 map* correspondance=getCorrespondance(); 1429 while(cursor!=NULL){ 1430 if(strstr(cursor->name,"_help")==NULL){ 1431 map* _cursor=cursor->content; 1432 map* vMap; 1433 while(_cursor!=NULL){ 1434 if((vMap=getMap(correspondance,_cursor->name))!=NULL){ 1435 if (msInsertHashTable(&(myMap->web.metadata), vMap->value, _cursor->value) == NULL){ 1436 #ifdef DEBUGMS 1437 fprintf(stderr,"Unable to add metadata"); 1438 #endif 1439 freeMap(&correspondance); 1440 free(correspondance); 1441 return; 1442 } 1443 } 1444 _cursor=_cursor->next; 1445 } 1446 } 1447 cursor=cursor->next; 1448 } 1449 freeMap(&correspondance); 1450 free(correspondance); 1451 1447 1452 1448 1453 if(tryOgr(conf,outputs,myMap)<0) -
branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.c
r863 r865 379 379 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(msg->value)+strlen(p->value)+strlen(sid->value)+64+1)*sizeof(char)); 380 380 sprintf(sqlQuery,"UPDATE %s.services set status=$$%s$$,message=$$%s$$ where uuid=$$%s$$;",schema->value,p->value,msg->value,sid->value); 381 if( zoo_ ds_nb == 0){381 if( zoo_DS == NULL || zoo_DS[zoo_ds_nb-1]==NULL ){ 382 382 init_sql(conf); 383 383 zoo_ds_nb++; 384 384 } 385 execSql(conf,0,sqlQuery); 386 cleanUpResultSet(conf,0); 387 close_sql(conf,0); 388 free(sqlQuery); 389 setMapInMaps(conf,"lenv","ds_nb","0"); 385 execSql(conf,zoo_ds_nb-1,sqlQuery); 386 cleanUpResultSet(conf,zoo_ds_nb-1); 387 free(sqlQuery); 390 388 return 0; 391 389 } -
branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.h
r839 r865 28 28 #ifdef META_DB 29 29 #include "ogrsf_frmts.h" 30 #include "ogr_p.h" 30 31 #if GDAL_VERSION_MAJOR >= 2 31 32 #include <gdal_priv.h> … … 36 37 #include "service_internal.h" 37 38 39 #ifdef META_DB 40 extern "C" 41 #if GDAL_VERSION_MAJOR >=2 42 GDALDataset 43 #else 44 OGRDataSource 45 #endif 46 **zoo_DS; 47 #endif 48 38 49 #ifdef __cplusplus 39 50 extern "C" { 40 51 #endif 52 41 53 42 54 #ifdef META_DB -
branches/prototype-v0/zoo-project/zoo-kernel/zoo_service_loader.c
r861 r865 1558 1558 /** 1559 1559 * No support for dot in service name stored in metadb!? 1560 #ifdef META_DB1561 service* s2=extractServiceFromDb(m,tmpMapI->value,0);1562 if(s2==NULL){1563 #endif1560 #ifdef META_DB 1561 service* s2=extractServiceFromDb(m,tmpMapI->value,0); 1562 if(s2==NULL){ 1563 #endif 1564 1564 */ 1565 s1 = (service *) malloc (SERVICE_SIZE); 1566 t = readServiceFile (m, buff1, &s1, tmpMapI->value); 1567 if (t < 0) 1568 { 1569 map *tmp00 = getMapFromMaps (m, "lenv", "message"); 1570 char tmp01[1024]; 1571 if (tmp00 != NULL) 1572 sprintf (tmp01, 1573 _ 1574 ("Unable to parse the ZCFG file for the following ZOO-Service: %s. Message: %s"), 1575 tmps, tmp00->value); 1576 else 1577 sprintf (tmp01, 1578 _ 1579 ("Unable to parse the ZCFG file for the following ZOO-Service: %s."), 1580 tmps); 1581 dup2 (saved_stdout, fileno (stdout)); 1582 errorException (m, tmp01, "InvalidParameterValue", 1583 "identifier"); 1584 freeMaps (&m); 1585 free (m); 1586 if(zooRegistry!=NULL){ 1587 freeRegistry(&zooRegistry); 1588 free(zooRegistry); 1589 } 1590 free (REQUEST); 1591 free (corig); 1592 free (orig); 1593 free (SERVICE_URL); 1594 free (s1); 1595 closedir (dirp); 1596 //xmlFreeDoc (doc); 1597 xmlCleanupParser (); 1598 zooXmlCleanupNs (); 1599 return 1; 1565 s1 = (service *) malloc (SERVICE_SIZE); 1566 t = readServiceFile (m, buff1, &s1, tmpMapI->value); 1567 if (t < 0) 1568 { 1569 map *tmp00 = getMapFromMaps (m, "lenv", "message"); 1570 char tmp01[1024]; 1571 if (tmp00 != NULL) 1572 sprintf (tmp01, 1573 _ 1574 ("Unable to parse the ZCFG file for the following ZOO-Service: %s. Message: %s"), 1575 tmps, tmp00->value); 1576 else 1577 sprintf (tmp01, 1578 _ 1579 ("Unable to parse the ZCFG file for the following ZOO-Service: %s."), 1580 tmps); 1581 dup2 (saved_stdout, fileno (stdout)); 1582 errorException (m, tmp01, "InvalidParameterValue", 1583 "identifier"); 1584 freeMaps (&m); 1585 free (m); 1586 if(zooRegistry!=NULL){ 1587 freeRegistry(&zooRegistry); 1588 free(zooRegistry); 1600 1589 } 1601 #ifdef DEBUG 1602 dumpService (s1); 1603 #endif 1604 inheritance(zooRegistry,&s1); 1590 free (REQUEST); 1591 free (corig); 1592 free (orig); 1593 free (SERVICE_URL); 1594 free (s1); 1595 closedir (dirp); 1596 //xmlFreeDoc (doc); 1597 xmlCleanupParser (); 1598 zooXmlCleanupNs (); 1599 return 1; 1600 } 1601 #ifdef DEBUG 1602 dumpService (s1); 1603 #endif 1604 inheritance(zooRegistry,&s1); 1605 1605 #ifdef USE_HPC 1606 1607 #endif 1608 1609 1610 1611 1612 1613 1614 1615 1616 #ifdef META_DB1617 }1618 #endif1619 1606 addNestedOutputs(&s1); 1607 #endif 1608 printDescribeProcessForProcess (zooRegistry, m, doc, n, s1); 1609 freeService (&s1); 1610 free (s1); 1611 s1 = NULL; 1612 scount++; 1613 hasVal = 1; 1614 setMapInMaps (m, "lenv", "level", "0"); 1615 /* 1616 #ifdef META_DB 1617 } 1618 #endif 1619 */ 1620 1620 } 1621 1621 else … … 1640 1640 }else /*TOTO*/{ 1641 1641 #endif 1642 memset (buff, 0, 256);1643 snprintf (buff, 256, "%s.zcfg", corig);1644 memset (buff1, 0, 1024);1642 memset (buff, 0, 256); 1643 snprintf (buff, 256, "%s.zcfg", corig); 1644 memset (buff1, 0, 1024); 1645 1645 #ifdef DEBUG 1646 1646 printf ("\n#######%s\n########\n", buff); … … 1774 1774 #ifdef META_DB 1775 1775 close_sql(m,0); 1776 1776 //end_sql(); 1777 1777 #endif 1778 1778 return 0; … … 1782 1782 map* version=getMapFromMaps(m,"main","rversion"); 1783 1783 int vid=getVersionId(version->value); 1784 1785 1784 int len = 0; 1785 int j = 0; 1786 1786 for(j=0;j<nbSupportedRequests;j++){ 1787 1787 if(requests[vid][j]!=NULL) … … 1858 1858 map* import = getMapFromMaps (m, IMPORTSERVICE, r_inputs->value); 1859 1859 if (import != NULL && import->value != NULL) { 1860 1861 1862 1860 strncpy(tmps1, import->value, 1024); 1861 setMapInMaps (m, "lenv", "Identifier", r_inputs->value); 1862 setMapInMaps (m, "lenv", "oIdentifier", r_inputs->value); 1863 1863 } 1864 1864 else { … … 1905 1905 }else /* Not found in MetaDB */{ 1906 1906 #endif 1907 s1 = (service *) malloc (SERVICE_SIZE); 1908 if (s1 == NULL) 1909 { 1910 freeMaps (&m); 1911 free (m); 1912 if(zooRegistry!=NULL){ 1913 freeRegistry(&zooRegistry); 1914 free(zooRegistry); 1907 s1 = (service *) malloc (SERVICE_SIZE); 1908 if (s1 == NULL) 1909 { 1910 freeMaps (&m); 1911 free (m); 1912 if(zooRegistry!=NULL){ 1913 freeRegistry(&zooRegistry); 1914 free(zooRegistry); 1915 } 1916 free (REQUEST); 1917 free (SERVICE_URL); 1918 return errorException (m, _("Unable to allocate memory"), 1919 "InternalError", NULL); 1915 1920 } 1916 free (REQUEST); 1917 free (SERVICE_URL); 1918 return errorException (m, _("Unable to allocate memory"), 1919 "InternalError", NULL); 1920 } 1921 1922 int saved_stdout = dup (fileno (stdout)); 1923 dup2 (fileno (stderr), fileno (stdout)); 1924 t = readServiceFile (m, tmps1, &s1, r_inputs->value); 1925 inheritance(zooRegistry,&s1); 1921 1922 int saved_stdout = dup (fileno (stdout)); 1923 dup2 (fileno (stderr), fileno (stdout)); 1924 t = readServiceFile (m, tmps1, &s1, r_inputs->value); 1925 inheritance(zooRegistry,&s1); 1926 1926 #ifdef USE_HPC 1927 addNestedOutputs(&s1);1928 #endif 1929 if(zooRegistry!=NULL){1930 freeRegistry(&zooRegistry);1931 free(zooRegistry);1932 }1933 fflush (stdout);1934 dup2 (saved_stdout, fileno (stdout));1935 if (t < 0)1936 {1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 }1951 close (saved_stdout);1927 addNestedOutputs(&s1); 1928 #endif 1929 if(zooRegistry!=NULL){ 1930 freeRegistry(&zooRegistry); 1931 free(zooRegistry); 1932 } 1933 fflush (stdout); 1934 dup2 (saved_stdout, fileno (stdout)); 1935 if (t < 0) 1936 { 1937 char *tmpMsg = (char *) malloc (2048 + strlen (r_inputs->value)); 1938 sprintf (tmpMsg, 1939 _ 1940 ("The value for <identifier> seems to be wrong (%s). Please specify one of the processes in the list returned by a GetCapabilities request."), 1941 r_inputs->value); 1942 errorException (m, tmpMsg, "InvalidParameterValue", "identifier"); 1943 free (tmpMsg); 1944 free (s1); 1945 freeMaps (&m); 1946 free (m); 1947 free (REQUEST); 1948 free (SERVICE_URL); 1949 return 0; 1950 } 1951 close (saved_stdout); 1952 1952 #ifdef META_DB 1953 1953 } … … 2329 2329 fprintf (stderr, "\nPID : %d\n", cpid); 2330 2330 #endif 2331 2332 2331 #ifndef WIN32 2333 2332 pid = fork (); … … 2335 2334 if (cgiSid == NULL) 2336 2335 { 2337 2338 2339 2340 2336 createProcess (m, request_inputs, s1, NULL, cpid, 2337 request_input_real_format, 2338 request_output_real_format); 2339 pid = cpid; 2341 2340 } 2342 2341 else 2343 2342 { 2344 2345 2343 pid = 0; 2344 cpid = atoi (cgiSid); 2346 2345 updateStatus(m,0,_("Initializing")); 2347 2346 } 2348 2347 #endif 2349 //InternetCloseHandle (&hInternet);2350 2348 if (pid > 0) 2351 2352 / **2353 *dady :2354 *set status to SERVICE_ACCEPTED2355 */2356 #ifdef DEBUG 2357 2358 2359 #endif 2360 2361 2349 { 2350 // 2351 // dady : 2352 // set status to SERVICE_ACCEPTED 2353 // 2354 #ifdef DEBUG 2355 fprintf (stderr, "father pid continue (origin %d) %d ...\n", cpid, 2356 getpid ()); 2357 #endif 2358 eres = SERVICE_ACCEPTED; 2359 } 2362 2360 else if (pid == 0) 2363 2364 / **2365 *son : have to close the stdout, stdin and stderr to let the parent2366 *process answer to http client.2367 */2361 { 2362 // 2363 // son : have to close the stdout, stdin and stderr to let the parent 2364 // process answer to http client. 2365 // 2368 2366 map* usid = getMapFromMaps (m, "lenv", "uusid"); 2369 map* tmpm = getMapFromMaps (m, "lenv", "osid"); 2370 int cpid = atoi (tmpm->value); 2371 r_inputs = getMapFromMaps (m, "main", "tmpPath"); 2372 setMapInMaps (m, "lenv", "async","true"); 2367 map* tmpm = getMapFromMaps (m, "lenv", "osid"); 2368 int cpid = atoi (tmpm->value); 2369 pid=cpid; 2370 r_inputs = getMapFromMaps (m, "main", "tmpPath"); 2371 setMapInMaps (m, "lenv", "async","true"); 2373 2372 map* r_inputs1 = createMap("ServiceName", s1->name); 2374 2373 2375 2374 // Create the filename for the result file (.res) 2376 2377 2378 2379 2380 2375 fbkpres = 2376 (char *) 2377 malloc ((strlen (r_inputs->value) + 2378 strlen (usid->value) + 7) * sizeof (char)); 2379 sprintf (fbkpres, "%s/%s.res", r_inputs->value, usid->value); 2381 2380 bmap = createMaps("status"); 2382 2381 bmap->content=createMap("usid",usid->value); … … 2385 2384 2386 2385 // Create PID file referencing the OS process identifier 2387 2388 2389 2390 2391 2386 fbkpid = 2387 (char *) 2388 malloc ((strlen (r_inputs->value) + 2389 strlen (usid->value) + 7) * sizeof (char)); 2390 sprintf (fbkpid, "%s/%s.pid", r_inputs->value, usid->value); 2392 2391 setMapInMaps (m, "lenv", "file.pid", fbkpid); 2393 2392 2394 2393 f0 = freopen (fbkpid, "w+",stdout); 2395 2394 printf("%d",getpid()); 2396 2395 fflush(stdout); 2397 2396 2398 2397 // Create SID file referencing the semaphore name 2399 2400 2401 2402 2403 2398 fbkp = 2399 (char *) 2400 malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) + 2401 strlen (usid->value) + 7) * sizeof (char)); 2402 sprintf (fbkp, "%s/%s.sid", r_inputs->value, usid->value); 2404 2403 setMapInMaps (m, "lenv", "file.sid", fbkp); 2405 2404 FILE* f2 = freopen (fbkp, "w+",stdout); 2406 2405 printf("%s",tmpm->value); 2407 2406 fflush(f2); 2408 2407 free(fbkp); 2409 2408 2410 2411 2412 2413 2414 2415 2409 fbkp = 2410 (char *) 2411 malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) + 2412 strlen (usid->value) + 7) * sizeof (char)); 2413 sprintf (fbkp, "%s/%s_%s.xml", r_inputs->value, r_inputs1->value, 2414 usid->value); 2416 2415 setMapInMaps (m, "lenv", "file.responseInit", fbkp); 2417 2418 2419 2420 2421 2422 2416 flog = 2417 (char *) 2418 malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) + 2419 strlen (usid->value) + 13) * sizeof (char)); 2420 sprintf (flog, "%s/%s_%s_error.log", r_inputs->value, 2421 r_inputs1->value, usid->value); 2423 2422 setMapInMaps (m, "lenv", "file.log", flog); 2424 2423 #ifdef DEBUG 2425 2426 2427 2428 2429 #endif 2430 2431 2424 fprintf (stderr, "RUN IN BACKGROUND MODE \n"); 2425 fprintf (stderr, "son pid continue (origin %d) %d ...\n", cpid, 2426 getpid ()); 2427 fprintf (stderr, "\nFILE TO STORE DATA %s\n", r_inputs->value); 2428 #endif 2429 freopen (flog, "w+", stderr); 2430 fflush (stderr); 2432 2431 f0 = freopen (fbkp, "w+", stdout); 2433 2432 rewind (stdout); … … 2439 2438 recordServiceStatus(m); 2440 2439 #endif 2441 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);2442 2440 invokeCallback(m,NULL,NULL,0,0); 2443 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);2444 2441 if(vid==0){ 2445 / **2446 *set status to SERVICE_STARTED and flush stdout to ensure full2447 *content was outputed (the file used to store the ResponseDocument).2448 * The rewind stdout to restart writing from the bgining of the file,2449 * this waythe data will be updated at the end of the process run.2450 */2442 // 2443 // set status to SERVICE_STARTED and flush stdout to ensure full 2444 // content was outputed (the file used to store the ResponseDocument). 2445 // Then, rewind stdout to restart writing from the begining of the file. 2446 // This way, the data will be updated at the end of the process run. 2447 // 2451 2448 printProcessResponse (m, request_inputs, cpid, s1, r_inputs1->value, 2452 2449 SERVICE_STARTED, request_input_real_format, … … 2458 2455 } 2459 2456 2460 2461 2462 2463 2464 2465 2466 2467 2457 fflush (stderr); 2458 2459 fbkp1 = 2460 (char *) 2461 malloc ((strlen (r_inputs->value) + strlen (r_inputs1->value) + 2462 strlen (usid->value) + 13) * sizeof (char)); 2463 sprintf (fbkp1, "%s/%s_final_%s.xml", r_inputs->value, 2464 r_inputs1->value, usid->value); 2468 2465 setMapInMaps (m, "lenv", "file.responseFinal", fbkp1); 2469 2466 2470 2467 f1 = freopen (fbkp1, "w+", stdout); 2471 2468 2472 2469 map* serviceTypeMap=getMap(s1->content,"serviceType"); … … 2474 2471 setMapInMaps (m, "lenv", "serviceType", serviceTypeMap->value); 2475 2472 2476 2477 2478 2479 2480 2473 char *flenv = 2474 (char *) 2475 malloc ((strlen (r_inputs->value) + 2476 strlen (usid->value) + 12) * sizeof (char)); 2477 sprintf (flenv, "%s/%s_lenv.cfg", r_inputs->value, usid->value); 2481 2478 maps* lenvMaps=getMaps(m,"lenv"); 2482 2479 dumpMapsToFile(lenvMaps,flenv,0); 2483 2480 free(flenv); 2484 2481 2485 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);2486 2482 invokeCallback(m,request_input_real_format,NULL,1,0); 2487 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);2488 //dumpMaps(request_output_real_format);2489 2483 if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){ 2490 2484 freeService (&s1); … … 2496 2490 if(dumpBackFinalFile(m,fbkp,fbkp1)<0) 2497 2491 return -1; 2498 //dumpBackFinalFile(m,fbkp,fbkp1);2499 2492 #ifndef RELY_ON_DB 2500 2493 dumpMapsToFile(bmap,fbkpres,1); … … 2502 2495 #else 2503 2496 recordResponse(m,fbkp1); 2504 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);2505 2497 invokeCallback(m,NULL,NULL,7,0); 2506 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);2507 2498 #endif 2508 2499 unlink (fbkpid); … … 2512 2503 cleanupCallbackThreads(); 2513 2504 close_sql(m,1); 2514 //end_sql();2515 2505 #endif 2516 2506 close_sql(m,0); … … 2528 2518 return -1; 2529 2519 } 2530 2531 2532 2533 2520 if(getMapFromMaps(m,"lenv","mapError")!=NULL){ 2521 setMapInMaps(m,"lenv","message",_("Issue with geographic data")); 2522 invokeCallback(m,NULL,NULL,7,0); 2523 eres=-1;//SERVICE_FAILED; 2534 2524 }else{ 2535 setMapInMaps(m,"lenv","ds_nb","0");2536 close_sql(m,0);2537 2525 loadServiceAndRun (&m, s1, request_inputs, 2538 2526 &request_input_real_format, 2539 2527 &request_output_real_format, &eres); 2540 setMapInMaps(m,"lenv","ds_nb","2");2541 2528 } 2542 2529 } 2543 2530 else 2544 2531 { … … 2547 2534 * error response here !!! 2548 2535 */ 2549 2550 2551 2536 eres = -1; 2537 errorException (m, _("Unable to run the child process properly"), 2538 "InternalError", NULL); 2552 2539 } 2553 2540 } … … 2607 2594 setMapInMaps(m,"lenv","fstate",wpsStatus[0]); 2608 2595 break; 2609 } 2596 } 2610 2597 #ifndef RELY_ON_DB 2611 2598 dumpMapsToFile(bmap,fbkpres,1); … … 2631 2618 free(fbkpres); 2632 2619 free (fbkp1); 2633 // free (tmps1); // tmps1 is stack memory and should not be freed2634 2620 if(cgiSid!=NULL) 2635 2621 free(cgiSid); … … 2644 2630 //InternetCloseHandle (&hInternet); 2645 2631 #ifdef META_DB 2646 //close_sql(m,0);2632 close_sql(m,0); 2647 2633 #endif 2648 2634 }
Note: See TracChangeset
for help on using the changeset viewer.