From 6fbd41542beeaf2e73b5a72f28799b3ddbeb60eb Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 4 May 2017 11:52:44 +0200 Subject: [PATCH] [update] Updated verbose plane handler (SGCA) --- central-manager/lib/local/handler.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/central-manager/lib/local/handler.c b/central-manager/lib/local/handler.c index 2c7827a..cf101b3 100644 --- a/central-manager/lib/local/handler.c +++ b/central-manager/lib/local/handler.c @@ -75,13 +75,13 @@ void* managePlane(void* THREADABLE_ARGS){ /* 2.1. Si erreur reception (-1:erreur, 0:fermeture client propre) */ if( read <= 0 ){ - if( DEBUGMOD&BUF ) printf("{tcp_com}(%d) read: %d -> must exit thread\n", index, read); + if( DEBUGMOD&BUF ) printf("{tcp_com}(%d) Error receiving (%d), must exit thread\n", index, read); break; } /* 2.2. Si message trop court */ if( read != PLANE_LEN+1 ){ - if( DEBUGMOD&BUF ) printf("{tcp_com}(%d) read: %d (expected: %d)\n", index, read, (int) (PLANE_LEN+1) ); + if( DEBUGMOD&BUF ) printf("{tcp_com}(%d) Error receiving (%d bytes, but %d expected)\n", index, read, (int) (PLANE_LEN+1) ); continue; } @@ -138,10 +138,11 @@ void* managePlane(void* THREADABLE_ARGS){ /* 4. On copie/met à jour les valeurs */ if( tmpFlags != 0x10 ){ // gestion réponse ctrlTerm - arg->sgca->unit[pindex].flags = tmpFlags; // on met à jour les flags - while( arg->sgca->unit[pindex].thrId == 0xf0 ); // on attend le numéro de thread - pthread_kill(arg->UDPManagers[arg->sgca->unit[pindex].thrId], SIGCONT); // on réveille le thread - arg->sgca->unit[pindex].thrId = 0xf0; // on laisse la place pour qqn d'autre + arg->sgca->unit[pindex].flags = tmpFlags; // on met à jour les flags + while( arg->sgca->unit[pindex].thrId == 0xf0 ); // on attend le numéro de thread + printf("{tcp_com}(%d) Waking up UDP threaad@%d for ctrlTerm response\n", index, arg->sgca->unit[pindex].thrId); + pthread_kill(arg->UDPManagers[(int)arg->sgca->unit[pindex].thrId], SIGCONT); // on réveille le thread + arg->sgca->unit[pindex].thrId = 0xf0; // on laisse la place pour qqn d'autre } memcpy(&arg->sgca->unit[pindex].data, &data, sizeof(struct plane)); @@ -157,21 +158,16 @@ void* managePlane(void* THREADABLE_ARGS){ arg->sgca->unit[pindex].socket = -1; - - - /* [6] On libère la mémoire =========================================================*/ - /* [7] Fermeture de la connection (SOCKET) =========================================================*/ printf("{tcp_com}(%d) Closing communication socket\n", index); close(SOCKET); - /* [n] Arrêt du THREAD ============================================================================*/ /* 1. On met à jour "activeManagers" */