Changeset 32 for trunk/zoo-kernel/zoo_service_loader.c
- Timestamp:
- Sep 27, 2010, 10:09:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/zoo_service_loader.c
r30 r32 44 44 #include "service.h" 45 45 #include "service_internal.h" 46 47 48 #ifdef USE_PYTHON49 46 #include "service_internal_python.h" 50 #endif51 47 52 48 #ifdef USE_JAVA … … 182 178 freeMaps(&m); 183 179 free(m); 184 freeMap(&request_inputs);185 free(request_inputs);186 180 return 1; 187 181 } … … 194 188 freeMaps(&m); 195 189 free(m); 196 freeMap(&request_inputs);197 free(request_inputs);198 190 free(REQUEST); 199 191 return 1; … … 418 410 s1=(service*)calloc(1,SERVICE_SIZE); 419 411 if(s1 == NULL){ 412 freeMaps(&m); 413 free(m); 414 free(REQUEST); 415 free(SERVICE_URL); 420 416 return errorException(m, "Unable to allocate memory.","InternalError"); 421 417 } … … 437 433 fflush(stdout); 438 434 dup2(saved_stdout,fileno(stdout)); 439 if(t==22){ 440 errorException(m, "The value for <indetifier> seems to be wrong. Please, ensure that the process exsits using the GetCapabilities request.", "InvalidParameterValue"); 441 exit(0); 435 if(t<0){ 436 char tmpMsg[2048+strlen(r_inputs->value)]; 437 sprintf(tmpMsg,"The value for <indetifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request.",r_inputs->value); 438 errorException(m, tmpMsg, "InvalidParameterValue"); 439 freeService(&s1); 440 free(s1); 441 freeMaps(&m); 442 free(m); 443 free(REQUEST); 444 free(SERVICE_URL); 445 return 0; 442 446 } 443 //s[0]=s1;447 close(saved_stdout); 444 448 445 449 #ifdef DEBUG … … 483 487 if(r_inputs==NULL) r_inputs=getMap(request_inputs,"RawDataOutput"); 484 488 485 //#ifdef DEBUG489 #ifdef DEBUG 486 490 fprintf(stderr,"OUTPUT Parsing ... \n"); 487 //#endif491 #endif 488 492 if(r_inputs!=NULL){ 489 //#ifdef DEBUG493 #ifdef DEBUG 490 494 fprintf(stderr,"OUTPUT Parsing start now ... \n"); 491 //#endif495 #endif 492 496 char current_output_as_string[10240]; 493 497 char cursor_output[10240]; … … 765 769 #endif 766 770 xmlNodePtr cur2=cur->children; 767 while(cur2 ){768 while(cur2 ->type!=XML_ELEMENT_NODE)771 while(cur2!=NULL){ 772 while(cur2!=NULL && cur2->type!=XML_ELEMENT_NODE) 769 773 cur2=cur2->next; 774 if(cur2==NULL) 775 break; 770 776 /** 771 777 * Indentifier … … 1024 1030 #endif 1025 1031 xmlNodePtr cur4=cur2->children; 1026 while(cur4 ){1027 while(cur4 ->type!=XML_ELEMENT_NODE)1032 while(cur4!=NULL){ 1033 while(cur4!=NULL &&cur4->type!=XML_ELEMENT_NODE) 1028 1034 cur4=cur4->next; 1029 1035 if(cur4==NULL) 1036 break; 1030 1037 if(xmlStrcasecmp(cur4->name, BAD_CAST "LiteralData")==0){ 1031 1038 /** … … 1103 1110 dumpMaps(request_input_real_format); 1104 1111 #endif 1105 tmpmaps=tmpmaps->next; 1106 1112 freeMaps(&tmpmaps); 1113 free(tmpmaps); 1114 tmpmaps=NULL; 1107 1115 } 1108 1116 #ifdef DEBUG … … 1427 1435 int eres=SERVICE_STARTED; 1428 1436 int cpid=getpid(); 1437 1438 maps *_tmpMaps=(maps*)malloc(MAPS_SIZE); 1439 _tmpMaps->name=strdup("lenv"); 1440 char tmpBuff[100]; 1441 sprintf(tmpBuff,"%i",cpid); 1442 _tmpMaps->content=createMap("sid",tmpBuff); 1443 _tmpMaps->next=NULL; 1444 addToMap(_tmpMaps->content,"status","0"); 1445 addMapsToMaps(&m,_tmpMaps); 1446 freeMaps(&_tmpMaps); 1447 free(_tmpMaps); 1448 1429 1449 #ifdef DEBUG 1430 1450 dumpMap(request_inputs); … … 1588 1608 } 1589 1609 else{ 1590 #ifdef USE_PYTHON1591 1610 if(strncasecmp(r_inputs->value,"PYTHON",6)==0){ 1592 1611 eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format); 1593 1612 } 1594 1613 else 1595 #endif1596 1614 1597 1615 #ifdef USE_JAVA … … 1660 1678 r_inputs=getMapFromMaps(m,"main","tmpPath"); 1661 1679 map* r_inputs1=getMap(s1->content,"ServiceProvider"); 1662 char* fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+1 6)*sizeof(char));1680 char* fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+100)*sizeof(char)); 1663 1681 sprintf(fbkp,"%s/%s_%d.xml",r_inputs->value,r_inputs1->value,cpid); 1664 char* flog=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+ 22)*sizeof(char));1682 char* flog=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+100)*sizeof(char)); 1665 1683 sprintf(flog,"%s/%s_%d_error.log",r_inputs->value,r_inputs1->value,cpid); 1666 fprintf(stderr,"File to use as backup %s\n",fbkp);1667 1684 #ifdef DEBUG 1668 1685 fprintf(stderr,"RUN IN BACKGROUND MODE \n"); … … 1675 1692 free(fbkp); 1676 1693 free(flog); 1694 if(setsid()<0) 1695 return errorException(m, "Unable to run the child process properly", "InternalError"); 1677 1696 /** 1678 1697 * set status to SERVICE_STARTED and flush stdout to ensure full … … 1681 1700 * this way the data will be updated at the end of the process run. 1682 1701 */ 1702 updateStatus(m); 1683 1703 printProcessResponse(m,request_inputs,cpid, 1684 s1,r_inputs ->value,SERVICE_STARTED,1704 s1,r_inputs1->value,SERVICE_STARTED, 1685 1705 request_input_real_format, 1686 1706 request_output_real_format); … … 1810 1830 } 1811 1831 } else{ 1812 1813 #ifdef USE_PYTHON1814 1832 if(strncasecmp(r_inputs->value,"PYTHON",6)==0){ 1815 1833 eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format); 1816 1834 } 1817 1835 else 1818 #endif1819 1836 1820 1837 #ifdef USE_JAVA … … 1853 1870 } 1854 1871 1855 //res=execute(&m,&request_input_real_format,&request_output_real_format);1856 1872 } else { 1857 1873 /** … … 1873 1889 cpid,m,eres); 1874 1890 1875 //if(getpid()==cpid){ 1891 if(((int)getpid())!=cpid){ 1892 fclose(stdout); 1893 fclose(stderr); 1894 unhandleStatus(m); 1895 } 1896 1876 1897 freeService(&s1); 1877 1898 free(s1); 1878 1899 freeMaps(&m); 1879 1900 free(m); 1880 freeMaps(&tmpmaps);1881 free(tmpmaps);1882 1901 1883 1902 freeMaps(&request_input_real_format); 1884 1903 free(request_input_real_format); 1885 1904 1886 //freeMap(&request_inputs);1887 //free(request_inputs);1888 1889 1905 /* The following is requested but get issue using with Python support :/ */ 1890 1906 /* freeMaps(&request_output_real_format); 1891 free(request_output_real_format); 1892 */ 1907 free(request_output_real_format);*/ 1893 1908 1894 1909 free(REQUEST); … … 1899 1914 fflush(stderr); 1900 1915 #endif 1901 //}1902 1916 1903 1917 return 0;
Note: See TracChangeset
for help on using the changeset viewer.