From 5ccdf6dd987be086a8712a4960f770122b1b499b Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 15 Aug 2008 09:37:36 +0000 Subject: Changes for read-loop-server. --- server/src/daemon.cc | 2 +- server/src/pracrod.cc | 25 ++++++ server/src/saxparser.h | 1 - server/src/server.cc | 103 ++++++++++++++++------- server/src/tcpsocket.cc | 178 +++++++++++++++++++++++++++------------- server/src/tcpsocket.h | 7 +- server/src/transactionparser.cc | 42 +++++++++- server/src/transactionparser.h | 6 +- server/xml/macros/example.xml | 93 +++++++++++++++++---- 9 files changed, 343 insertions(+), 114 deletions(-) diff --git a/server/src/daemon.cc b/server/src/daemon.cc index 655a234..6aed66e 100644 --- a/server/src/daemon.cc +++ b/server/src/daemon.cc @@ -153,7 +153,7 @@ int Daemon::run(const char *user, const char* group, bool detach) setsid(); signal (SIGTERM, SIG_IGN); - signal (SIGHUP, SIG_IGN); + // signal (SIGHUP, SIG_IGN); if(detach) signal (SIGINT, SIG_IGN); // Don't disable Ctrl+c when running in foreground. return daemon_main(); diff --git a/server/src/pracrod.cc b/server/src/pracrod.cc index 6ee1817..6ca21db 100644 --- a/server/src/pracrod.cc +++ b/server/src/pracrod.cc @@ -33,6 +33,9 @@ #include #include +// For waitpid +#include + // For signal #include @@ -85,6 +88,24 @@ static const char usage_str[] = ConfigurationParser *configparser = NULL; +bool pracro_is_running = true; + +void ctrl_c(int) +{ + // printf("Ctrl+c\n"); + pracro_is_running = false; +} + +void childwait(int) +{ + // printf("childwait\n"); + + pid_t pid; + while((pid = waitpid(-1, NULL, WNOHANG)) > 0) { + // printf("\tOne down!\n"); + } +} + void reload(int) { int port; @@ -183,6 +204,10 @@ int main(int argc, char *argv[]) group = strdup(Conf::server_group.c_str()); } + signal(SIGHUP, reload); + signal(SIGCLD, childwait); + if(foreground) signal (SIGINT, ctrl_c); + PracroDaemon daemon; daemon.run(user, group, !foreground); diff --git a/server/src/saxparser.h b/server/src/saxparser.h index 2ee4f43..67a86b7 100644 --- a/server/src/saxparser.h +++ b/server/src/saxparser.h @@ -47,7 +47,6 @@ public: protected: virtual int readData(char *data, size_t size) { return 0; } -private: XML_Parser p; }; diff --git a/server/src/server.cc b/server/src/server.cc index a419181..d2921b8 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -52,6 +52,8 @@ static std::string error_box(std::string message) { std::string errorbox = + "\n" + "\n" " \n" " \n" " \n" @@ -59,7 +61,8 @@ static std::string error_box(std::string message) "