Skip to content

Fix race condition in ts_utils:make_dir/1 - #109

Merged
nniclausse merged 2 commits into
processone:masterfrom
tisba:fix-race-condition-ts_utils-make_dir
Mar 5, 2015
Merged

nniclausse merged 2 commits into
processone:masterfrom
tisba:fix-race-condition-ts_utils-make_dir

Conversation

@tisba

@tisba tisba commented Mar 5, 2015

Copy link
Copy Markdown
Collaborator

There is a race condition, when multiple Erlang VMs are started almost simultaneously which is a typical case if you are not using tsung's SMP option.

I observed it a couple of times now, that ts_local_mon failed to write the protocol_local dumpfile. The reason is that the check and set is not one atomic operation in ts_utils:make_dir_rec/3. There is a window after the check, when another process could have created the directory already, resulting in a {error, eexist}.

In #88 the check for ok in ts_local_mon:init/1 was wrongfully removed (I'm sorry for that). Back then I noticed the {error, eexist} and assumed that this is a result from the fact that the entire log directory already existed, which is not the case. ts_utils:make_dir/1 and ts_utils:make_dir_raw/1 should now be better protected against the mentioned race condition.

@tisba tisba changed the title Fix race condition ts_utils:make_dir Fix race condition in ts_utils:make_dir/1 Mar 5, 2015
nniclausse added a commit that referenced this pull request Mar 5, 2015
@nniclausse
nniclausse merged commit 6e75081 into processone:master Mar 5, 2015
@tisba
tisba deleted the fix-race-condition-ts_utils-make_dir branch November 1, 2017 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants