34 #include <sys/types.h>
35 #include <sys/socket.h>
45 using std::ostringstream ;
74 cerr <<
"Unable to determine method to handle clients, "
75 <<
"single or multiple as defined by BES.ProcessManagerMethod"
79 if( _method !=
"multiple" && _method !=
"single" )
81 cerr <<
"Unable to determine method to handle clients, "
82 <<
"single or multiple as defined by BES.ProcessManagerMethod"
97 if (_method ==
"single")
111 if ((pid = fork()) < 0)
113 string error(
"fork error");
114 const char* error_info = strerror(errno);
116 error +=
" " + (string) error_info;
133 if( ( pid1 = fork() ) < 0 )
137 kill( main_process, 9 );
138 perror(
"fork error" );
139 exit( SERVER_EXIT_CHILD_SUBPROCESS_ABNORMAL_TERMINATION );
150 exit( SERVER_EXIT_CHILD_SUBPROCESS_NORMAL_TERMINATION );
152 if( waitpid( pid, NULL, 0 ) != pid )
155 string error(
"waitpid error" );
156 const char *error_info = strerror( errno );
158 error +=
" " + (string)error_info;
172 string from = strm.str() ;
174 map<string,string> extensions ;
187 done = c->
receive( extensions, &ss ) ;
191 if( extensions[
"status"] == c->
exit() )
202 string cmd_str = ss.str() ;
203 BESDEBUG(
"server",
"BESServerHandler::execute - command = "
204 << cmd_str << endl ) ;
217 std::streambuf *holder ;
218 holder = cout.rdbuf() ;
222 int status = cmd.execute_request( from ) ;
228 cout.rdbuf( holder ) ;
230 BESDEBUG(
"server",
"BESServerHandler::execute - "
231 <<
"executed successfully" << endl ) ;
235 if( sw && sw->
stop() )
238 "BESServerHandler::execute - executed in "
239 << sw->
seconds() <<
" seconds and "
245 BESDEBUG(
"timing",
"BESServerHandler::execute - "
246 <<
"no timing available" << endl ) ;
253 BESDEBUG(
"server",
"BESServerHandler::execute - "
254 <<
"error occurred" << endl ) ;
261 map<string,string> extensions ;
262 extensions[
"status"] =
"error" ;
265 extensions[
"exit"] =
"true" ;
271 cmd.finish_with_error( status ) ;
277 cout.rdbuf( holder ) ;
285 cout <<
"BES server " << getpid()
286 <<
": Status not OK, dispatcher returned value "
317 << (
void *)
this <<
")" << endl ;