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
6000b760
Commit
6000b760
authored
5 months ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Clean up the OFD check/decision, make use of fcntl() locks easier to opt-in
parent
b5ae6469
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xpdev/filewrap.c
+19
-15
19 additions, 15 deletions
src/xpdev/filewrap.c
with
19 additions
and
15 deletions
src/xpdev/filewrap.c
+
19
−
15
View file @
6000b760
...
...
@@ -70,24 +70,28 @@ off_t filelength(int fd)
return
(
st
.
st_size
);
}
// See https://patchwork.kernel.org/patch/9289177/
#if defined(F_OFD_SETLK) && _FILE_OFFSET_BITS != 64
#undef F_OFD_SETLK
#endif
#if defined(__linux__) && !defined(F_OFD_SETLK)
#warning Linux OFD locks not enabled!
#endif
#if defined(F_OFD_SETLK)
#undef F_SETLK
#define F_SETLK F_OFD_SETLK
/*************************************/
/* Use OFD fcntl() locks when we can */
/*************************************/
#if defined __linux__
#define USE_FCNTL_LOCKS
// See https://patchwork.kernel.org/patch/9289177/
#if defined F_OFD_SETLK && _FILE_OFFSET_BITS != 64
#undef F_OFD_SETLK
#endif
#if defined F_OFD_SETLK
#undef F_SETLK
#define F_SETLK F_OFD_SETLK
#else
#warning Linux OFD locks not enabled!
#endif
#endif
/* Sets a lock on a portion of a file */
int
lock
(
int
fd
,
off_t
pos
,
off_t
len
)
{
#if
!
defined
(BSD)
#if defined
USE_FCNTL_LOCKS
struct
flock
alock
=
{
0
};
// fcntl() will return EBADF if we try to set a write lock a file opened O_RDONLY
...
...
@@ -117,7 +121,7 @@ int lock(int fd, off_t pos, off_t len)
int
unlock
(
int
fd
,
off_t
pos
,
off_t
len
)
{
#if
!
defined
(BSD)
#if defined
USE_FCNTL_LOCKS
struct
flock
alock
=
{
0
};
alock
.
l_type
=
F_UNLCK
;
/* remove the lock */
...
...
@@ -195,7 +199,7 @@ int sopen(const char *fn, int sh_access, int share, ...)
if
(
share
==
SH_DENYNO
||
share
==
SH_COMPAT
)
/* no lock needed */
return
fd
;
#if
!
defined
(BSD)
#if defined
USE_FCNTL_LOCKS
struct
flock
alock
=
{
0
};
// lock entire file from offset 0
...
...
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