Changeset 860
- Timestamp:
- Dec 12, 2017, 4:09:47 PM (7 years ago)
- Location:
- branches/prototype-v0/zoo-project/zoo-kernel
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/caching.c
r854 r860 272 272 273 273 if(i>0){ 274 sprintf(cname,"cache_file_%d",i); 274 275 tmp1=getMap(content->content,cname); 275 sprintf(cname,"cache_file_%d",i);276 276 sprintf(vname,"value_%d",i); 277 277 sprintf(sname,"size_%d",i); -
branches/prototype-v0/zoo-project/zoo-kernel/response_print.c
r854 r860 2465 2465 else 2466 2466 exceptionCode="501 Internal Server Error"; 2467 2467 tmp=getMapFromMaps(m,"lenv","status_code"); 2468 if(tmp!=NULL) 2469 exceptionCode=tmp->value; 2468 2470 if(m!=NULL){ 2469 2471 map *tmpSid=getMapFromMaps(m,"lenv","sid"); … … 2605 2607 void outputResponse(service* s,maps* request_inputs,maps* request_outputs, 2606 2608 map* request_inputs1,int cpid,maps* m,int res){ 2607 2608 2609 #ifdef DEBUG 2609 2610 dumpMaps(request_inputs); … … 2659 2660 } 2660 2661 } 2661 2662 2662 if(res==SERVICE_FAILED){ 2663 2663 map *lenv; … … 2718 2718 toto=getMap(tmpI->content,"asReference"); 2719 2719 #ifdef USE_MS 2720 2720 restartNoMS: 2721 2721 map* geodatatype=getMap(tmpI->content,"geodatatype"); 2722 2722 … … 2778 2778 2779 2779 toto=getMap(tmpI->content,"value"); 2780 if(toto==NULL){ 2781 char tmpMsg[1024]; 2782 sprintf(tmpMsg,_("No value found for the requested output %s."),tmpI->name); 2783 errorException(m,tmpMsg,"InternalError",NULL); 2784 fclose(ofile); 2785 free(file_name); 2786 free(file_path); 2787 return; 2788 } 2780 2789 if(strcasecmp(format,"BoundingBoxData")!=0){ 2781 2790 map* size=getMap(tmpI->content,"size"); -
branches/prototype-v0/zoo-project/zoo-kernel/service.c
r854 r860 865 865 else 866 866 addToMap(m,tmp,value); 867 } 868 869 /** 870 * Add a key and an integer value to an existing map array. 871 * 872 * @param m the map to add the KVP 873 * @param n the key to add 874 * @param index the index of the MapArray 875 * @param v the corresponding value to add 876 */ 877 void addIntToMapArray(map* m,const char* n,int index,const int v){ 878 char svalue[10]; 879 sprintf(svalue,"%d",v); 880 setMapArray(m,n,index,svalue); 867 881 } 868 882 -
branches/prototype-v0/zoo-project/zoo-kernel/service.h
r850 r860 81 81 */ 82 82 #define zWrite write 83 #include "unistd.h" 83 84 /** 84 85 * The crossplatform sleep alias 85 86 */ 86 #define zSleep sleep 87 static int zSleep(const long millisecond){ 88 return usleep(millisecond*1000); 89 } 87 90 /** 88 91 * The crossplatform gettimeofday alias -
branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c
r857 r860 142 142 ( cStep!=arg->step || (arg->state!=0 && steps[arg->step][0]==false) ) 143 143 ){ 144 struct timespec tv; 145 tv.tv_sec = 0; 146 tv.tv_nsec = (long) 5*1e+9; 147 nanosleep(&tv, &tv); 148 //sleep(1); 144 zSleep(100); 149 145 } 150 146 isOngoing=1; … … 307 303 308 304 case 1: { 309 // Fetching data inputs 310 maps* curs=inputs; 311 dumpMaps(curs); 312 char *keys[10][2]={ 313 { 314 "href", 315 "ref" 316 }, 317 { 318 "cache_file", 319 "cachefile" 320 }, 321 { 322 "fmimeType", 323 "mimetype" 324 }, 325 { 326 "size", 327 "size" 328 }, 329 { 330 "ref_wms_link", 331 "ref_wms_link" 332 }, 333 { 334 "ref_wcs_link", 335 "ref_wcs_link" 336 }, 337 { 338 "ref_wcs_link", 339 "ref_wcs_link" 340 }, 341 { 342 "ref_wcs_preview_link", 343 "ref_wcs_preview_link" 344 }, 345 { 346 "geodatatype", 347 "datatype" 348 }, 349 { 350 "wcs_extent", 351 "boundingbox" 352 } 353 }; 354 json_object *res1=json_object_new_object(); 355 while(curs!=NULL){ 356 map* tmpMap=getMap(curs->content,"cache_file"); 357 sid=getMap(curs->content,"ref_wms_link"); 358 json_object *res2=json_object_new_object(); 359 if(tmpMap!=NULL){ 360 if(sid==NULL){ 361 addToMap(curs->content,"generated_file",tmpMap->value); 362 addToMap(curs->content,"storage",tmpMap->value); 363 } 364 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 365 dumpMap(curs->content); 366 struct stat buf; 367 char timeStr[ 100 ] = ""; 368 if (stat(tmpMap->value, &buf)==0){ 369 strftime(timeStr, 100, "%d-%m-%Y %H:%M:%S", localtime( &buf.st_mtime)); 370 json_object *jsStr=json_object_new_string(timeStr); 371 json_object_object_add(res2,"creation_date",jsStr); 372 } 373 tmpMap=getMap(curs->content,"fmimeType"); 374 if(tmpMap!=NULL){ 375 addToMap(curs->content,"mimeType",tmpMap->value); 376 } 377 setReferenceUrl(conf,curs); 378 } 379 int i=0; 380 int hasRef=-1; 381 for(;i<10;i++){ 382 sid=getMap(curs->content,keys[i][0]); 383 if(sid!=NULL){ 384 json_object *jsStr=json_object_new_string(sid->value); 385 json_object_object_add(res2,keys[i][1],jsStr); 386 if(i==0){ 387 hasRef=1; 388 json_object *jsStr1=json_object_new_string(getProvenance(conf,url->value)); 389 json_object_object_add(res2,"dataOrigin",jsStr1); 390 } 391 } 392 } 393 if(hasRef<0) 394 json_object_put(res2); 395 else 396 json_object_object_add(res1,curs->name,res2); 397 curs=curs->next; 398 } 399 json_object_object_add(res,"inputs",res1); 400 break; 401 } 402 403 case 2: { 404 // Update the execute request stored on disk at step 1,1 to modify the references used. 405 if(state==0){ 305 // Update the execute request stored on disk at step 0,0 to modify the references used. 306 if(state==1){ 406 307 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 407 308 fflush(stderr); … … 424 325 //if(bvMap!=NULL && strncasecmp(bvMap->value,"true",4)==0){ 425 326 if(getMap(curs->content,"href")==NULL && getMap(curs->content,"mimeType")!=NULL){ 426 map* tmpMap=getMap(curs->content,"cache_file"); 327 map* tmpMap=getMap(curs->content,"value"); 328 char tmpStr[100]; 329 sprintf(tmpStr,"%d",strlen(tmpMap->value)); 330 addToMap(curs->content,"size",tmpStr); 331 tmpMap=getMap(curs->content,"mimeType"); 332 addToMap(curs->content,"fmimeType",tmpMap->value); 333 tmpMap=getMap(curs->content,"cache_file"); 427 334 addToMap(curs->content,"generated_file",tmpMap->value); 428 335 addToMap(curs->content,"storage",tmpMap->value); … … 459 366 char *tmpParam=(char*)malloc((strlen(curs->name)+11)*sizeof(char)); 460 367 char *tmpParam1=(char*)malloc((strlen(filePath->value)+11)*sizeof(char)); 461 sprintf(tmpParam,"string(\"%s\")",curs->name); 462 sprintf(tmpParam1,"string(\"%s\")",filePath->value); 368 addToMap(curs->content,"href",filePath->value); 369 addToMap(curs->content,"xlink:href",filePath->value); 370 sprintf(tmpParam,"string(\"%s\")",curs->name); 371 sprintf(tmpParam1,"string(\"%s\")",filePath->value); 463 372 params[0]="attr"; 464 373 params[1]=tmpParam; … … 538 447 } 539 448 449 // Fetching data inputs 450 maps* curs=inputs; 451 dumpMaps(curs); 452 char *keys[11][2]={ 453 { 454 "xlink:href", 455 "ref" 456 }, 457 { 458 "cache_file", 459 "cachefile" 460 }, 461 { 462 "fmimeType", 463 "mimetype" 464 }, 465 { 466 "size", 467 "size" 468 }, 469 { 470 "ref_wms_link", 471 "ref_wms_link" 472 }, 473 { 474 "ref_wfs_link", 475 "ref_wfs_link" 476 }, 477 { 478 "ref_wcs_link", 479 "ref_wcs_link" 480 }, 481 { 482 "ref_wcs_link", 483 "ref_wcs_link" 484 }, 485 { 486 "ref_wcs_preview_link", 487 "ref_wcs_preview_link" 488 }, 489 { 490 "geodatatype", 491 "datatype" 492 }, 493 { 494 "wgs84_extent", 495 "boundingbox" 496 } 497 }; 498 json_object *res1=json_object_new_object(); 499 while(curs!=NULL){ 500 if(getMap(curs->content,"length")==NULL){ 501 addToMap(curs->content,"length","1"); 502 } 503 map* length=getMap(curs->content,"length"); 504 int len=atoi(length->value); 505 json_object *res3; 506 int hasRef=-1; 507 for(int ii=0;ii<len;ii++){ 508 map* tmpMap=getMapArray(curs->content,"cache_file",ii); 509 sid=getMapArray(curs->content,"ref_wms_link",ii); 510 json_object *res2=json_object_new_object(); 511 if(tmpMap!=NULL){ 512 if(sid==NULL){ 513 setMapArray(curs->content,"generated_file",ii,tmpMap->value); 514 setMapArray(curs->content,"storage",ii,tmpMap->value); 515 } 516 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 517 dumpMap(curs->content); 518 struct stat buf; 519 char timeStr[ 100 ] = ""; 520 if (stat(tmpMap->value, &buf)==0){ 521 strftime(timeStr, 100, "%d-%m-%Y %H:%M:%S", localtime( &buf.st_mtime)); 522 json_object *jsStr=json_object_new_string(timeStr); 523 json_object_object_add(res2,"creation_date",jsStr); 524 } 525 tmpMap=getMapArray(curs->content,"fmimeType",ii); 526 if(tmpMap!=NULL){ 527 setMapArray(curs->content,"mimeType",ii,tmpMap->value); 528 } 529 setReferenceUrl(conf,curs); 530 }else{ 531 } 532 addIntToMap(curs->content,"published_id",ii+1); 533 int i=0; 534 for(;i<11;i++){ 535 sid=getMapArray(curs->content,keys[i][0],ii); 536 if(sid!=NULL){ 537 json_object *jsStr=json_object_new_string(sid->value); 538 json_object_object_add(res2,keys[i][1],jsStr); 539 if(i==0){ 540 hasRef=1; 541 json_object *jsStr1=json_object_new_string(getProvenance(conf,sid->value)); 542 json_object_object_add(res2,"dataOrigin",jsStr1); 543 } 544 } 545 } 546 if(len>1){ 547 if(ii==0) 548 res3=json_object_new_array(); 549 json_object_array_add(res3,res2); 550 }else 551 res3=res2; 552 } 553 if(hasRef<0) 554 json_object_put(res3); 555 else 556 json_object_object_add(res1,curs->name,res3); 557 addIntToMap(curs->content,"published_id",0); 558 curs=curs->next; 559 } 560 json_object_object_add(res,"inputs",res1); 561 break; 562 } 563 564 case 2: { 540 565 // Uploading data input to cluster 541 566 maps* in=getMaps(conf,"uploadQueue"); … … 545 570 if(length!=NULL){ 546 571 json_object *res1=json_object_new_object(); 547 json_object *res 2=json_object_new_object();572 json_object *res3=json_object_new_array(); 548 573 int limit=atoi(length->value); 549 574 int i=0; … … 555 580 map* tmp2=getMapArray(tmp,"targetPath",i); 556 581 if(tmp0!=NULL && tmp1!=NULL && tmp2!=NULL){ 582 json_object *res2=json_object_new_object(); 557 583 json_object *jsStr=json_object_new_string(tmp1->value); 558 584 json_object_object_add(res2,"local_path",jsStr); 559 585 jsStr=json_object_new_string(tmp2->value); 560 586 json_object_object_add(res2,"target_path",jsStr); 561 json_object_object_add(res1,tmp0->value,res2); 587 json_object *res4=json_object_object_get(res1,tmp0->value); 588 if(json_object_is_type(res4,json_type_null)){ 589 json_object_object_add(res1,tmp0->value,res2); 590 }else{ 591 if(json_object_is_type(res4,json_type_object)){ 592 json_object_array_add(res3,res4); 593 } 594 json_object_array_add(res3,res2); 595 if(json_object_is_type(res4,json_type_object)){ 596 json_object_object_del(res1,tmp0->value); 597 json_object_object_add(res1,tmp0->value,res3); 598 } 599 } 562 600 } 563 601 } 602 if(json_object_array_length(res3)==0) 603 json_object_put(res3); 564 604 json_object_object_add(res,"inputs",res1); 565 605 } … … 616 656 }, 617 657 { 618 "w cs_extent",658 "wgs84_extent", 619 659 "boundingbox" 620 660 }, … … 684 724 int i0=0; 685 725 for(;i0<6;i0++){ 686 sid=getMap(specificMaps->content,keys[i0][0]); 726 if(i0==0) 727 sid=getMap(specificMaps->content,specifics[i][1]); 728 else 729 sid=getMap(specificMaps->content,keys[i0][0]); 687 730 if(sid!=NULL){ 688 731 json_object *jsStr=json_object_new_string(sid->value); -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal.c
r854 r860 649 649 fprintf(stderr,"Retry to access the semaphore later ...\n"); 650 650 #endif 651 zSleep(1 );651 zSleep(1000); 652 652 } 653 653 } -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c
r854 r860 285 285 * @param real_inputs the maps containing the inputs 286 286 * @param real_outputs the maps containing the outputs 287 * @return SERVICE_SUCCEEDED in case of success, -1 or SERVICE_FAILED when failing. 287 288 */ 288 289 int zoo_hpc_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){ … … 391 392 } 392 393 393 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 394 invokeCallback(m,inputs,NULL,2,0);395 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 396 dumpMaps(inputs);394 #ifdef HPC_DEBUG 395 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 396 #endif 397 invokeCallback(m,inputs,NULL,1,1); 397 398 if(getMapFromMaps(m,"lenv","mapError")!=NULL){ 398 399 invokeCallback(m,inputs,NULL,7,0); 399 400 return -1; 400 401 } 402 invokeCallback(m,inputs,NULL,2,0); 403 #ifdef HPC_DEBUG 404 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 405 dumpMaps(inputs); 406 #endif 401 407 402 408 // Upload data on HPC … … 404 410 errorException (m, _("Unable to lock the file for upload!"), 405 411 "InternalError", NULL); 406 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 412 #ifdef HPC_DEBUG 413 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 414 #endif 407 415 invokeCallback(m,inputs,NULL,7,0); 408 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 416 #ifdef HPC_DEBUG 417 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 418 #endif 409 419 return -1; 410 420 } 411 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 421 #ifdef HPC_DEBUG 422 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 423 #endif 412 424 invokeCallback(m,inputs,NULL,2,1); 413 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 425 #ifdef HPC_DEBUG 426 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 427 #endif 414 428 415 429 // Add the filename to generate for every output to parameters … … 417 431 // TODO: fix appendOutputParameters 418 432 //appendOutputParameters(input,parameters,¶meters_cnt,s,uuid,targetPathMap); 433 #ifdef HPC_DEBUG 419 434 dumpMaps(input); 435 #endif 420 436 while(input!=NULL){ 421 437 // TODO: parse all outputs including inner outputs if required. … … 509 525 sprintf(scriptPath,"%s/zoo_%s_%s.sh",tmpPath->value,s->name,uuid->value); 510 526 setMapInMaps(*main_conf,"lenv","local_script",scriptPath); 527 #ifdef HPC_DEBUG 511 528 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 512 529 fflush(stderr); 530 #endif 513 531 invokeCallback(m,inputs,NULL,3,0); 532 #ifdef HPC_DEBUG 514 533 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 515 534 fflush(stderr); 535 #endif 516 536 FILE* scriptFile=fopen(scriptPath,"w+"); 517 537 map* headerMap=getMapFromMaps(*main_conf,configurationId,"jobscript_header"); … … 562 582 free(fcontent); 563 583 }else 564 fprintf(scriptFile," #!/bin/bash\n\n### *** Default ZOO-Service BODY (no body found) *** ###\n\n");584 fprintf(scriptFile,"\n### *** Default ZOO-Service BODY (no body found) *** ###\n\n"); 565 585 }else 566 fprintf(scriptFile," #!/bin/bash\n\n### *** Default ZOO-Service BODY *** ###\n\n");586 fprintf(scriptFile,"\n### *** Default ZOO-Service BODY *** ###\n\n"); 567 587 568 588 map* sp=getMap(s->content,"serviceProvider"); … … 583 603 fflush(scriptFile); 584 604 fclose(scriptFile); 585 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 605 #ifdef HPC_DEBUG 606 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 607 #endif 586 608 invokeCallback(m,inputs,NULL,3,1); 587 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 609 #ifdef HPC_DEBUG 610 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 611 #endif 588 612 589 613 // Upload the SBATCH File to the remote host 590 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 614 #ifdef HPC_DEBUG 615 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 616 #endif 591 617 invokeCallback(m,inputs,NULL,4,0); 592 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 618 #ifdef HPC_DEBUG 619 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 620 #endif 593 621 targetPathMap=getMapFromMaps(*main_conf,configurationId,"remote_work_path"); 594 622 if(targetPathMap==NULL){ … … 597 625 errorException (m, _("There is no remote_work_path defined in your section!"), 598 626 "InternalError", NULL); 627 #ifdef HPC_DEBUG 599 628 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 600 629 fflush(stderr); 630 #endif 601 631 invokeCallback(m,NULL,NULL,7,0); 632 #ifdef HPC_DEBUG 602 633 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 603 634 fflush(stderr); 635 #endif 604 636 return SERVICE_FAILED; 605 637 } … … 609 641 setMapInMaps(*main_conf,"lenv","remote_script",targetPath); 610 642 SSHCON *test=ssh_connect(*main_conf); 611 ssh_copy(*main_conf,scriptPath,targetPath,ssh_get_cnt(*main_conf));643 int copy0=ssh_copy(*main_conf,scriptPath,targetPath,ssh_get_cnt(*main_conf)); 612 644 unlink(scriptPath); 613 645 free(scriptPath); 646 if(copy0!=true){ 647 setMapInMaps(m,"lenv","message",_("Unable to upload the script")); 648 invokeCallback(m,NULL,NULL,7,0); 649 errorException(m,_("Unable to upload the script"),"NoApplicableCode",NULL); 650 return -1; 651 } 614 652 // Execute the SBATCH script remotely 615 653 addReadLocks(main_conf); … … 617 655 char *command=(char*)malloc((strlen(targetPath)+strlen(targetPathMap->value)+strlen(subStr->value)+strlen(uuid->value)+137)*sizeof(char)); 618 656 sprintf(command,"sbatch %s 2> %s/error_%s.log | sed \"s:%s::g\"",targetPath,targetPathMap->value,uuid->value,subStr->value); 619 if(ssh_exec(*main_conf,command,ssh_get_cnt(m)) ==0){657 if(ssh_exec(*main_conf,command,ssh_get_cnt(m))<=0){ 620 658 // The sbatch command has failed! 621 659 // Download the error log file from the HPC server … … 645 683 }else 646 684 setMapInMaps(*main_conf,"lenv","message",_("Unable to fetch the remote error log file")); 647 tmpPath=getMapFromMaps(*main_conf,"lenv","message"); 685 tmpPath=getMapFromMaps(m,"lenv","message"); 686 #ifdef HPC_DEBUG 648 687 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 649 688 fflush(stderr); 689 #endif 650 690 invokeCallback(m,NULL,NULL,7,0); 691 #ifdef HPC_DEBUG 651 692 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 652 693 fflush(stderr); 653 sprintf(tmpS, "Cannot execute the HPC ZOO-Service %s: %s", s->name, tmpPath->value); 694 #endif 695 sprintf(tmpS, "Cannot execute the HPC ZOO-Service %s using %s: %s", s->name, configurationId, tmpPath->value); 654 696 errorException(m,tmpS,"NoApplicableCode",NULL); 655 697 free(command); 656 698 free(targetPath); 657 699 ssh_close(*main_conf); 700 removeReadLocks(main_conf); 658 701 sleep(1); 659 702 return -1; 660 703 } 661 704 free(targetPath); 705 #ifdef HPC_DEBUG 662 706 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 663 707 fflush(stderr); 708 #endif 664 709 invokeCallback(m,NULL,NULL,4,1); 710 #ifdef HPC_DEBUG 665 711 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 666 712 fflush(stderr); 713 #endif 667 714 free(command); 715 #ifdef HPC_DEBUG 668 716 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 669 717 fflush(stderr); 718 #endif 670 719 671 720 struct sockaddr_un addr; 672 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);673 fflush(stderr);674 721 memset(&addr, 0, sizeof(addr)); 675 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);676 fflush(stderr);677 722 addr.sun_family = AF_UNIX; 678 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);679 fflush(stderr);680 723 int rc, cl, fd = socket(AF_UNIX, SOCK_STREAM, 0); 681 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);682 fflush(stderr);683 724 char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(uuid->value)+20)); 684 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);685 fflush(stderr);686 725 sprintf(sname,"%s/.wait_socket_%s.sock",tmpPath->value,uuid->value); 687 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);688 fflush(stderr);689 726 strncpy(addr.sun_path, sname, sizeof(addr.sun_path)-1); 690 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);691 fflush(stderr);692 727 693 728 if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) { … … 696 731 errorException (m, _("Unable to bind socket!"), 697 732 "InternalError", NULL); 733 #ifdef HPC_DEBUG 698 734 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 699 735 fflush(stderr); 736 #endif 700 737 invokeCallback(m,NULL,NULL,7,0); 738 removeReadLocks(main_conf); 739 #ifdef HPC_DEBUG 701 740 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 702 741 fflush(stderr); 703 sleep(120); 742 #endif 704 743 return -1; 705 744 } 745 #ifdef HPC_DEBUG 706 746 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 707 747 fflush(stderr); 748 #endif 708 749 if (listen(fd, 5) == -1) { 709 750 setMapInMaps(*main_conf,"lenv","message",_("Listen error")); 710 751 errorException (m, _("Listen error"), 711 752 "InternalError", NULL); 753 #ifdef HPC_DEBUG 712 754 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 713 755 fflush(stderr); 756 #endif 714 757 invokeCallback(m,NULL,NULL,7,0); 758 removeReadLocks(main_conf); 759 #ifdef HPC_DEBUG 715 760 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 716 761 fflush(stderr); 762 #endif 717 763 return -1; 718 764 } 719 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);720 fflush(stderr);721 765 if ( (cl = accept(fd, NULL, NULL)) == -1) { 722 766 setMapInMaps(*main_conf,"lenv","message",_("Accept error")); 723 767 errorException (m, _("Accept error"), 724 768 "InternalError", NULL); 769 #ifdef HPC_DEBUG 725 770 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 726 771 fflush(stderr); 772 #endif 727 773 invokeCallback(m,NULL,NULL,7,0); 774 removeReadLocks(main_conf); 775 #ifdef HPC_DEBUG 728 776 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 729 777 fflush(stderr); 778 #endif 730 779 return -1; 731 780 }else{ 781 #ifdef HPC_DEBUG 732 782 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 733 783 fflush(stderr); 784 #endif 734 785 int hasPassed=-1; 735 786 char buf[11]; … … 741 792 errorException (m, _("Read closed"), 742 793 "InternalError", NULL); 794 #ifdef HPC_DEBUG 743 795 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 744 796 fflush(stderr); 797 #endif 745 798 invokeCallback(m,NULL,NULL,7,0); 799 removeReadLocks(main_conf); 800 #ifdef HPC_DEBUG 746 801 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 747 802 fflush(stderr); 803 #endif 748 804 return -1; 749 805 }else{ … … 752 808 errorException (m, _("Read error"), 753 809 "InternalError", NULL); 810 #ifdef HPC_DEBUG 754 811 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 755 812 fflush(stderr); 813 #endif 756 814 invokeCallback(m,NULL,NULL,7,0); 815 removeReadLocks(main_conf); 816 #ifdef HPC_DEBUG 757 817 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 758 818 fflush(stderr); 819 #endif 759 820 return -1; 760 821 } 761 822 } 762 823 hasPassed=1; 763 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);764 fflush(stderr);765 824 res=atoi(buf); 766 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);767 fflush(stderr);768 825 unlink(sname); 769 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);770 fflush(stderr);771 826 free(sname); 772 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);773 fflush(stderr);774 827 removeReadLocks(main_conf); 775 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);776 fflush(stderr);777 828 778 829 if(res==3){ 830 #ifdef HPC_DEBUG 779 831 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 780 832 fflush(stderr); 833 #endif 781 834 invokeCallback(m,NULL,outputs,5,0); 835 #ifdef HPC_DEBUG 782 836 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 783 837 fflush(stderr); 838 #endif 839 840 // Read informations provided by FinalizeHPC as a configuration file 841 // then, remove the file. 842 map* jobid=getMapFromMaps(*main_conf,"lenv","usid"); 843 map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath"); 844 char *filePath=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+15)*sizeof(char)); 845 sprintf(filePath,"%s/exec_status_%s",tmpPath->value,jobid->value); 846 maps* m = (maps *) malloc (MAPS_SIZE); 847 m->child=NULL; 848 m->next=NULL; 849 int saved_stdout = dup (fileno (stdout)); 850 dup2 (fileno (stderr), fileno (stdout)); 851 conf_read(filePath,m); 852 fflush(stdout); 853 dup2 (saved_stdout, fileno (stdout)); 854 close(saved_stdout); 855 unlink(filePath); 856 free(filePath); 857 addMapsToMaps(main_conf,m); 858 freeMaps(&m); 859 free(m); 860 784 861 input=*real_outputs; 785 862 while(input!=NULL){ … … 797 874 char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 798 875 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename); 799 setMapInMaps( *main_conf,"lenv","message",tmpStr);876 setMapInMaps(m,"lenv","message",tmpStr); 800 877 free(tmpStr); 801 878 invokeCallback(m,NULL,NULL,7,0); … … 804 881 } 805 882 }else{ 806 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);807 fflush(stderr);808 883 map* generatedFile=getMap(input->content,"generated_file"); 809 884 if(generatedFile!=NULL){ … … 834 909 sprintf(serviceName,"wcs_link"); 835 910 setMapInMaps(output->child,serviceName,"msOgc","WCS"); 911 setMapInMaps(output->child,serviceName,"requestedMimeType","image/tiff"); 836 912 } 837 913 else{ 838 914 sprintf(serviceName,"wfs_link"); 839 915 setMapInMaps(output->child,serviceName,"msOgc","WFS"); 916 setMapInMaps(output->child,serviceName,"requestedMimeType","text/xml"); 840 917 } 841 918 setMapInMaps(output->child,serviceName,"storage",targetPath); … … 844 921 setMapInMaps(output->child,serviceName,"asReference","true"); 845 922 }else{ 846 char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 847 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename); 848 setMapInMaps(*main_conf,"lenv","message",tmpStr); 849 free(tmpStr); 850 invokeCallback(m,NULL,NULL,7,0); 923 map* hpcStdErr=getMapFromMaps(*main_conf,"henv","StdErr"); 924 if(hpcStdErr!=NULL && ssh_fetch(*main_conf,targetPath,hpcStdErr->value,ssh_get_cnt(m))==0){ 925 struct stat f_status; 926 int ts=stat(targetPath, &f_status); 927 if(ts==0) { 928 char* fcontent = NULL; 929 fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 930 FILE* f=fopen(targetPath,"rb"); 931 fread(fcontent,f_status.st_size,1,f); 932 int fsize=f_status.st_size; 933 fcontent[fsize]=0; 934 fclose(f); 935 setMapInMaps(*main_conf,"lenv","message",fcontent); 936 free(fcontent); 937 }else{ 938 char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 939 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename); 940 setMapInMaps(*main_conf,"lenv","message",tmpStr); 941 free(tmpStr); 942 } 943 }else{ 944 char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 945 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename); 946 setMapInMaps(*main_conf,"lenv","message",tmpStr); 947 free(tmpStr); 948 } 949 invokeCallback(*main_conf,NULL,NULL,7,0); 851 950 return SERVICE_FAILED; 852 951 } … … 857 956 } 858 957 859 // Read informations provided by FinalizeHPC as a configuration file860 // then, remove the file.861 map* jobid=getMapFromMaps(*main_conf,"lenv","usid");862 map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath");863 char *filePath=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+15)*sizeof(char));864 sprintf(filePath,"%s/exec_status_%s",tmpPath->value,jobid->value);865 maps* m = (maps *) malloc (MAPS_SIZE);866 m->child=NULL;867 m->next=NULL;868 int saved_stdout = dup (fileno (stdout));869 dup2 (fileno (stderr), fileno (stdout));870 conf_read(filePath,m);871 fflush(stdout);872 dup2 (saved_stdout, fileno (stdout));873 close(saved_stdout);874 unlink(filePath);875 free(filePath);876 addMapsToMaps(main_conf,m);877 freeMaps(&m);878 free(m);879 958 }else{ 880 959 // Try to access remotely to the log file and return a more relevant error message … … 882 961 errorException (m, _("HPC Execution failed!"), 883 962 "InternalError", NULL); 963 #ifdef HPC_DEBUG 884 964 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 885 965 fflush(stderr); 966 #endif 886 967 invokeCallback(m,NULL,NULL,7,0); 968 #ifdef HPC_DEBUG 887 969 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 888 970 fflush(stderr); 971 #endif 889 972 } 890 973 //free(buf); … … 895 978 errorException (m, _("Unable to parse the value returned by remote execution"), 896 979 "InternalError", NULL); 980 #ifdef HPC_DEBUG 897 981 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 898 982 fflush(stderr); 983 #endif 899 984 invokeCallback(m,NULL,NULL,7,0); 985 #ifdef HPC_DEBUG 900 986 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 901 987 fflush(stderr); 902 sleep(120); 988 #endif 903 989 return SERVICE_FAILED; 904 990 } 905 991 } 992 #ifdef HPC_DEBUG 906 993 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 907 994 fflush(stderr); 995 #endif 908 996 ssh_close(*main_conf); 997 #ifdef HPC_DEBUG 909 998 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 910 999 fflush(stderr); 1000 #endif 911 1001 return res; 912 1002 } -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c
r854 r860 76 76 77 77 /** 78 * Return the current publish_id value 79 * @param elem and maps pointer on which the search occur 80 * @return the integer value of the publish_id field, if any, 0 otherwise 81 */ 82 int getPublishedId(maps* elem){ 83 map* myIndex=getMap(elem->content,"published_id"); 84 if(myIndex!=NULL){ 85 return atoi(myIndex->value); 86 } 87 return 0; 88 } 89 /** 78 90 * Add width and height keys to an output maps containing the maximum width 79 91 * and height for displaying the full data extent. … … 87 99 */ 88 100 void setMapSize(maps* output,double minx,double miny,double maxx,double maxy){ 101 int imyIndex=getPublishedId(output); 89 102 double maxWidth=640; 90 103 double maxHeight=480; … … 118 131 #endif 119 132 if(output!=NULL){ 120 addToMap(output->content,"width",sWidth);121 addToMap(output->content,"height",sHeight);133 setMapArray(output->content,"width",imyIndex,sWidth); 134 setMapArray(output->content,"height",imyIndex,sHeight); 122 135 } 123 136 } … … 131 144 */ 132 145 void setReferenceUrl(maps* m,maps* tmpI){ 133 outputMapfile(m,tmpI);134 146 map *msUrl=getMapFromMaps(m,"main","mapserverAddress"); 135 147 if(msUrl==NULL){ … … 138 150 exit(-1); 139 151 } 152 int imyIndex=getPublishedId(tmpI); 153 if(getMapArray(tmpI->content,"ref_wms_link",imyIndex)!=NULL) 154 return; 155 outputMapfile(m,tmpI); 140 156 int finalProto=-1; 141 157 map *msOgcVersion=getMapFromMaps(m,"main","msOgcVersion"); 142 158 map *dataPath=getMapFromMaps(m,"main","dataPath"); 143 159 map *sid=getMapFromMaps(m,"lenv","usid"); 144 map* format=getMap(tmpI->content,"mimeType"); 145 map* rformat=getMap(tmpI->content,"requestedMimeType"); 146 map* width=getMap(tmpI->content,"width"); 147 map* height=getMap(tmpI->content,"height"); 148 map* protoMap=getMap(tmpI->content,"msOgc"); 149 map* versionMap=getMap(tmpI->content,"msOgcVersion"); 160 map* format=getMapArray(tmpI->content,"mimeType",imyIndex); 161 map* rformat=getMapArray(tmpI->content,"requestedMimeType",imyIndex); 162 map* width=getMapArray(tmpI->content,"width",imyIndex); 163 map* height=getMapArray(tmpI->content,"height",imyIndex); 164 map* protoMap=getMapArray(tmpI->content,"msOgc",imyIndex); 165 map* versionMap=getMapArray(tmpI->content,"msOgcVersion",imyIndex); 166 map* datatype=getMapArray(tmpI->content,"geodatatype",imyIndex); 150 167 char options[4][5][25]={ 151 168 {"WMS","1.3.0","GetMap","layers=%s","wms_extent"}, … … 154 171 {"WCS","1.1.0","GetCoverage","coverage=%s","wcs_extent"} 155 172 }; 156 map* datatype=getMap(tmpI->content,"geodatatype");157 173 if(datatype==NULL || strncmp(datatype->value,"other",5)==0){ 158 setMapInMaps(m,"lenv","mapError","true"); 159 setMapInMaps(m,"lenv","locator",tmpI->name); 160 setMapInMaps(m,"lenv","message",_("The ZOO-Kernel was able to retrieve the data but could not read it as geographic data.")); 161 if(getMapFromMaps(m,"lenv","state")==NULL) 162 errorException (m, _("Unable to find any geographic data"), "WrongInputData", tmpI->name); 174 map* minNb=getMap(tmpI->content,"minoccurs"); 175 if(minNb==NULL || atoi(minNb->value)>=1){ 176 setMapInMaps(m,"lenv","mapError","true"); 177 setMapInMaps(m,"lenv","locator",tmpI->name); 178 setMapInMaps(m,"lenv","message",_("The ZOO-Kernel was able to retrieve the data but could not read it as geographic data.")); 179 if(getMapFromMaps(m,"lenv","state")==NULL) 180 errorException (m, _("Unable to find any geographic data"), "WrongInputData", tmpI->name); 181 } 163 182 return; 164 183 } 165 184 int proto=0; 166 185 if(rformat==NULL){ 167 rformat=getMap (tmpI->content,"mimeType");186 rformat=getMapArray(tmpI->content,"mimeType",imyIndex); 168 187 } 169 188 if(strncasecmp(rformat->value,"text/xml",8)==0) … … 172 191 strncasecmp(rformat->value,"image/geotiff",10)==0) 173 192 proto=2; 193 int hasFormat=-1; 174 194 if(protoMap!=NULL){ 175 if(strncasecmp(protoMap->value,"WMS",3)==0) 195 hasFormat=1; 196 if(strncasecmp(protoMap->value,"WMS",3)==0){ 176 197 proto=0; 198 rformat=createMap("value","image/png"); 199 } 177 200 else{ 178 if(strncasecmp(protoMap->value,"WFS",3)==0) 201 if(strncasecmp(protoMap->value,"WFS",3)==0){ 179 202 proto=1; 180 else 203 rformat=createMap("value","text/xml"); 204 } 205 else { 181 206 proto=2; 207 rformat=createMap("value","image/tiff"); 208 } 182 209 } 183 210 } … … 190 217 } 191 218 192 map* extent=getMap(tmpI->content,options[proto][4]); 193 map* crs=getMap(tmpI->content,"crs"); 219 220 map* extent=getMapArray(tmpI->content,options[proto][4],imyIndex); 221 map* crs=getMapArray(tmpI->content,"crs",imyIndex); 194 222 int hasCRS=1; 195 223 if(crs==NULL){ … … 203 231 sprintf(layers,options[proto][3],tmpI->name); 204 232 205 char* webService_url=(char*)malloc((strlen(msUrl->value)+strlen(format->value)+strlen(tmpI->name)+strlen(width->value)+strlen(height->value)+strlen(extent->value)+256)*sizeof(char)); 233 if(format==NULL || width==NULL || height==NULL || extent==NULL){ 234 char tmpStr[1024]; 235 sprintf(tmpStr,_("Unable to create the mapfile for %s because of missing values."),tmpI->name); 236 errorException (m, tmpStr, 237 "InternalError", NULL); 238 exit(-1); 239 return; 240 } 241 242 if(proto==0){ 243 hasFormat=1; 244 rformat=createMap("mimeType","image/png"); 245 }else{ 246 if(proto==1){ 247 rformat=createMap("mimeType","text/xml"); 248 hasFormat=1; 249 } 250 else 251 if(proto==2){ 252 rformat=createMap("mimeType","image/tiff"); 253 hasFormat=1; 254 finalProto=1; 255 } 256 } 206 257 258 char* webService_url=(char*)malloc((strlen(msUrl->value)+strlen(rformat->value)+strlen(tmpI->name)+strlen(width->value)+strlen(height->value)+strlen(extent->value)+256)*sizeof(char)); 259 260 207 261 if(proto>0){ 208 262 if(proto==2) 209 263 finalProto=1; 210 264 sprintf(webService_url, 211 "%s?map=%s/%s_% s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",265 "%s?map=%s/%s_%d_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s", 212 266 msUrl->value, 213 267 dataPath->value, 214 268 tmpI->name, 269 imyIndex, 215 270 sid->value, 216 271 options[proto][2], … … 223 278 ); 224 279 if(datatype!=NULL && strncasecmp(datatype->value,"raster",6)==0){ 225 addToMap(tmpI->content,"ref_wcs_link",webService_url);280 setMapArray(tmpI->content,"ref_wcs_link",imyIndex,webService_url); 226 281 } 227 282 else{ 228 addToMap(tmpI->content,"ref_wfs_link",webService_url);283 setMapArray(tmpI->content,"ref_wfs_link",imyIndex,webService_url); 229 284 } 230 285 proto=0; 286 freeMap(&rformat); 287 free(rformat); 231 288 rformat=createMap("mimeType","image/png"); 232 289 } 233 290 else{ 234 291 sprintf(webService_url, 235 "%s?map=%s/%s_% s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s",292 "%s?map=%s/%s_%d_%s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s", 236 293 msUrl->value, 237 294 dataPath->value, 238 295 tmpI->name, 296 imyIndex, 239 297 sid->value, 240 298 options[proto][2], … … 248 306 crs->value 249 307 ); 250 addToMap(tmpI->content,"ref_wms_link",webService_url);308 setMapArray(tmpI->content,"ref_wms_link",imyIndex,webService_url); 251 309 if(datatype!=NULL && strncasecmp(datatype->value,"raster",6)==0){ 252 310 proto=2; 311 freeMap(&rformat); 312 free(rformat); 253 313 rformat=createMap("mimeType","image/tiff"); 254 314 } 255 315 else{ 256 316 proto=1; 317 freeMap(&rformat); 318 free(rformat); 257 319 rformat=createMap("mimeType","text/xml"); 258 320 } 259 321 } 260 addToMap(tmpI->content,"Reference",webService_url);322 setMapArray(tmpI->content,"Reference",imyIndex,webService_url); 261 323 memset(layers,0,128); 262 324 sprintf(layers,options[proto][3],tmpI->name); 263 325 protoVersion=options[proto][1]; 264 extent=getMap (tmpI->content,options[proto][4]);326 extent=getMapArray(tmpI->content,options[proto][4],imyIndex); 265 327 memset(webService_url,0,strlen(webService_url)); 266 328 if(proto>0){ … … 268 330 finalProto=1; 269 331 sprintf(webService_url, 270 "%s?map=%s/%s_% s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",332 "%s?map=%s/%s_%d_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s", 271 333 msUrl->value, 272 334 dataPath->value, 273 335 tmpI->name, 336 imyIndex, 274 337 sid->value, 275 338 options[proto][2], … … 282 345 ); 283 346 if(datatype!=NULL && strncasecmp(datatype->value,"raster",6)==0){ 284 addToMap(tmpI->content,"ref_wcs_link",webService_url);347 setMapArray(tmpI->content,"ref_wcs_link",imyIndex,webService_url); 285 348 } 286 349 else{ 287 addToMap(tmpI->content,"ref_wfs_link",webService_url);350 setMapArray(tmpI->content,"ref_wfs_link",imyIndex,webService_url); 288 351 } 289 352 }else{ 290 353 sprintf(webService_url, 291 "%s?map=%s/%s_% s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s",354 "%s?map=%s/%s_%d_%s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s", 292 355 msUrl->value, 293 356 dataPath->value, 294 357 tmpI->name, 358 imyIndex, 295 359 sid->value, 296 360 options[proto][2], … … 304 368 crs->value 305 369 ); 306 addToMap(tmpI->content,"ref_wms_link",webService_url);370 setMapArray(tmpI->content,"ref_wms_link",imyIndex,webService_url); 307 371 } 308 372 if(finalProto>0){ … … 311 375 sprintf(layers,options[proto][3],tmpI->name); 312 376 protoVersion=options[proto][1]; 313 extent=getMap (tmpI->content,options[proto][4]);377 extent=getMapArray(tmpI->content,options[proto][4],imyIndex); 314 378 memset(webService_url,0,strlen(webService_url)); 379 freeMap(&rformat); 380 free(rformat); 381 rformat=createMap("value","image/tiff"); 315 382 sprintf(webService_url, 316 "%s?map=%s/%s_% s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",383 "%s?map=%s/%s_%d_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s", 317 384 msUrl->value, 318 385 dataPath->value, 319 386 tmpI->name, 387 imyIndex, 320 388 sid->value, 321 389 options[proto][2], … … 327 395 crs->value 328 396 ); 329 addToMap(tmpI->content,"ref_wcs_preview_link",webService_url);397 setMapArray(tmpI->content,"ref_wcs_preview_link",imyIndex,webService_url); 330 398 } 331 399 if(hasCRS==0){ … … 352 420 OGRSpatialReferenceH hSRS; 353 421 map* msSrs=NULL; 422 int imyIndex=getPublishedId(output); 354 423 hSRS = OSRNewSpatialReference(NULL); 355 424 if( pszProjection!=NULL && strlen(pszProjection)>1){ … … 375 444 if(output!=NULL){ 376 445 if(OSRIsGeographic(hSRS)==TRUE) 377 addToMap(output->content,"crs_isGeographic","true");446 setMapArray(output->content,"crs_isGeographic",imyIndex,"true"); 378 447 else 379 addToMap(output->content,"crs_isGeographic","false");380 addToMap(output->content,"crs",tmpSrs);448 setMapArray(output->content,"crs_isGeographic",imyIndex,"false"); 449 setMapArray(output->content,"crs",imyIndex,tmpSrs); 381 450 } 382 451 } … … 391 460 if(output!=NULL){ 392 461 if(OSRIsGeographic(hSRS)==TRUE) 393 addToMap(output->content,"crs_isGeographic","true");462 setMapArray(output->content,"crs_isGeographic",imyIndex,"true"); 394 463 else 395 addToMap(output->content,"crs_isGeographic","false");464 setMapArray(output->content,"crs_isGeographic",imyIndex,"false"); 396 465 } 397 466 free(proj4Str); … … 401 470 msLoadProjectionStringEPSG(&myLayer->projection,"EPSG:4326"); 402 471 if(output!=NULL){ 403 addToMap(output->content,"crs_isGeographic","true");472 setMapArray(output->content,"crs_isGeographic",imyIndex,"true"); 404 473 } 405 474 } 406 475 if(output!=NULL){ 407 addToMap(output->content,"crs","EPSG:4326");408 addToMap(output->content,"real_extent","true");476 setMapArray(output->content,"crs",imyIndex,"EPSG:4326"); 477 setMapArray(output->content,"real_extent",imyIndex,"true"); 409 478 } 410 479 msInsertHashTable(&(m->web.metadata),"ows_srs", "EPSG:4326 EPSG:900913 EPSG:3857"); … … 415 484 else{ 416 485 if(output!=NULL){ 417 msSrs=getMap (output->content,"msSrs");486 msSrs=getMapArray(output->content,"msSrs",imyIndex); 418 487 } 419 488 if(msSrs!=NULL){ … … 431 500 } 432 501 if(output!=NULL){ 433 addToMap(output->content,"crs",msSrs->value);434 addToMap(output->content,"crs_isGeographic","true");502 setMapArray(output->content,"crs",imyIndex,msSrs->value); 503 setMapArray(output->content,"crs_isGeographic",imyIndex,"true"); 435 504 } 436 505 } … … 454 523 void setMsExtent(maps* output,mapObj* m,layerObj* myLayer, 455 524 double minX,double minY,double maxX,double maxY){ 525 int imyIndex=getPublishedId(output); 456 526 msMapSetExtent(m,minX,minY,maxX,maxY); 457 527 #ifdef DEBUGMS … … 466 536 467 537 if(output!=NULL){ 468 map* test=getMap(output->content,"real_extent"); 538 map* test=getMapArray(output->content,"real_extent",imyIndex); 539 pointObj min, max; 540 projectionObj tempSrs; 541 min.x = m->extent.minx; 542 min.y = m->extent.miny; 543 max.x = m->extent.maxx; 544 max.y = m->extent.maxy; 545 char tmpSrsStr[1024]; 546 msInitProjection(&tempSrs); 547 msLoadProjectionStringEPSG(&tempSrs,"EPSG:4326"); 548 549 msProjectPoint(&(myLayer->projection),&tempSrs,&min); 550 msProjectPoint(&myLayer->projection,&tempSrs,&max); 551 469 552 if(test!=NULL){ 470 pointObj min, max;471 projectionObj tempSrs;472 min.x = m->extent.minx;473 min.y = m->extent.miny;474 max.x = m->extent.maxx;475 max.y = m->extent.maxy;476 char tmpSrsStr[1024];477 msInitProjection(&tempSrs);478 msLoadProjectionStringEPSG(&tempSrs,"EPSG:4326");479 480 msProjectPoint(&(m->projection),&tempSrs,&min);481 msProjectPoint(&m->projection,&tempSrs,&max);482 483 553 sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",min.y,min.x,max.y,max.x); 484 map* isGeo=getMap (output->content,"crs_isGeographic");554 map* isGeo=getMapArray(output->content,"crs_isGeographic",imyIndex); 485 555 #ifdef DEBUGMS 486 556 fprintf(stderr,"isGeo = %s\n",isGeo->value); 487 557 #endif 488 if(isGeo!=NULL && strcasecmp("true",isGeo->value)==0) 558 if(isGeo!=NULL && strcasecmp("true",isGeo->value)==0){ 559 sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",min.y,min.x,max.y,max.x); 560 setMapArray(output->content,"wgs84_extent",imyIndex,tmpExtent); 489 561 sprintf(tmpExtent,"%f,%f,%f,%f", minY,minX, maxY, maxX); 490 addToMap(output->content,"wms_extent",tmpExtent); 562 }else{ 563 sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",min.x,min.y,max.x,max.y); 564 setMapArray(output->content,"wgs84_extent",imyIndex,tmpExtent); 565 } 566 setMapArray(output->content,"wms_extent",imyIndex,tmpExtent); 491 567 sprintf(tmpSrsStr,"%.3f,%.3f,%.3f,%.3f",min.x,min.y,max.x,max.y); 492 addToMap(output->content,"wcs_extent",tmpExtent);568 setMapArray(output->content,"wcs_extent",imyIndex,tmpExtent); 493 569 }else{ 570 sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",min.x,min.y,max.x,max.y); 571 setMapArray(output->content,"wgs84_extent",imyIndex,tmpExtent); 494 572 sprintf(tmpExtent,"%f,%f,%f,%f",minX, minY, maxX, maxY); 495 map* isGeo=getMap (output->content,"crs_isGeographic");573 map* isGeo=getMapArray(output->content,"crs_isGeographic",imyIndex); 496 574 if(isGeo!=NULL){ 497 575 #ifdef DEBUGMS … … 501 579 sprintf(tmpExtent,"%f,%f,%f,%f", minY,minX, maxY, maxX); 502 580 } 503 addToMap(output->content,"wms_extent",tmpExtent);581 setMapArray(output->content,"wms_extent",imyIndex,tmpExtent); 504 582 sprintf(tmpExtent,"%.3f,%.3f,%.3f,%.3f",minX,minY,maxX,maxY); 505 addToMap(output->content,"wcs_extent",tmpExtent);583 setMapArray(output->content,"wcs_extent",imyIndex,tmpExtent); 506 584 } 507 585 } … … 518 596 */ 519 597 int tryOgr(maps* conf,maps* output,mapObj* m){ 520 521 map* tmpMap=getMap (output->content,"storage");598 int imyIndex=getPublishedId(output); 599 map* tmpMap=getMapArray(output->content,"storage",imyIndex); 522 600 char *pszDataSource=tmpMap->value; 523 601 … … 643 721 #endif 644 722 setMapInMaps(conf,"lenv","message","Unable to open datasource in read only mode"); 645 //OGR_DS_Destroy(poDS);646 //OGRCleanupAll();647 723 #ifdef DEBUGMS 648 724 fprintf(stderr,"Unable to access the DataSource, exit! \n"); … … 651 727 } 652 728 653 addToMap(output->content,"geodatatype","vector");729 setMapArray(output->content,"geodatatype",imyIndex,"vector"); 654 730 int iLayer = 0; 655 731 for( iLayer=0; iLayer < OGR_DS_GetLayerCount(poDS); iLayer++ ){ … … 687 763 msConnectLayer(myLayer,MS_OGR,pszDataSource); 688 764 689 addIntToMap (output->content,"nb_features",OGR_L_GetFeatureCount(poLayer,1));765 addIntToMapArray(output->content,"nb_features",imyIndex,OGR_L_GetFeatureCount(poLayer,1)); 690 766 691 767 /** … … 739 815 } 740 816 else{ 741 addToMap(output->content,"crs","EPSG:4326");742 addToMap(output->content,"crs_isGeographic","true");817 setMapArray(output->content,"crs",imyIndex,"EPSG:4326"); 818 setMapArray(output->content,"crs_isGeographic",imyIndex,"true"); 743 819 msLoadProjectionStringEPSG(&m->projection,"EPSG:4326"); 744 820 msInsertHashTable(&(m->web.metadata), "ows_srs", "EPSG:4326 EPSG:900913 EPSG:3857"); … … 752 828 memset(&extent,0,1024); 753 829 sprintf(extent,"%d,%d,%d,%d",oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY); 754 addToMap(output->content,"boundingbox",extent);830 setMapArray(output->content,"boundingbox",imyIndex,extent); 755 831 } 756 832 … … 771 847 msInsertHashTable(&(myLayer->metadata), "gml_include_items", "all"); 772 848 msInsertHashTable(&(myLayer->metadata), "ows_name", output->name); 773 map* tmpMap=getMap (output->content,"title");849 map* tmpMap=getMapArray(output->content,"title",imyIndex); 774 850 if(tmpMap!=NULL) 775 851 msInsertHashTable(&(myLayer->metadata), "ows_title", tmpMap->value); … … 839 915 */ 840 916 int tryGdal(maps* conf,maps* output,mapObj* m){ 841 map* tmpMap=getMap(output->content,"storage"); 917 int imyIndex=getPublishedId(output); 918 map* tmpMap=getMapArray(output->content,"storage",imyIndex); 842 919 char *pszFilename=tmpMap->value; 843 920 GDALDatasetH hDataset; … … 855 932 fprintf(stderr,"Unable to access the DataSource %s \n",pszFilename); 856 933 #endif 857 addToMap(output->content,"geodatatype","other");934 setMapArray(output->content,"geodatatype",imyIndex,"other"); 858 935 setMapInMaps(conf,"lenv","message","gdalinfo failed - unable to open"); 859 936 GDALDestroyDriverManager(); … … 864 941 #endif 865 942 866 addToMap(output->content,"geodatatype","raster");943 setMapArray(output->content,"geodatatype",imyIndex,"raster"); 867 944 /** 868 945 * Add a new layer set name, data … … 886 963 887 964 char *title=output->name; 888 tmpMap=getMap (output->content,"title");965 tmpMap=getMapArray(output->content,"title",imyIndex); 889 966 if(tmpMap!=NULL) 890 967 title=tmpMap->value; 891 968 char *abstract=output->name; 892 tmpMap=getMap (output->content,"abstract");969 tmpMap=getMapArray(output->content,"abstract",imyIndex); 893 970 if(tmpMap!=NULL) 894 971 abstract=tmpMap->value; … … 905 982 m->width=GDALGetRasterXSize( hDataset ); 906 983 m->height=GDALGetRasterYSize( hDataset ); 907 addIntToMap (output->content,"nb_pixels",GDALGetRasterXSize( hDataset )*GDALGetRasterYSize( hDataset ));984 addIntToMapArray(output->content,"nb_pixels",imyIndex,GDALGetRasterXSize( hDataset )*GDALGetRasterYSize( hDataset )); 908 985 909 986 /** … … 947 1024 memset(&extent,0,1024); 948 1025 sprintf(extent,"%d,%d,%d,%d",minX,minY,maxX,maxY); 949 addToMap(output->content,"boundingbox",extent);1026 setMapArray(output->content,"boundingbox",imyIndex,extent); 950 1027 } 951 1028 }else{ 952 1029 int scale=1; 953 1030 if(m->width>2048){ 954 addIntToMap (output->content,"width",2048);1031 addIntToMapArray(output->content,"width",imyIndex,2048); 955 1032 scale=2048/m->width; 956 1033 }else 957 addIntToMap (output->content,"width",m->width);958 addIntToMap (output->content,"height",m->height*scale);1034 addIntToMapArray(output->content,"width",imyIndex,m->width); 1035 addIntToMapArray(output->content,"height",imyIndex,m->height*scale); 959 1036 } 960 1037 … … 1130 1207 * First store the value on disk 1131 1208 */ 1132 map* mime=getMap(outputs->content,"mimeType"); 1209 int imyIndex=getPublishedId(outputs); 1210 map* mime=getMapArray(outputs->content,"mimeType",imyIndex); 1133 1211 char *ext="data"; 1134 1212 if(mime!=NULL) … … 1136 1214 ext="json"; 1137 1215 1138 map* storage=getMap (outputs->content,"storage");1216 map* storage=getMapArray(outputs->content,"storage",imyIndex); 1139 1217 if(storage==NULL){ 1140 1218 map* tmpMap=getMapFromMaps(conf,"main","dataPath"); 1141 1219 map* sidMap=getMapFromMaps(conf,"lenv","usid"); 1142 1220 char *pszDataSource=(char*)malloc((strlen(tmpMap->value)+strlen(sidMap->value)+strlen(outputs->name)+17)*sizeof(char)); 1143 sprintf(pszDataSource,"%s/ZOO_DATA_% s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext);1221 sprintf(pszDataSource,"%s/ZOO_DATA_%d_%s_%s.%s",tmpMap->value,imyIndex,outputs->name,sidMap->value,ext); 1144 1222 int f=zOpen(pszDataSource,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); 1145 map *gfile=getMap (outputs->content,"generated_file");1223 map *gfile=getMapArray(outputs->content,"generated_file",imyIndex); 1146 1224 if(gfile!=NULL){ 1147 1225 readGeneratedFile(conf,outputs->content,gfile->value); 1148 1226 } 1149 map* sizeMap=getMap (outputs->content,"size");1150 map* vData=getMap (outputs->content,"value");1227 map* sizeMap=getMapArray(outputs->content,"size",imyIndex); 1228 map* vData=getMapArray(outputs->content,"value",imyIndex); 1151 1229 if(sizeMap!=NULL){ 1152 1230 zWrite(f,vData->value,atoi(sizeMap->value)*sizeof(char)); … … 1156 1234 } 1157 1235 close(f); 1158 addToMap(outputs->content,"storage",pszDataSource);1236 setMapArray(outputs->content,"storage",imyIndex,pszDataSource); 1159 1237 free(pszDataSource); 1160 1238 } … … 1327 1405 map* sid=getMapFromMaps(conf,"lenv","usid"); 1328 1406 char *mapPath= 1329 (char*)malloc(( 7+strlen(sid->value)+strlen(outputs->name)+strlen(tmp1->value))*sizeof(char));1330 sprintf(mapPath,"%s/%s_% s.map",tmp1->value,outputs->name,sid->value);1407 (char*)malloc((14+strlen(sid->value)+strlen(outputs->name)+strlen(tmp1->value))*sizeof(char)); 1408 sprintf(mapPath,"%s/%s_%d_%s.map",tmp1->value,outputs->name,imyIndex,sid->value); 1331 1409 msSaveMap(myMap,mapPath); 1332 1410 free(mapPath); -
branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.c
r854 r860 121 121 int _init_sql(maps* conf,const char* key){ 122 122 char* sqlInitString=_createInitString(conf,key); 123 #ifdef SQL_DEBUG 123 124 fprintf(stderr,"Try to connect to: %s %s !\n",key,sqlInitString); 124 125 fflush(stderr); 126 #endif 125 127 if(strncmp(sqlInitString,"-1",2)==0) 126 128 return -1; 127 fprintf(stderr,"Try to connect to: %s !\n",key);128 fflush(stderr);129 129 OGRSFDriver *poDriver = NULL; 130 130 OGRRegisterAll(); … … 165 165 #endif 166 166 if( zoo_DS[zoo_ds_nb] == NULL ){ 167 #ifdef DEBUG167 #ifdef SQL_DEBUG 168 168 fprintf(stderr,"sqlInitString: %s FAILED !\n",sqlInitString); 169 169 fflush(stderr); … … 174 174 return -2; 175 175 } 176 #ifdef DEBUG176 #ifdef SQL_DEBUG 177 177 fprintf(stderr,"sqlInitString: %s SUCEED !\n",sqlInitString); 178 178 fflush(stderr); 179 179 #endif 180 fprintf(stderr,"sqlInitString: %s SUCEED %d !\n",sqlInitString,zoo_ds_nb);181 fflush(stderr);182 180 free(sqlInitString); 183 181 zoo_ds_nb++; … … 234 232 return NULL; 235 233 OGRLayer *res=NULL; 236 #ifdef DEBUG234 #ifdef SQL_DEBUG 237 235 fprintf(stderr,"************************* %s %s %d\n\n",sqlQuery,__FILE__,__LINE__); 238 236 fflush(stderr); … … 381 379 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(msg->value)+strlen(p->value)+strlen(sid->value)+64+1)*sizeof(char)); 382 380 sprintf(sqlQuery,"UPDATE %s.services set status=$$%s$$,message=$$%s$$ where uuid=$$%s$$;",schema->value,p->value,msg->value,sid->value); 383 if(zoo_ds_nb==0){ 381 if( zoo_ds_nb== 382 #ifdef META_DB 383 1 384 #else 385 0 386 #endif 387 ){ 384 388 init_sql(conf); 385 389 zoo_ds_nb++; -
branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c
r854 r860 283 283 } 284 284 }while(!sftp_handle); 285 #ifdef SSH_DEBUG 285 286 fprintf(stderr, "libssh2_sftp_open() is done, get file information\n"); 287 #endif 286 288 do { 287 289 rc = libssh2_sftp_stat_ex(sessions[cnt]->sftp_session, targetPath, strlen(targetPath), … … 295 297 else 296 298 { 299 #ifdef SSH_DEBUG 297 300 fprintf(stderr, "Stat Data: RetCode=%d\n", rc); 298 301 fprintf(stderr, "Stat Data: Size=%llu\n", attrs.filesize); 299 302 fprintf(stderr, "Stat Data: Perm=%lx\n", attrs.permissions); 300 303 fprintf(stderr, "Stat Data: mtime=%lu\n", attrs.mtime); 304 #endif 301 305 if(rc==0) 302 306 break; … … 348 352 return false; 349 353 } 354 if(!sessions[cnt]->sftp_session) 355 zSleep(10); 350 356 } while (!sessions[cnt]->sftp_session); 351 357 … … 363 369 return false; 364 370 } 371 if(!sftp_handle) 372 zSleep(10); 365 373 } while (!sftp_handle); 366 374 start = time(NULL); … … 432 440 return -1; 433 441 } 442 if(!sessions[cnt]->sftp_session) 443 zSleep(10); 434 444 } while (!sessions[cnt]->sftp_session); 435 445 do { … … 482 492 return -1; 483 493 } 484 494 485 495 } while (1); 486 496 duration = (int)(time(NULL)-start); … … 503 513 int exitcode; 504 514 char *exitsignal=(char *)"none"; 505 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);506 fflush(stderr);507 515 while( (channel = libssh2_channel_open_session(sessions[cnt]->session)) == NULL && 508 516 libssh2_session_last_error(sessions[cnt]->session,NULL,NULL,0) == LIBSSH2_ERROR_EAGAIN ) { 509 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 510 fflush(stderr); 511 waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session); 512 } 513 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 514 fflush(stderr); 517 waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session); 518 } 515 519 if( channel == NULL ){ 516 520 fprintf(stderr,"Error\n"); 517 521 return -1; 518 522 } 519 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);520 fflush(stderr);521 523 while( (rc = libssh2_channel_exec(channel, command)) == LIBSSH2_ERROR_EAGAIN ) { 522 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);523 fflush(stderr);524 524 waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session); 525 525 } 526 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);527 fflush(stderr);528 526 if( rc != 0 ) { 529 527 fprintf(stderr,"Error\n"); 530 528 return -1; 531 529 } 532 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);533 fflush(stderr);534 530 535 531 map* tmpPath=getMapFromMaps(conf,"main","tmpPath"); … … 539 535 FILE* logFile=fopen(logPath,"wb"); 540 536 free(logPath); 541 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);542 fflush(stderr);543 537 while(true){ 544 538 int rc; … … 563 557 break; 564 558 } 565 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);566 fflush(stderr);567 559 fclose(logFile); 568 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);569 fflush(stderr);570 560 exitcode = 127; 571 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);572 fflush(stderr);573 561 while( (rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN ) 574 562 waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session); 575 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);576 fflush(stderr);577 563 578 564 if( rc == 0 ) { … … 581 567 NULL, NULL, NULL, NULL, NULL); 582 568 } 583 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);584 fflush(stderr);585 569 586 570 if (exitsignal) … … 588 572 else 589 573 fprintf(stderr, "\nEXIT: %d bytecount: %d\n", exitcode, bytecount); 590 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);591 fflush(stderr);592 574 593 575 libssh2_channel_free(channel); … … 664 646 } 665 647 } 666 #ifdef DEBUG648 #ifdef SSH_DEBUG 667 649 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 668 650 fflush(stderr); … … 682 664 return false; 683 665 } 684 #ifdef DEBUG666 #ifdef SSH_DEBUG 685 667 fprintf(stderr,"*** %s %d\n",__FILE__,__LINE__); 686 668 fflush(stderr); … … 700 682 getMapArray(queueMaps->content,"targetPath",i) 701 683 }; 684 #ifdef SSH_DEBUG 702 685 fprintf(stderr,"*** %s %d %s %s\n",__FILE__,__LINE__,argv[1]->value,argv[2]->value); 686 #endif 703 687 /**/zooLock* lck; 704 688 if((lck=lockFile(*conf,argv[1]->value,'w'))!=NULL){/**/ -
branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c
r859 r860 316 316 if(passThrough!=NULL && targetHosts!=NULL){ 317 317 char *tmp=zStrdup(passThrough->value); 318 char *token, *saveptr;319 token = strtok_r (tmp, ",", &saveptr);320 318 int i; 321 319 for(i=0;i<handle->nb;i++){ 322 320 if(strstr(targetHosts->value,"*")!=NULL || isProtectedHost(targetHosts->value,handle->ihandle[i].url)==1){ 321 char *token, *saveptr; 322 token = strtok_r (tmp, ",", &saveptr); 323 323 while (token != NULL){ 324 324 int length=strlen(token)+6; … … 338 338 AddMissingHeaderEntry(&handle->ihandle[i],token,tmpMap->value); 339 339 } 340 free(tmp1);341 340 if(handle->ihandle[i].header!=NULL) 342 341 curl_easy_setopt(handle->ihandle[i].handle,CURLOPT_HTTPHEADER,handle->ihandle[i].header); 342 free(tmp1); 343 343 cnt+=1; 344 344 token = strtok_r (NULL, ",", &saveptr); … … 520 520 if(curl_multi_perform(hInternet->handle, &still_running)==CURLM_OK) 521 521 if(still_running){ 522 struct timespec tv; 523 tv.tv_sec = 0; 524 tv.tv_nsec = (long) 100; 525 nanosleep(&tv, &tv); 522 zSleep(10); 526 523 } 527 524 }while(still_running); -
branches/prototype-v0/zoo-project/zoo-kernel/zoo_service_loader.c
r854 r860 2201 2201 int hasValidCookie = -1; 2202 2202 char *tcook = originalCookie = zStrdup (cgiCookie); 2203 //fprintf(stderr,">>>>> %s %d %s\n",__FILE__,__LINE__,tcook );2204 char *tmp = NULL;2205 2203 map *testing = getMapFromMaps (m, "main", "cookiePrefix"); 2206 2204 parseCookie(&m,originalCookie); 2207 if (testing == NULL) 2205 map *sessId=getMapFromMaps(m,"cookies",(testing==NULL?"ID":testing->value)); 2206 if (sessId!=NULL) 2208 2207 { 2209 tmp = zStrdup ("ID="); 2210 } 2211 else 2212 { 2213 tmp = 2214 (char *) malloc ((strlen (testing->value) + 2) * sizeof (char)); 2215 sprintf (tmp, "%s=", testing->value); 2216 } 2217 if (strstr (cgiCookie, ";") != NULL) 2218 { 2219 char *token, *saveptr; 2220 token = strtok_r (tcook, ";", &saveptr); 2221 while (token != NULL) 2222 { 2223 if (strcasestr (token, tmp) != NULL) 2224 { 2225 if (tcook != NULL) 2226 free (tcook); 2227 tcook = zStrdup (token); 2228 hasValidCookie = 1; 2229 } 2230 token = strtok_r (NULL, ";", &saveptr); 2231 } 2232 } 2233 else 2234 { 2235 if (strstr (cgiCookie, "=") != NULL 2236 && strcasestr (cgiCookie, tmp) != NULL) 2237 { 2238 tcook = zStrdup (cgiCookie); 2239 hasValidCookie = 1; 2240 } 2241 if (tmp != NULL) 2242 { 2243 free (tmp); 2244 } 2245 } 2246 if (hasValidCookie > 0) 2247 { 2248 addToMap (_tmpMaps->content, "sessid", strstr (tcook, "=") + 1); 2208 addToMap (_tmpMaps->content, "sessid", sessId->value); 2249 2209 char session_file_path[1024]; 2250 2210 map *tmpPath = getMapFromMaps (m, "main", "sessPath"); … … 2254 2214 if (tmp1 != NULL) 2255 2215 sprintf (session_file_path, "%s/sess_%s.cfg", tmpPath->value, 2256 s trstr (tmp1, "=") + 1);2216 sessId->value); 2257 2217 else 2258 2218 sprintf (session_file_path, "%s/sess_%s.cfg", tmpPath->value, 2259 s trstr (cgiCookie, "=") + 1);2219 sessId->value); 2260 2220 free (tcook); 2261 2221 maps *tmpSess = (maps *) malloc (MAPS_SIZE); … … 2351 2311 if (status == NULLMAP) 2352 2312 { 2353 /* hInternet = InternetOpen (2354 #ifndef WIN322355 (LPCTSTR)2356 #endif2357 "ZooWPSClient\0",2358 INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);*/2359 2313 if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){ 2360 2314 freeService (&s1); … … 2378 2332 close_sql(m,0); 2379 2333 #endif 2380 2381 /*#ifdef RELY_ON_DB2382 //close_sql(m,1);2383 //end_sql();2384 #endif*/2385 2334 } 2386 2335 else … … 2433 2382 setMapInMaps (m, "lenv", "async","true"); 2434 2383 map* r_inputs1 = createMap("ServiceName", s1->name); 2435 2436 /*hInternet = InternetOpen (2437 #ifndef WIN322438 (LPCTSTR)2439 #endif2440 "ZooWPSClient\0",2441 INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);2442 #ifndef WIN322443 if (!CHECK_INET_HANDLE (hInternet))2444 fprintf (stderr, "WARNING : hInternet handle failed to initialize");2445 #endif*/2446 2384 2447 2385 // Create the filename for the result file (.res) … … 2558 2496 invokeCallback(m,request_input_real_format,NULL,1,0); 2559 2497 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 2560 dumpMaps(request_output_real_format);2498 //dumpMaps(request_output_real_format); 2561 2499 if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){ 2562 2500 freeService (&s1); … … 2600 2538 return -1; 2601 2539 } 2602 dumpMaps(request_output_real_format);2603 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);2604 invokeCallback(m,request_input_real_format,NULL,1,1);2605 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);2606 2540 if(getMapFromMaps(m,"lenv","mapError")!=NULL){ 2607 2541 setMapInMaps(m,"lenv","message",_("Issue with geographic data")); … … 2634 2568 fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__); 2635 2569 #endif 2636 fflush(stdout); 2637 rewind(stdout); 2570 fflush(stdout); 2571 rewind(stdout); 2572 2638 2573 if (eres != -1) 2639 2574 outputResponse (s1, request_input_real_format,
Note: See TracChangeset
for help on using the changeset viewer.