From c7b28232c2adf0313913e8377d1b5ad0805f663b Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Fri, 14 Nov 2003 22:37:01 +0000 Subject: [PATCH] add unique session ids --- src/configfile.c | 14 ++++++++++++++ src/configfile.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/configfile.c b/src/configfile.c index 74134958..0dd7a3e0 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -92,6 +92,7 @@ typedef struct tag_scan_status { SCAN_STATUS scan_status = { 0,0,NULL,NULL }; pthread_mutex_t scan_mutex = PTHREAD_MUTEX_INITIALIZER; +int config_session=0; #define MAX_LINE 1024 @@ -669,3 +670,16 @@ int config_mutex_unlock(void) { return 0; } + +/* + * return the next available session ID + */ +int config_get_next_session(void) { + int session; + config_mutex_lock(); + + session=++config_session; + config_mutex_unlock(); + + return session; +} diff --git a/src/configfile.h b/src/configfile.h index ed815ace..d8a80786 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -30,5 +30,6 @@ extern int config_write(CONFIG *pconfig); extern int config_auth(char *user, char *password); extern void config_handler(WS_CONNINFO *pwsc); extern void config_set_status(WS_CONNINFO *pwsc, int session, char *fmt, ...); +extern int config_get_next_session(void); #endif /* _CONFIGFILE_H_ */