Changeset 384 for trunk/zoo-project/zoo-kernel/zoo_service_loader.c
- Timestamp:
- Jan 9, 2013, 11:52:44 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r381 r384 431 431 } 432 432 433 433 434 #ifdef WIN32 434 435 /** … … 449 450 char *dataInputsKVP=getMapsAsKVP(inputs,cgiContentLength,0); 450 451 char *dataOutputsKVP=getMapsAsKVP(outputs,cgiContentLength,1); 452 #ifdef DEBUG 451 453 fprintf(stderr,"DATAINPUTSKVP %s\n",dataInputsKVP); 452 454 fprintf(stderr,"DATAOUTPUTSKVP %s\n",dataOutputsKVP); 455 #endif 453 456 map *sid=getMapFromMaps(m,"lenv","sid"); 454 457 map* r_inputs=getMapFromMaps(m,"main","tmpPath"); 455 map* r_inputs1=getMap(s1->content,"ServiceProvider"); 458 map* r_inputs1=getMap(request_inputs,"metapath"); 459 int hasIn=-1; 460 if(r_inputs1==NULL){ 461 r_inputs1=createMap("metapath",""); 462 hasIn=1; 463 } 456 464 map* r_inputs2=getMap(s1->content,"ResponseDocument"); 457 465 if(r_inputs2==NULL) … … 460 468 461 469 if(r_inputs2!=NULL){ 462 sprintf(tmp,"\" request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,r_inputs2->name,r_inputs2->value,sid->value);463 sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",req->value,id->value,dataInputsKVP,r_inputs2->name,dataOutputsKVP);470 sprintf(tmp,"\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",r_inputs1->value,req->value,id->value,dataInputsKVP,r_inputs2->name,r_inputs2->value,sid->value); 471 sprintf(tmpq,"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",r_inputs1->value,req->value,id->value,dataInputsKVP,r_inputs2->name,dataOutputsKVP); 464 472 } 465 473 else{ 466 sprintf(tmp,"\"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,sid->value); 467 sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s",req->value,id->value,dataInputsKVP,sid->value); 468 } 469 474 sprintf(tmp,"\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",r_inputs1->value,req->value,id->value,dataInputsKVP,sid->value); 475 sprintf(tmpq,"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s",r_inputs1->value,req->value,id->value,dataInputsKVP,sid->value); 476 } 477 478 if(hasIn>0){ 479 freeMap(&r_inputs1); 480 free(r_inputs1); 481 } 470 482 char *tmp1=strdup(tmp); 471 483 sprintf(tmp,"zoo_loader.cgi %s \"%s\"",tmp1,sid->value); 472 484 473 485 free(dataInputsKVP); 474 486 free(dataOutputsKVP); 487 //printf("REQUEST IS : %s \n",tmp); 488 #ifdef DEBUG 475 489 fprintf(stderr,"REQUEST IS : %s \n",tmp); 490 #endif 476 491 SetEnvironmentVariable("CGISID",TEXT(sid->value)); 477 492 SetEnvironmentVariable("QUERY_STRING",TEXT(tmpq)); … … 492 507 ) 493 508 { 509 //printf("CreateProcess failed (%d).\n",GetLastError() ); 510 #ifdef DEBUG 494 511 fprintf( stderr, "CreateProcess failed (%d).\n", GetLastError() ); 512 #endif 495 513 return ; 496 514 }else{ 515 //printf("CreateProcess successfull (%d).\n",GetLastError() ); 516 #ifdef DEBUG 497 517 fprintf( stderr, "CreateProcess successfull (%d).\n\n\n\n", GetLastError() ); 518 #endif 498 519 } 499 520 CloseHandle( pi.hProcess ); 500 521 CloseHandle( pi.hThread ); 522 //printf("CreateProcess finished !\n"); 523 #ifdef DEBUG 501 524 fprintf(stderr,"CreateProcess finished !\n"); 525 #endif 502 526 } 503 527 #endif … … 1701 1725 } 1702 1726 /** 1703 * Get every attribute from a LiteralData node 1704 * storeExecuteResponse, lineage, status 1727 * Get every attribute: storeExecuteResponse, lineage, status 1705 1728 */ 1706 1729 const char *ress[3]={"storeExecuteResponse","lineage","status"}; … … 1742 1765 tmpmaps->next=NULL; 1743 1766 } 1744 else 1745 tmpmaps->name=strdup((char*)val);; 1767 else{ 1768 //free(tmpmaps->name); 1769 tmpmaps->name=strdup((char*)val); 1770 } 1746 1771 xmlFree(val); 1747 1772 } … … 1764 1789 else{ 1765 1790 if(tmpmaps->content!=NULL) 1766 addToMap(tmpmaps->content, 1767 (char*)cur1->name,(char*)val); 1791 addToMap(tmpmaps->content,(char*)cur1->name,(char*)val); 1768 1792 else 1769 tmpmaps->content= 1770 createMap((char*)cur1->name,(char*)val); 1793 tmpmaps->content=createMap((char*)cur1->name,(char*)val); 1771 1794 } 1772 1795 xmlFree(val); … … 1795 1818 } 1796 1819 xmlNodePtr cur2=cur1->children; 1820 while(cur2!=NULL && cur2->type != XML_ELEMENT_NODE) 1821 cur2=cur2->next; 1797 1822 while(cur2){ 1798 1823 /** … … 2125 2150 if(test1!=NULL){ 2126 2151 cgiSid=test1->value; 2127 }2128 if(cgiSid!=NULL){2129 2152 addToMap(request_inputs,"storeExecuteResponse","true"); 2130 2153 addToMap(request_inputs,"status","true"); 2154 setMapInMaps(m,"lenv","sid",test1->value); 2131 2155 status=getMap(request_inputs,"status"); 2132 //fprintf(stderr,"cgiSID : %s",cgiSid); 2133 } 2134 #endif 2156 printf("cgiSid %s\n",cgiSid); 2157 } 2158 #endif 2159 int hrstd=-1; 2160 char *fbkp,*fbkp1; 2161 FILE *f0,*f1; 2135 2162 if(status!=NULL) 2136 2163 if(strcasecmp(status->value,"false")==0) … … 2149 2176 #else 2150 2177 if(cgiSid==NULL){ 2151 addToMap(request_inputs,"cgSid",cgiSid);2152 2178 createProcess(m,request_inputs,s1,NULL,cpid,request_input_real_format,request_output_real_format); 2153 2179 pid = cpid; … … 2155 2181 pid=0; 2156 2182 cpid=atoi(cgiSid); 2157 } 2158 fflush(stderr); 2183 printf("cgiSid %s\n",cgiSid); 2184 } 2185 //printf("pid cpid %d %d\n",pid,cpid); 2186 //fflush(stderr); 2159 2187 #endif 2160 2188 if (pid > 0) { … … 2174 2202 r_inputs=getMapFromMaps(m,"main","tmpPath"); 2175 2203 map* r_inputs1=getMap(s1->content,"ServiceProvider"); 2176 char* fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+100)*sizeof(char));2204 fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+1024)*sizeof(char)); 2177 2205 sprintf(fbkp,"%s/%s_%d.xml",r_inputs->value,r_inputs1->value,cpid); 2178 char* flog=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+10 0)*sizeof(char));2206 char* flog=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+1024)*sizeof(char)); 2179 2207 sprintf(flog,"%s/%s_%d_error.log",r_inputs->value,r_inputs1->value,cpid); 2180 2208 #ifdef DEBUG … … 2184 2212 #endif 2185 2213 freopen(flog,"w+",stderr); 2186 f reopen(fbkp , "w+", stdout);2214 f0=freopen(fbkp , "w+", stdout); 2187 2215 fclose(stdin); 2188 free(fbkp);2189 2216 free(flog); 2190 2217 /** … … 2194 2221 * this way the data will be updated at the end of the process run. 2195 2222 */ 2196 updateStatus(m);2197 2223 printProcessResponse(m,request_inputs,cpid, 2198 2224 s1,r_inputs1->value,SERVICE_STARTED, … … 2202 2228 fflush(stdout); 2203 2229 rewind(stdout); 2204 #endif 2205 2230 #else 2231 #endif 2232 fbkp1=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+1024)*sizeof(char)); 2233 sprintf(fbkp1,"%s/%s_final_%d.xml",r_inputs->value,r_inputs1->value,cpid); 2234 f1=freopen(fbkp1 , "w+", stdout); 2206 2235 loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres); 2207 2208 2236 } else { 2209 2237 /** … … 2242 2270 fclose(stderr); 2243 2271 unhandleStatus(m); 2272 /** 2273 * Dump back the final file fbkp1 to fbkp 2274 */ 2275 fclose(f0); 2276 fclose(f1); 2277 FILE* f2=fopen(fbkp1,"rb"); 2278 FILE* f3=fopen(fbkp,"wb+"); 2279 free(fbkp); 2280 free(fbkp1); 2281 fseek(f2,0,SEEK_END); 2282 long flen=ftell(f2); 2283 fseek(f2,0,SEEK_SET); 2284 char *tmps1=(char*)malloc((flen+1)*sizeof(char)); 2285 fread(tmps1,flen,1,f2); 2286 fwrite(tmps1,1,flen,f3); 2287 fclose(f2); 2288 fclose(f3); 2244 2289 } 2245 2290
Note: See TracChangeset
for help on using the changeset viewer.