Skip to content

Conversation

@milo
Copy link
Member

@milo milo commented Feb 21, 2015

Contents of static $locks exists only in one process. The acquiring can be skipped when lock already exists in this process.

Contents of static $locks exists only in one process. The acquiring can be skipped when lock already exists in this process.
@fprochazka
Copy link
Contributor

👍

@mrtnzlml
Copy link

Looks good. Tested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply

flock($locks[$name] = fopen($path . '/lock-' . md5($name), 'w'), LOCK_EX);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It releases previous lock for a few microseconds.

@milo
Copy link
Member Author

milo commented Mar 18, 2015

@dg Some comments on this?

@dg
Copy link
Member

dg commented Mar 18, 2015

It seems ok.

milo added a commit that referenced this pull request Mar 18, 2015
Environment: acquire lock() only if not exist
@milo milo merged commit f999bda into nette:master Mar 18, 2015
@milo milo deleted the pull-pid-locking branch March 18, 2015 10:46
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.

5 participants