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
f40329f7
Commit
f40329f7
authored
3 months ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Add fmutex_open() for cases where you want to keep the mutex file open
parent
6135284f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sbbs3/nopen.c
+19
-6
19 additions, 6 deletions
src/sbbs3/nopen.c
src/sbbs3/nopen.h
+1
-0
1 addition, 0 deletions
src/sbbs3/nopen.h
with
20 additions
and
6 deletions
src/sbbs3/nopen.c
+
19
−
6
View file @
f40329f7
...
...
@@ -109,11 +109,11 @@ bool ftouch(const char* fname)
return
true
;
}
bool
fmutex
(
const
char
*
fname
,
const
char
*
text
,
long
max_age
,
time_t
*
tp
)
int
fmutex
_open
(
const
char
*
fname
,
const
char
*
text
,
long
max_age
,
time_t
*
tp
)
{
int
file
;
time_t
t
;
bool
result
=
true
;
size_t
len
;
#if !defined(NO_SOCKET_SUPPORT)
char
hostname
[
128
];
if
(
text
==
NULL
&&
gethostname
(
hostname
,
sizeof
(
hostname
))
==
0
)
...
...
@@ -126,15 +126,28 @@ bool fmutex(const char* fname, const char* text, long max_age, time_t* tp)
*
tp
=
fdate
(
fname
);
if
(
max_age
>
0
&&
*
tp
!=
-
1
&&
(
time
(
NULL
)
-
*
tp
)
>
max_age
)
{
if
(
remove
(
fname
)
!=
0
)
return
false
;
return
-
1
;
}
}
if
((
file
=
sopen
(
fname
,
O_CREAT
|
O_WRONLY
|
O_EXCL
,
SH_DENYRW
,
DEFFILEMODE
))
<
0
)
return
file
;
if
(
text
!=
NULL
)
{
len
=
strlen
(
text
);
if
(
write
(
file
,
text
,
len
)
!=
len
)
{
close
(
file
);
return
-
1
;
}
}
return
file
;
}
bool
fmutex
(
const
char
*
fname
,
const
char
*
text
,
long
max_age
,
time_t
*
tp
)
{
int
file
=
fmutex_open
(
fname
,
text
,
max_age
,
tp
);
if
(
file
<
0
)
return
false
;
if
(
text
!=
NULL
)
result
=
write
(
file
,
text
,
strlen
(
text
))
>=
0
;
close
(
file
);
return
result
;
return
true
;
}
bool
fcompare
(
const
char
*
fn1
,
const
char
*
fn2
)
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/nopen.h
+
1
−
0
View file @
f40329f7
...
...
@@ -37,6 +37,7 @@ int nopen(const char* str, uint access);
FILE
*
fnopen
(
int
*
file
,
const
char
*
str
,
uint
access
);
bool
ftouch
(
const
char
*
fname
);
bool
fmutex
(
const
char
*
fname
,
const
char
*
text
,
long
max_age
,
time_t
*
);
int
fmutex_open
(
const
char
*
fname
,
const
char
*
text
,
long
max_age
,
time_t
*
);
bool
fcompare
(
const
char
*
fn1
,
const
char
*
fn2
);
bool
backup
(
const
char
*
org
,
int
backup_level
,
bool
ren
);
...
...
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