summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-12-07 15:25:57 -0500
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-12-07 15:25:57 -0500
commit92c4bc01cfa89aa3f16ee6e29f6be67ff5998f22 (patch)
tree739b5f1b661e7120842eda15740e9f2c897cd662
parent4985de53421e6e9e9fa6f11f42918de76f141f54 (diff)
move MAX_SESSIONS macroINSTRUMENT_5_0_0
-rw-r--r--globals.h4
-rw-r--r--instr-daemon.c19
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; count++) {
+ for(count=0; count<MAX_SESSIONS; count++) {
//allocate on the heap and deallocate in response.c, cbClientOutput()
char *toSend = realloc(NULL, size+1);
memcpy(toSend, message, size+1);
@@ -65,7 +64,7 @@ static int pullIndex(GThread* id)
int i=0,ret=-1;
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
g_static_mutex_lock (&mutex);
- for(i=0; i<maxConn; i++)
+ for(i=0; i<MAX_SESSIONS; i++)
if(peers[i] == id) {
peers[i] = (GThread*)0;
ret=i;
@@ -84,7 +83,7 @@ static int pushIndex(GThread* id)
int i=0,ret=-1;
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
g_static_mutex_lock (&mutex);
- for(i=0; i<maxConn; i++)
+ for(i=0; i<MAX_SESSIONS; i++)
if(peers[i] == 0) {
peers[i] = id;
ret=i;
@@ -102,7 +101,7 @@ incomingConnection (GSocketService *service,
GSocketListener *listener,
gpointer user_data)
{
- if(globals.Remote.terminal_connections +1 > 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<maxConn; idx++) {
+ peers = malloc(sizeof(GThread*) * MAX_SESSIONS);
+ for(idx=0; idx<MAX_SESSIONS; idx++) {
peers[idx] = 0;
stdinQueue[idx] = g_async_queue_new();
}
//create a threaded service
- service = g_threaded_socket_service_new (maxConn+1);
+ service = g_threaded_socket_service_new (MAX_SESSIONS+1);
if (!g_socket_listener_add_inet_port (G_SOCKET_LISTENER (service),
port,
NULL,