Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b45219f
Implement custom thread local storage for user of library
implausible Mar 29, 2021
7a76a33
checkout: cleanup duplication in checkout_create_the_new
implausible Aug 12, 2020
07493cc
thread checkout: move checkout buffers to tls
implausible Mar 29, 2021
e1a1eaa
thread checkout: add locks around shared state
implausible Aug 12, 2020
dc4e588
thread checkout: add locks around non thread-safe actions
implausible Apr 9, 2021
0739689
thread checkout: stub indirection for threading
implausible Aug 12, 2020
27f3c80
thread checkout: add threading to checkout_create_the_new
implausible Mar 29, 2021
37caa8d
meta: show build status for v1.3 branch
ethomson Feb 26, 2022
6b12762
online: test with https instead of git protocol
ethomson Jan 11, 2022
670415a
clone: update bitbucket tests
ethomson Mar 23, 2022
973d959
path: refactor ownership checks into current user and system
ethomson Apr 10, 2022
62d492d
repo: ensure that repo dir is owned by current user
ethomson Apr 11, 2022
e4eabb0
fs_path: mock ownership checks
ethomson Apr 12, 2022
caee92e
repo: test configuration ownership validation
ethomson Apr 11, 2022
f683806
repo: refactor global config loader function
ethomson Apr 11, 2022
eb8c3e5
repo: honor safe.directory during ownership checks
ethomson Apr 11, 2022
b58e905
repo: make ownership checks optional
ethomson Apr 12, 2022
a9eac6a
Merge pull request #6268 from libgit2/ethomson/ownership_13
ethomson Apr 12, 2022
1f39aac
meta: update version numbers for v1.3.1
ethomson Apr 12, 2022
23c24f8
meta: changelog for v1.3.1
ethomson Apr 12, 2022
1f5e7f9
Merge pull request #6271 from libgit2/ethomson/v1.3.1
ethomson Apr 12, 2022
6da6a10
Merge remote-tracking branch 'zawata/feature/custom-tls-for-external-…
zawata Apr 13, 2022
30d5c08
Merge remote-tracking branch 'zawata/multithread/checkout_create_the_…
zawata Apr 13, 2022
4b193b1
New checkout option: disabled_filters
julianmesa-gitkraken May 6, 2022
fe44f25
Merge branch 'disabled-filters-checkout' into libgit-next
ianhattendorf May 7, 2022
e78ee33
Fix degraded performance using GIT_USE_NSEC on repos cloned with GIT_…
julianmesa-gitkraken May 18, 2022
013d416
Merge pull request #7 from julianmesa-gitkraken/fix-nanoseconds-on-no…
ianhattendorf May 18, 2022
3ad710a
Fix the GIT_USE_NSEC performance fix
julianmesa-gitkraken May 26, 2022
4c98283
Merge pull request #8 from julianmesa-gitkraken/fix-nsecs-fix
ianhattendorf May 26, 2022
d6554d0
stash: introduce `build_stash_commit_from_index`
gitkraken-jacobw Jul 14, 2022
8280bb0
stash: implement partial stashing by path
gitkraken-jacobw Jul 14, 2022
65210e9
stash: implement CI testing
gitkraken-jacobw Jun 17, 2022
ec67f95
stash: better option validation for stash save
gitkraken-jacobw Jul 14, 2022
f2befe8
stash: add `const` to arguments
gitkraken-jacobw Jul 13, 2022
98faa3e
stash: test save options init
gitkraken-jacobw Jul 13, 2022
0ac7af7
Merge pull request #1 from gitkraken-jacobw/partialstashing
zawata Jul 28, 2022
e6b6ed0
Fix leak in git_tag_create_from_buffer
julianmesa-gitkraken Nov 3, 2022
d4b247d
Missing disposes
julianmesa-gitkraken Nov 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
thread checkout: add locks around non thread-safe actions
  • Loading branch information
implausible authored and zawata committed Feb 3, 2022
commit dc4e588be8565592d8f0b7cb3628a38d8b9b752b
61 changes: 49 additions & 12 deletions src/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ typedef struct {

enum {
COMPLETED_STEPS_MUTEX_INITIALIZED = 1,
PERFDATA_MUTEX_INITIALIZED = 2
INDEX_MUTEX_INITIALIZED = 2,
MKPATH_MUTEX_INITIALIZED = 4,
PERFDATA_MUTEX_INITIALIZED = 8
};

typedef struct {
Expand Down Expand Up @@ -83,6 +85,8 @@ typedef struct {
git_strmap *mkdir_map;
git_attr_session attr_session;
git_mutex completed_steps_mutex;
git_mutex index_mutex;
git_mutex mkpath_mutex;
git_mutex perfdata_mutex;
unsigned int mutexes_initialized;
} checkout_data;
Expand Down Expand Up @@ -1451,15 +1455,20 @@ static int mkpath2file(
checkout_data *data, const char *path, unsigned int mode)
{
struct stat st;
bool remove_existing = should_remove_existing(data);
unsigned int flags =
bool remove_existing;
unsigned int flags;
int error;

git_mutex_lock(&data->mkpath_mutex);

remove_existing = should_remove_existing(data);
flags =
(remove_existing ? MKDIR_REMOVE_EXISTING : MKDIR_NORMAL) |
GIT_MKDIR_SKIP_LAST;
int error;

if ((error = checkout_mkdir(
data, path, data->opts.target_directory, mode, flags)) < 0)
return error;
goto cleanup;

if (remove_existing) {
git_mutex_lock(&data->perfdata_mutex);
Expand All @@ -1476,12 +1485,14 @@ static int mkpath2file(
error = git_futils_rmdir_r(path, NULL, GIT_RMDIR_REMOVE_FILES);
} else if (errno != ENOENT) {
git_error_set(GIT_ERROR_OS, "failed to stat '%s'", path);
return GIT_EEXISTS;
error = GIT_EEXISTS;
} else {
git_error_clear();
}
}

cleanup:
git_mutex_unlock(&data->mkpath_mutex);
return error;
}

Expand Down Expand Up @@ -1557,12 +1568,19 @@ static int blob_content_to_file(
filter_session.attr_session = &data->attr_session;
filter_session.temp_buf = &buffers->tmp;

if (!data->opts.disable_filters &&
(error = git_filter_list__load(
if (!data->opts.disable_filters) {
git_mutex_lock(&data->index_mutex);

error = git_filter_list__load(
&fl, data->repo, blob, hint_path,
GIT_FILTER_TO_WORKTREE, &filter_session))) {
p_close(fd);
return error;
GIT_FILTER_TO_WORKTREE, &filter_session);

git_mutex_unlock(&data->index_mutex);

if (error) {
p_close(fd);
return error;
}
}

/* setup the writer */
Expand Down Expand Up @@ -1818,8 +1836,11 @@ static int checkout_blob(
data, &file->id, fullpath->ptr, file->path, file->mode, &st);

/* update the index unless prevented */
if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0) {
git_mutex_lock(&data->index_mutex);
error = checkout_update_index(data, file, &st);
git_mutex_unlock(&data->index_mutex);
}

/* update the submodule data if this was a new .gitmodules file */
if (!error && strcmp(file->path, ".gitmodules") == 0)
Expand Down Expand Up @@ -2412,6 +2433,12 @@ static void checkout_data_clear(checkout_data *data)
if (data->mutexes_initialized & COMPLETED_STEPS_MUTEX_INITIALIZED)
git_mutex_free(&data->completed_steps_mutex);

if (data->mutexes_initialized & INDEX_MUTEX_INITIALIZED)
git_mutex_free(&data->index_mutex);

if (data->mutexes_initialized & MKPATH_MUTEX_INITIALIZED)
git_mutex_free(&data->mkpath_mutex);

if (data->mutexes_initialized & PERFDATA_MUTEX_INITIALIZED)
git_mutex_free(&data->perfdata_mutex);
}
Expand Down Expand Up @@ -2460,6 +2487,16 @@ static int checkout_data_init(

data->mutexes_initialized |= COMPLETED_STEPS_MUTEX_INITIALIZED;

if ((error = git_mutex_init(&data->index_mutex)) < 0)
goto cleanup;

data->mutexes_initialized |= INDEX_MUTEX_INITIALIZED;

if ((error = git_mutex_init(&data->mkpath_mutex)) < 0)
goto cleanup;

data->mutexes_initialized |= MKPATH_MUTEX_INITIALIZED;

if ((error = git_mutex_init(&data->perfdata_mutex)) < 0)
goto cleanup;

Expand Down