Commit 4c54a03d authored by rswindell's avatar rswindell
Browse files

Judicious (even excessive?) use of the volatile keyword on variables that are

commonly modified by multiple threads, potentially simultaneously, resulting in
bad values (e.g. active_clients = -1).
Updated copyright date to 2011.
Fixed Win32 compile bug in main.cpp introduced in last commit.
Eliminated some unused variables and updated some times (e.g. ulong in place
fo uint32_t).
parent 6727c5a5
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -146,7 +146,7 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
}
if(!strcmp(sp,"UPTIME")) {
extern time_t uptime;
extern volatile time_t uptime;
time_t up=time(NULL)-uptime;
if(up<0)
up=0;
......@@ -164,7 +164,7 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
}
if(!strcmp(sp,"SERVED")) {
extern DWORD served;
extern volatile ulong served;
safe_snprintf(str,maxlen,"%lu",served);
return(str);
}
......
......@@ -79,12 +79,12 @@
static ftp_startup_t* startup=NULL;
static scfg_t scfg;
static SOCKET server_socket=INVALID_SOCKET;
static ulong active_clients=0;
static ulong sockets=0;
static ulong thread_count=0;
static time_t uptime=0;
static ulong served=0;
static BOOL terminate_server=FALSE;
static volatile ulong active_clients=0;
static volatile ulong sockets=0;
static volatile ulong thread_count=0;
static volatile time_t uptime=0;
static volatile ulong served=0;
static volatile BOOL terminate_server=FALSE;
static char revision[16];
static char *text[TOTAL_TEXT];
static str_list_t recycle_semfiles;
......
......@@ -80,7 +80,7 @@ static char* badrsp_err = "%s replied with:\r\n\"%s\"\r\n"
"instead of the expected reply:\r\n\"%s ...\"";
#define TIMEOUT_THREAD_WAIT 60 /* Seconds */
#define DNSBL_THROTTLE_VALUE 5000 /* Milliseconds */
#define DNSBL_THROTTLE_VALUE 1000 /* Milliseconds */
#define SPAM_HASH_SUBJECT_MIN_LEN 10 /* characters */
#define STATUS_WFC "Listening"
......@@ -90,34 +90,34 @@ static scfg_t scfg;
static SOCKET server_socket=INVALID_SOCKET;
static SOCKET submission_socket=INVALID_SOCKET;
static SOCKET pop3_socket=INVALID_SOCKET;
static ulong active_clients=0;
static int active_sendmail=0;
static ulong thread_count=0;
static BOOL sendmail_running=FALSE;
static BOOL terminate_server=FALSE;
static BOOL terminate_sendmail=FALSE;
static volatile ulong active_clients=0;
static volatile int active_sendmail=0;
static volatile ulong thread_count=0;
static volatile BOOL sendmail_running=FALSE;
static volatile BOOL terminate_server=FALSE;
static volatile BOOL terminate_sendmail=FALSE;
static sem_t sendmail_wakeup_sem;
static char revision[16];
static time_t uptime;
static volatile time_t uptime;
static str_list_t recycle_semfiles;
static str_list_t shutdown_semfiles;
static int mailproc_count;
static js_server_props_t js_server_props;
struct {
ulong sockets;
ulong errors;
ulong crit_errors;
ulong connections_ignored;
ulong connections_refused;
ulong connections_served;
ulong pop3_served;
ulong smtp_served;
volatile ulong sockets;
volatile ulong errors;
volatile ulong crit_errors;
volatile ulong connections_ignored;
volatile ulong connections_refused;
volatile ulong connections_served;
volatile ulong pop3_served;
volatile ulong smtp_served;
/* SMTP: */
ulong sessions_refused;
ulong msgs_ignored;
ulong msgs_refused;
ulong msgs_received;
volatile ulong sessions_refused;
volatile ulong msgs_ignored;
volatile ulong msgs_refused;
volatile ulong msgs_received;
} stats;
struct mailproc {
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -76,11 +76,11 @@
#define SSH_END()
#endif
time_t uptime=0;
DWORD served=0;
volatile time_t uptime=0;
volatile ulong served=0;
static ulong node_threads_running=0;
static ulong thread_count=0;
static volatile ulong node_threads_running=0;
static volatile ulong thread_count=0;
char lastuseron[LEN_ALIAS+1]; /* Name of user last online */
RingBuf* node_inbuf[MAX_NODES];
......@@ -305,7 +305,7 @@ DLLEXPORT void DLLCALL sbbs_srand()
close(rf);
}
#else
seed = time(NULL) ^ (DWORD)GetCurrentThreadId()
seed = time(NULL) ^ (DWORD)GetCurrentThreadId();
#endif
srand(seed);
......
......@@ -969,7 +969,7 @@ extern "C" {
const char* version_detail;
uint32_t* interface_addr;
uint32_t* options;
ulong* clients;
volatile ulong* clients;
} js_server_props_t;
enum {
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -58,8 +58,8 @@
#define VERSION_NOTICE "Synchronet BBS for "PLATFORM_DESC\
" Version " VERSION
#define SYNCHRONET_CRC 0x9BCDD162
#define COPYRIGHT_NOTICE "Copyright 2010 Rob Swindell"
#define COPYRIGHT_CRC 0xA053FC9F
#define COPYRIGHT_NOTICE "Copyright 2011 Rob Swindell"
#define COPYRIGHT_CRC 0x3D5C1DE9
#define Y2K_2DIGIT_WINDOW 70
......@@ -86,7 +86,7 @@ typedef struct {
ulong gc_interval;
ulong gc_attempts;
BOOL auto_terminate;
BOOL* terminated;
volatile BOOL* terminated;
str_list_t exit_func;
} js_branch_t;
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -69,10 +69,10 @@
static services_startup_t* startup=NULL;
static scfg_t scfg;
static uint32_t sockets=0;
static BOOL terminated=FALSE;
static time_t uptime=0;
static uint32_t served=0;
static volatile ulong sockets=0;
static volatile BOOL terminated=FALSE;
static volatile time_t uptime=0;
static volatile ulong served=0;
static char revision[16];
static str_list_t recycle_semfiles;
static str_list_t shutdown_semfiles;
......@@ -91,11 +91,11 @@ typedef struct {
js_startup_t js;
js_server_props_t js_server_props;
/* These are run-time state and stat vars */
ulong clients;
ulong served;
SOCKET socket;
BOOL running;
BOOL terminated;
volatile ulong clients;
volatile ulong served;
volatile SOCKET socket;
volatile BOOL running;
volatile BOOL terminated;
} service_t;
typedef struct {
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -96,15 +96,14 @@ enum {
};
static scfg_t scfg;
static BOOL scfg_reloaded=TRUE;
static BOOL http_logging_thread_running=FALSE;
static ulong active_clients=0;
static ulong sockets=0;
static BOOL terminate_server=FALSE;
static BOOL terminate_http_logging_thread=FALSE;
static ulong thread_count=0;
static SOCKET server_socket=INVALID_SOCKET;
static SOCKET server_socket6=INVALID_SOCKET;
static volatile BOOL http_logging_thread_running=FALSE;
static volatile ulong active_clients=0;
static volatile ulong sockets=0;
static volatile BOOL terminate_server=FALSE;
static volatile BOOL terminate_http_logging_thread=FALSE;
static volatile ulong thread_count=0;
static volatile SOCKET server_socket=INVALID_SOCKET;
static volatile SOCKET server_socket6=INVALID_SOCKET;
static char revision[16];
static char root_dir[MAX_PATH+1];
static char error_dir[MAX_PATH+1];
......@@ -112,14 +111,14 @@ static char temp_dir[MAX_PATH+1];
static char cgi_dir[MAX_PATH+1];
static char cgi_env_ini[MAX_PATH+1];
static char default_auth_list[MAX_PATH+1];
static time_t uptime=0;
static ulong served=0;
static volatile time_t uptime=0;
static volatile ulong served=0;
static web_startup_t* startup=NULL;
static js_server_props_t js_server_props;
static str_list_t recycle_semfiles;
static str_list_t shutdown_semfiles;
static str_list_t cgi_env;
static ulong session_threads=0;
static volatile ulong session_threads=0;
static named_string_t** mime_types;
static named_string_t** cgi_handlers;
......@@ -5478,7 +5477,6 @@ void DLLCALL web_server(void* arg)
cleanup(1);
return;
}
scfg_reloaded=TRUE;
lprintf(LOG_DEBUG,"Temporary file directory: %s", temp_dir);
MKDIR(temp_dir);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment