Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
ac07a40a
Commit
ac07a40a
authored
3 years ago
by
Colin Stolley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check packed-refs filestamp before reusing mmap.
Avoid using a stale mmap() by tracking the filestamp.
parent
cdf05a1d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletions
+8
-1
src/refdb_fs.c
+8
-1
No files found.
src/refdb_fs.c
View file @
ac07a40a
...
...
@@ -67,6 +67,7 @@ typedef struct refdb_fs_backend {
int
fsync
;
git_map
packed_refs_map
;
git_mutex
prlock
;
/* protect packed_refs_map */
git_futils_filestamp
packed_refs_stamp
;
bool
sorted
;
}
refdb_fs_backend
;
...
...
@@ -495,6 +496,7 @@ static void packed_map_free(refdb_fs_backend *backend)
#endif
backend
->
packed_refs_map
.
data
=
NULL
;
backend
->
packed_refs_map
.
len
=
0
;
git_futils_filestamp_set
(
&
backend
->
packed_refs_stamp
,
NULL
);
}
}
...
...
@@ -507,10 +509,13 @@ static int packed_map_check(refdb_fs_backend *backend)
if
((
error
=
git_mutex_lock
(
&
backend
->
prlock
))
<
0
)
return
error
;
if
(
backend
->
packed_refs_map
.
data
)
{
if
(
backend
->
packed_refs_map
.
data
&&
!
git_futils_filestamp_check
(
&
backend
->
packed_refs_stamp
,
backend
->
refcache
->
path
))
{
git_mutex_unlock
(
&
backend
->
prlock
);
return
error
;
}
packed_map_free
(
backend
);
fd
=
git_futils_open_ro
(
backend
->
refcache
->
path
);
if
(
fd
<
0
)
{
...
...
@@ -535,6 +540,8 @@ static int packed_map_check(refdb_fs_backend *backend)
return
0
;
}
git_futils_filestamp_set_from_stat
(
&
backend
->
packed_refs_stamp
,
&
st
);
#ifdef GIT_WIN32
/* on windows, we copy the entire file into memory rather than using
* mmap() because using mmap() on windows also locks the file and this
...
...
This diff is collapsed.
Click to expand it.
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