Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
149e73aa
Commit
149e73aa
authored
Jan 13, 2006
by
rswindell
Browse files
fmutex() now supports an option max_age argument (to detect and remove stale
mutex files).
parent
5f0c129a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
src/sbbs3/main.cpp
src/sbbs3/main.cpp
+3
-3
src/sbbs3/nopen.c
src/sbbs3/nopen.c
+7
-2
src/sbbs3/nopen.h
src/sbbs3/nopen.h
+2
-2
No files found.
src/sbbs3/main.cpp
View file @
149e73aa
...
...
@@ -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 200
5
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 200
6
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 *
...
...
@@ -1734,7 +1734,7 @@ void event_thread(void* arg)
getuserdat
(
&
sbbs
->
cfg
,
&
sbbs
->
useron
);
if
(
sbbs
->
useron
.
number
&&
flength
(
g
.
gl_pathv
[
i
])
>
0
)
{
sprintf
(
semfile
,
"%s.lock"
,
g
.
gl_pathv
[
i
]);
if
(
!
fmutex
(
semfile
,
startup
->
host_name
))
if
(
!
fmutex
(
semfile
,
startup
->
host_name
,
24
*
60
*
60
))
continue
;
sbbs
->
online
=
ON_LOCAL
;
eprintf
(
LOG_INFO
,
"Un-packing QWK Reply packet from %s"
,
sbbs
->
useron
.
alias
);
...
...
@@ -1758,7 +1758,7 @@ void event_thread(void* arg)
eprintf
(
LOG_DEBUG
,
"QWK pack semaphore signaled: %s"
,
g
.
gl_pathv
[
i
]);
sbbs
->
useron
.
number
=
atoi
(
g
.
gl_pathv
[
i
]
+
offset
);
sprintf
(
semfile
,
"%spack%04u.lock"
,
sbbs
->
cfg
.
data_dir
,
sbbs
->
useron
.
number
);
if
(
!
fmutex
(
semfile
,
startup
->
host_name
))
{
if
(
!
fmutex
(
semfile
,
startup
->
host_name
,
24
*
60
*
60
))
{
eprintf
(
LOG_WARNING
,
"%s exists (already being packed?)"
,
semfile
);
continue
;
}
...
...
src/sbbs3/nopen.c
View file @
149e73aa
...
...
@@ -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 200
5
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 200
6
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 *
...
...
@@ -118,15 +118,20 @@ BOOL ftouch(const char* fname)
return
(
TRUE
);
}
BOOL
fmutex
(
const
char
*
fname
,
const
char
*
text
)
BOOL
fmutex
(
const
char
*
fname
,
const
char
*
text
,
long
max_age
)
{
int
file
;
long
t
;
#if !defined(NO_SOCKET_SUPPORT)
char
hostname
[
128
];
if
(
text
==
NULL
&&
gethostname
(
hostname
,
sizeof
(
hostname
))
==
0
)
text
=
hostname
;
#endif
if
(
max_age
&&
(
t
=
fdate
(
fname
))
>=
0
&&
(
time
(
NULL
)
-
t
)
>
max_age
)
{
if
(
remove
(
fname
)
!=
0
)
return
(
FALSE
);
}
if
((
file
=
open
(
fname
,
O_CREAT
|
O_WRONLY
|
O_EXCL
,
S_IREAD
|
S_IWRITE
))
<
0
)
return
(
FALSE
);
if
(
text
!=
NULL
)
...
...
src/sbbs3/nopen.h
View file @
149e73aa
...
...
@@ -4,7 +4,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 200
5
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 200
6
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 *
...
...
@@ -41,7 +41,7 @@ extern "C" {
int
nopen
(
const
char
*
str
,
int
access
);
FILE
*
fnopen
(
int
*
file
,
const
char
*
str
,
int
access
);
BOOL
ftouch
(
const
char
*
fname
);
BOOL
fmutex
(
const
char
*
fname
,
const
char
*
text
);
BOOL
fmutex
(
const
char
*
fname
,
const
char
*
text
,
long
max_age
);
#ifdef __cplusplus
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment