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() ;
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" ;
245 cout.rdbuf( holder ) ;
251 cout <<
"BES server " << getpid()
252 <<
": Status not OK, dispatcher returned value " 281 << (
void *)
this <<
")" << endl ;
#define BES_SYNTAX_USER_ERROR
virtual int execute_request(const string &from)
Override execute_request in order to register memory pool.
#define BESISDEBUG(x)
macro used to determine if the specified debug context is set
exception thrown if inernal error encountered
#define BES_INTERNAL_ERROR
virtual int microseconds()
virtual void sendExtensions(map< string, string > &extensions)=0
virtual void closeConnection()=0
#define BES_FORBIDDEN_ERROR
virtual string get_message()
get the error message for this exception
virtual int finish_with_error(int status)
Abstract exception class for the BES with basic string message.
virtual void handle(Connection *c)
virtual unsigned int getSendChunkSize()=0
static ostream & LMarg(ostream &strm)
#define SERVER_EXIT_FATAL_CAN_NOT_START
#define BES_INTERNAL_FATAL_ERROR
virtual void dump(ostream &strm) const
dumps information about this object
#define CHILD_SUBPROCESS_READY
Entry point into BES using xml document requests.
virtual int getSocketDescriptor()
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
#define BES_NOT_FOUND_ERROR
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
#define SERVER_EXIT_CHILD_SUBPROCESS_NORMAL_TERMINATION
#define SERVER_EXIT_CHILD_SUBPROCESS_ABNORMAL_TERMINATION
virtual Socket * getSocket()
static BESKeys * TheKeys()
virtual bool receive(map< string, string > &extensions, ostream *strm=0)=0