From 6374516e063e49ca313329a68f9c5f0dd16713ae Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Tue, 25 Jan 2011 16:20:29 +0000 Subject: Correction de quelques trucs oubliés dans le refactoring précédent. La gestion de signaux est remontée dans le main (pas fonctionnellement lié au serveur TCP). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///var/svn/2011-usi/trunk@16 db941bf7-0cb3-4dda-9634-87faf64f93a7 --- app/v3_c/src/CMakeLists.txt | 4 ++-- app/v3_c/src/include/tcpserver.h | 10 ++++++++++ app/v3_c/src/main.c | 27 +++++++++++++++++++++++++-- app/v3_c/src/myhttpd.h.in | 11 ----------- app/v3_c/src/tcpserver.c | 22 +--------------------- app/v3_c/src/tcpserver.h.in | 10 ---------- app/v3_c/src/usi2011jjl.h.in | 8 ++++++++ 7 files changed, 46 insertions(+), 46 deletions(-) create mode 100644 app/v3_c/src/include/tcpserver.h delete mode 100644 app/v3_c/src/myhttpd.h.in delete mode 100644 app/v3_c/src/tcpserver.h.in create mode 100644 app/v3_c/src/usi2011jjl.h.in (limited to 'app/v3_c/src') diff --git a/app/v3_c/src/CMakeLists.txt b/app/v3_c/src/CMakeLists.txt index 7953490..0360413 100644 --- a/app/v3_c/src/CMakeLists.txt +++ b/app/v3_c/src/CMakeLists.txt @@ -3,8 +3,8 @@ set(SRC_COMMON utils.c) # configure a header file to pass some of the CMake settings # to the source code configure_file ( - "tcpserver.h.in" - "${PROJECT_BINARY_DIR}/tcpserver.h" + "usi2011jjl.h.in" + "${PROJECT_BINARY_DIR}/usi2011jjl.h" ) add_executable(usi2011jjl main.c tcpserver.c dispatcher.c ${SRC_COMMON} ) diff --git a/app/v3_c/src/include/tcpserver.h b/app/v3_c/src/include/tcpserver.h new file mode 100644 index 0000000..14b6736 --- /dev/null +++ b/app/v3_c/src/include/tcpserver.h @@ -0,0 +1,10 @@ +#ifndef TCPSERVER_H +#define TCPSERVER_H + +#define LISTEN_PORT 8080 +#define LISTEN_BACKLOG 5 + +int tcpserver(); + +#endif + diff --git a/app/v3_c/src/main.c b/app/v3_c/src/main.c index c88485e..d952730 100644 --- a/app/v3_c/src/main.c +++ b/app/v3_c/src/main.c @@ -1,9 +1,32 @@ +#include +#include +#include + +#include "usi2011jjl.h" +#include "utils.h" #include "tcpserver.h" -#define USI2011JJL_VERSION_MAJOR @USI2011JJL_VERSION_MAJOR@ -#define USI2011JJL_VERSION_MINOR @USI2011JJL_VERSION_MINOR@ +extern int end; + +void _signals(int signum) { + static int force=0; + if (0) printf("signal %i\n", signum); + + if(!force) { + end=1; + force=1; + logs("Tentative d'arrêt soft du serveur..."); + } else { + logs("Arrêt d'urgence du serveur"); + exit(1); + } +} int main() { + // On active la gestion des signaux + signal(2,_signals); + + // On exécute le serveur TCP return tcpserver(); } diff --git a/app/v3_c/src/myhttpd.h.in b/app/v3_c/src/myhttpd.h.in deleted file mode 100644 index ce022b8..0000000 --- a/app/v3_c/src/myhttpd.h.in +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef MYHTTPD_H -#define MYHTTPD_H - -#define MYHTTPD_VERSION_MAJOR @NetLemmings_VERSION_MAJOR@ -#define MYHTTPD_VERSION_MINOR @NetLemmings_VERSION_MINOR@ - -#define LISTEN_PORT 8080 -#define LISTEN_BACKLOG 5 - -#endif - diff --git a/app/v3_c/src/tcpserver.c b/app/v3_c/src/tcpserver.c index 53b86a9..32b9138 100644 --- a/app/v3_c/src/tcpserver.c +++ b/app/v3_c/src/tcpserver.c @@ -7,30 +7,13 @@ #include #include #include -#include -#include "utils.h" #include "tcpserver.h" +#include "utils.h" #include "dispatcher.h" int end=0; -void _signals(int signum) { - static int force=0; - - if (0) printf("signal %i\n", signum); - - if(!force) { - end=1; - force=1; - logs("Tentative d'arrêt soft du serveur..."); - } else { - logs("Arrêt d'urgence du serveur"); - exit(1); - } -} - - int tcpserver() { int res; int sockServ, sockCli; @@ -53,9 +36,6 @@ int tcpserver() { listen(sockServ,LISTEN_BACKLOG); if (res < 0) { perror("listen"); return(4); } - // On active la gestion des signaux - signal(2,_signals); - res=initDispatcher(); if (res != 0 ) { #ifdef DEBUG diff --git a/app/v3_c/src/tcpserver.h.in b/app/v3_c/src/tcpserver.h.in deleted file mode 100644 index 14b6736..0000000 --- a/app/v3_c/src/tcpserver.h.in +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef TCPSERVER_H -#define TCPSERVER_H - -#define LISTEN_PORT 8080 -#define LISTEN_BACKLOG 5 - -int tcpserver(); - -#endif - diff --git a/app/v3_c/src/usi2011jjl.h.in b/app/v3_c/src/usi2011jjl.h.in new file mode 100644 index 0000000..d2d9bb6 --- /dev/null +++ b/app/v3_c/src/usi2011jjl.h.in @@ -0,0 +1,8 @@ +#ifndef USI2011JJL_H +#define USI2011JJL_H + +#define USI2011JJL_VERSION_MAJOR @USI2011JJL_VERSION_MAJOR@ +#define USI2011JJL_VERSION_MINOR @USI2011JJL_VERSION_MINOR@ + +#endif + -- cgit v1.2.3