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"
101 int main_process = getpid() ;
103 if( ( pid = fork() ) < 0 )
105 string error(
"fork error" ) ;
106 const char* error_info = strerror( errno ) ;
108 error +=
" " + (string)error_info ;
115 if( ( pid1 = fork() ) < 0 )
119 kill( main_process, 9 ) ;
120 perror(
"fork error" ) ;
131 if( waitpid( pid, NULL, 0 ) != pid )
133 string error(
"waitpid error" ) ;
134 const char *error_info = strerror( errno ) ;
136 error +=
" " + (string)error_info ;
149 string from = strm.str() ;
151 map<string,string> extensions ;
159 done = c->
receive( extensions, &ss ) ;
161 if( extensions[
"status"] == c->
exit() )
172 string cmd_str = ss.str() ;
173 BESDEBUG(
"server",
"BESServerHandler::execute - command = "
174 << cmd_str << endl ) ;
187 std::streambuf *holder ;
188 holder = cout.rdbuf() ;
192 int status = cmd.execute_request( from ) ;
196 BESDEBUG(
"server",
"BESServerHandler::execute - "
197 <<
"executed successfully" << endl ) ;
199 cout.rdbuf( holder ) ;
203 if( sw && sw->
stop() )
206 "BESServerHandler::execute - executed in "
207 << sw->
seconds() <<
" seconds and "
213 BESDEBUG(
"timing",
"BESServerHandler::execute - "
214 <<
"no timing available" << endl ) ;
221 BESDEBUG(
"server",
"BESServerHandler::execute - "
222 <<
"error occurred" << endl ) ;
229 map<string,string> extensions ;
230 extensions[
"status"] =
"error" ;
233 extensions[
"exit"] =
"true" ;
239 cmd.finish_with_error( status ) ;
245 cout.rdbuf( holder ) ;
251 cout <<
"BES server " << getpid()
252 <<
": Status not OK, dispatcher returned value "
281 << (
void *)
this <<
")" << endl ;