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
cd982a30
Commit
cd982a30
authored
21 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Using semaphore to terminate sendmail_thread more rapidly.
parent
395b18be
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/mailsrvr.c
+8
-3
8 additions, 3 deletions
src/sbbs3/mailsrvr.c
with
8 additions
and
3 deletions
src/sbbs3/mailsrvr.c
+
8
−
3
View file @
cd982a30
...
...
@@ -96,6 +96,7 @@ static BOOL sendmail_running=FALSE;
static
DWORD
sockets
=
0
;
static
DWORD
served
=
0
;
static
BOOL
recycle_server
=
FALSE
;
static
sem_t
terminated_sem
;
static
char
revision
[
16
];
typedef
struct
{
...
...
@@ -2921,7 +2922,7 @@ static void sendmail_thread(void* arg)
while
(
server_socket
!=
INVALID_SOCKET
)
{
if
(
startup
->
options
&
MAIL_OPT_NO_SENDMAIL
)
{
mswait
(
1000
);
sem_trywait_block
(
&
terminated_sem
,
1000
);
continue
;
}
...
...
@@ -2946,7 +2947,7 @@ static void sendmail_thread(void* arg)
if
(
first_cycle
)
first_cycle
=
FALSE
;
else
mswait
(
startup
->
sem_chk_freq
*
1000
);
sem_trywait_block
(
&
terminated_sem
,
startup
->
sem_chk_freq
*
1000
);
sprintf
(
smb
.
file
,
"%smail"
,
scfg
.
data_dir
);
smb
.
retry_time
=
scfg
.
smb_retry_time
;
...
...
@@ -3233,6 +3234,7 @@ void DLLCALL mail_terminate(void)
mail_close_socket
(
server_socket
);
server_socket
=
INVALID_SOCKET
;
}
sem_post
(
&
terminated_sem
);
}
static
void
cleanup
(
int
code
)
...
...
@@ -3256,6 +3258,7 @@ static void cleanup(int code)
lprintf
(
"0000 !WSACleanup ERROR %d"
,
ERROR_VALUE
);
#endif
sem_destroy
(
&
terminated_sem
);
thread_down
();
status
(
"Down"
);
lprintf
(
"#### Mail Server thread terminated (%u threads remain, %lu clients served)"
...
...
@@ -3417,6 +3420,8 @@ void DLLCALL mail_server(void* arg)
active_clients
=
0
;
update_clients
();
sem_init
(
&
terminated_sem
,
0
,
0
);
/* open a socket and wait for a client */
server_socket
=
mail_open_socket
(
SOCK_STREAM
);
...
...
@@ -3705,7 +3710,7 @@ void DLLCALL mail_server(void* arg)
if
(
sendmail_running
)
{
mail_close_socket
(
server_socket
);
server_socket
=
INVALID_SOCKET
;
/* necessary to terminate sendmail_thread */
mswait
(
2000
);
mswait
(
1
);
}
if
(
sendmail_running
)
{
lprintf
(
"0000 Waiting for SendMail thread to terminate..."
);
...
...
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