Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
df418f28
Commit
df418f28
authored
23 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Added thread, socket, and client counters.
parent
1e07664f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/sbbscon.c
+105
-8
105 additions, 8 deletions
src/sbbs3/sbbscon.c
with
105 additions
and
8 deletions
src/sbbs3/sbbscon.c
+
105
−
8
View file @
df418f28
...
...
@@ -43,19 +43,25 @@
#include
"services.h"
/* services_startup_t, services_thread */
/* Constants */
#define SBBSCON_VERSION "1.
1
0"
#define SBBSCON_VERSION "1.
2
0"
/* Global variables */
BOOL
bbs_running
=
FALSE
;
bbs_startup_t
bbs_startup
;
uint
bbs_client_count
=
0
;
BOOL
ftp_running
=
FALSE
;
ftp_startup_t
ftp_startup
;
uint
ftp_client_count
=
0
;
BOOL
mail_running
=
FALSE
;
mail_startup_t
mail_startup
;
uint
mail_client_count
=
0
;
BOOL
services_running
=
FALSE
;
services_startup_t
services_startup
;
uint
services_client_count
=
0
;
uint
thread_count
=
1
;
uint
socket_count
=
0
;
static
const
char
*
prompt
=
"
Command
(?=Help): "
;
static
const
char
*
prompt
=
"
[Threads: %3d Sockets: %3d Clients: %3d]
(?=Help): "
;
static
const
char
*
usage
=
"
\n
usage: %s [[option] [...]]
\n
"
"
\n
options:
\n\n
"
...
...
@@ -83,17 +89,46 @@ static void lputs(char *str)
pthread_mutex_lock
(
&
mutex
);
printf
(
"
\r
%*s
\r
%s
\n
"
,
strlen
(
prompt
),
""
,
str
);
printf
(
prompt
);
printf
(
prompt
,
thread_count
,
socket_count
,
bbs_client_count
+
ftp_client_count
+
mail_client_count
+
services_client_count
);
fflush
(
stdout
);
pthread_mutex_unlock
(
&
mutex
);
}
static
void
thread_up
(
BOOL
up
)
{
if
(
up
==
TRUE
)
{
/* Add setuid code here */
;
static
pthread_mutex_t
mutex
;
static
BOOL
mutex_initialized
;
if
(
!
mutex_initialized
)
{
pthread_mutex_init
(
&
mutex
,
NULL
);
mutex_initialized
=
TRUE
;
}
pthread_mutex_lock
(
&
mutex
);
if
(
up
)
thread_count
++
;
else
if
(
thread_count
>
0
)
thread_count
--
;
pthread_mutex_unlock
(
&
mutex
);
}
static
void
socket_open
(
BOOL
open
)
{
static
pthread_mutex_t
mutex
;
static
BOOL
mutex_initialized
;
if
(
!
mutex_initialized
)
{
pthread_mutex_init
(
&
mutex
,
NULL
);
mutex_initialized
=
TRUE
;
}
pthread_mutex_lock
(
&
mutex
);
if
(
open
)
socket_count
++
;
else
if
(
socket_count
>
0
)
socket_count
--
;
pthread_mutex_unlock
(
&
mutex
);
}
/************************************************/
...
...
@@ -144,6 +179,20 @@ static void bbs_terminated(int code)
bbs_running
=
FALSE
;
}
static
void
bbs_clients
(
int
clients
)
{
static
pthread_mutex_t
mutex
;
static
BOOL
mutex_initialized
;
if
(
!
mutex_initialized
)
{
pthread_mutex_init
(
&
mutex
,
NULL
);
mutex_initialized
=
TRUE
;
}
pthread_mutex_lock
(
&
mutex
);
bbs_client_count
=
clients
;
pthread_mutex_unlock
(
&
mutex
);
}
/****************************************************************************/
/* FTP local/log print routine */
/****************************************************************************/
...
...
@@ -180,6 +229,20 @@ static void ftp_terminated(int code)
ftp_running
=
FALSE
;
}
static
void
ftp_clients
(
int
clients
)
{
static
pthread_mutex_t
mutex
;
static
BOOL
mutex_initialized
;
if
(
!
mutex_initialized
)
{
pthread_mutex_init
(
&
mutex
,
NULL
);
mutex_initialized
=
TRUE
;
}
pthread_mutex_lock
(
&
mutex
);
ftp_client_count
=
clients
;
pthread_mutex_unlock
(
&
mutex
);
}
/****************************************************************************/
/* Mail Server local/log print routine */
/****************************************************************************/
...
...
@@ -216,6 +279,20 @@ static void mail_terminated(int code)
mail_running
=
FALSE
;
}
static
void
mail_clients
(
int
clients
)
{
static
pthread_mutex_t
mutex
;
static
BOOL
mutex_initialized
;
if
(
!
mutex_initialized
)
{
pthread_mutex_init
(
&
mutex
,
NULL
);
mutex_initialized
=
TRUE
;
}
pthread_mutex_lock
(
&
mutex
);
mail_client_count
=
clients
;
pthread_mutex_unlock
(
&
mutex
);
}
/****************************************************************************/
/* Services local/log print routine */
/****************************************************************************/
...
...
@@ -252,6 +329,20 @@ static void services_terminated(int code)
services_running
=
FALSE
;
}
static
void
services_clients
(
int
clients
)
{
static
pthread_mutex_t
mutex
;
static
BOOL
mutex_initialized
;
if
(
!
mutex_initialized
)
{
pthread_mutex_init
(
&
mutex
,
NULL
);
mutex_initialized
=
TRUE
;
}
pthread_mutex_lock
(
&
mutex
);
services_client_count
=
clients
;
pthread_mutex_unlock
(
&
mutex
);
}
/****************************************************************************/
/* Event thread local/log print routine */
/****************************************************************************/
...
...
@@ -329,12 +420,12 @@ int main(int argc, char** argv)
bbs_startup
.
event_log
=
event_lputs
;
bbs_startup
.
started
=
bbs_started
;
bbs_startup
.
terminated
=
bbs_terminated
;
bbs_startup
.
clients
=
bbs_clients
;
bbs_startup
.
thread_up
=
thread_up
;
bbs_startup
.
socket_open
=
socket_open
;
/* These callbacks haven't been created yet
bbs_startup.status=bbs_status;
bbs_startup.clients=bbs_clients;
bbs_startup.client_on=client_on;
bbs_startup.socket_open=socket_open;
*/
strcpy
(
bbs_startup
.
ctrl_dir
,
ctrl_dir
);
...
...
@@ -344,7 +435,9 @@ int main(int argc, char** argv)
ftp_startup
.
lputs
=
ftp_lputs
;
ftp_startup
.
started
=
ftp_started
;
ftp_startup
.
terminated
=
ftp_terminated
;
ftp_startup
.
clients
=
ftp_clients
;
ftp_startup
.
thread_up
=
thread_up
;
ftp_startup
.
socket_open
=
socket_open
;
ftp_startup
.
options
=
FTP_OPT_INDEX_FILE
|
FTP_OPT_ALLOW_QWK
;
strcpy
(
ftp_startup
.
index_file_name
,
"00index"
);
strcpy
(
ftp_startup
.
ctrl_dir
,
ctrl_dir
);
...
...
@@ -355,7 +448,9 @@ int main(int argc, char** argv)
mail_startup
.
lputs
=
mail_lputs
;
mail_startup
.
started
=
mail_started
;
mail_startup
.
terminated
=
mail_terminated
;
mail_startup
.
clients
=
mail_clients
;
mail_startup
.
thread_up
=
thread_up
;
mail_startup
.
socket_open
=
socket_open
;
mail_startup
.
options
|=
MAIL_OPT_ALLOW_POP3
;
/* Spam filtering */
mail_startup
.
options
|=
MAIL_OPT_USE_RBL
;
/* Realtime Blackhole List */
...
...
@@ -394,7 +489,9 @@ int main(int argc, char** argv)
services_startup
.
lputs
=
services_lputs
;
services_startup
.
started
=
services_started
;
services_startup
.
terminated
=
services_terminated
;
services_startup
.
clients
=
services_clients
;
services_startup
.
thread_up
=
thread_up
;
services_startup
.
socket_open
=
socket_open
;
strcpy
(
services_startup
.
ctrl_dir
,
ctrl_dir
);
/* Process arguments */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment