diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2011-01-25 16:20:29 +0000 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2011-01-25 16:20:29 +0000 |
commit | 6374516e063e49ca313329a68f9c5f0dd16713ae (patch) | |
tree | ecfc6c8686bf9aa2d49a40ff2181ccfbd3448e06 | |
parent | dcda721939bc81c58f66850aa21f6b6f0c64cab3 (diff) | |
download | 2011-usi-6374516e063e49ca313329a68f9c5f0dd16713ae.tar.gz 2011-usi-6374516e063e49ca313329a68f9c5f0dd16713ae.tar.bz2 2011-usi-6374516e063e49ca313329a68f9c5f0dd16713ae.zip |
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).
git-svn-id: file:///var/svn/2011-usi/trunk@16 db941bf7-0cb3-4dda-9634-87faf64f93a7
-rw-r--r-- | app/v3_c/src/CMakeLists.txt | 4 | ||||
-rw-r--r-- | app/v3_c/src/include/tcpserver.h (renamed from app/v3_c/src/tcpserver.h.in) | 0 | ||||
-rw-r--r-- | app/v3_c/src/main.c | 27 | ||||
-rw-r--r-- | app/v3_c/src/myhttpd.h.in | 11 | ||||
-rw-r--r-- | app/v3_c/src/tcpserver.c | 22 | ||||
-rw-r--r-- | app/v3_c/src/usi2011jjl.h.in | 8 |
6 files changed, 36 insertions, 36 deletions
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/tcpserver.h.in b/app/v3_c/src/include/tcpserver.h index 14b6736..14b6736 100644 --- a/app/v3_c/src/tcpserver.h.in +++ b/app/v3_c/src/include/tcpserver.h 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 <stdio.h> +#include <stdlib.h> +#include <signal.h> + +#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 <strings.h> #include <errno.h> #include <unistd.h> -#include <signal.h> -#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/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 + |