From 92c4bc01cfa89aa3f16ee6e29f6be67ff5998f22 Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Fri, 7 Dec 2012 15:25:57 -0500 Subject: move MAX_SESSIONS macro --- globals.h | 4 ++++ instr-daemon.c | 19 +++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/globals.h b/globals.h index afca843..239ac22 100644 --- a/globals.h +++ b/globals.h @@ -768,6 +768,10 @@ typedef struct { } TimeStruct; +// maximum number of ssh/getty sessions. +// same as max number of vxi sessions +#define MAX_SESSIONS 8 + typedef struct { int terminal_connections; int vxi_connections; diff --git a/instr-daemon.c b/instr-daemon.c index 727b19d..a74cdbd 100644 --- a/instr-daemon.c +++ b/instr-daemon.c @@ -25,7 +25,6 @@ static gboolean finish_boot (void); int port=3333; //port to listen -int maxConn=8; //max connections - 8 guint signalMyCb; //signal to register which is used in cbClientInput(), step 10 from requirements GAsyncQueue** stdinQueue=NULL; @@ -44,7 +43,7 @@ void send_message(gchar* message) } //send the final buffer to the queue - for(count=0; count maxConn) { + if(globals.Remote.terminal_connections +1 > MAX_SESSIONS) { g_print_debug("Connection closed. Max reached\n"); return TRUE; } @@ -253,17 +252,17 @@ int main(int argc, char **argv) int idx=0; - //allocate a maxConn queue on the heap - stdinQueue = malloc(sizeof(struct GAsyncQueue*) * maxConn); + //allocate a MAX_SESSIONS queue on the heap + stdinQueue = malloc(sizeof(struct GAsyncQueue*) * MAX_SESSIONS); //allocate peers vector on the heap - peers = malloc(sizeof(GThread*) * maxConn); - for(idx=0; idx