unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [ssoma PATCH] git: simplify sysopen usage
@ 2016-03-06  5:12 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-03-06  5:12 UTC (permalink / raw)
  To: meta; +Cc: Eric Wong

We don't need all these excessive checks for opening/creating the
lock file, merely using O_CREAT guarantees multiple processes will
not walk over the same file during creation (flock is still needed
once opened, of course).
---
 lib/Ssoma/Git.pm | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/Ssoma/Git.pm b/lib/Ssoma/Git.pm
index bc31cdc..8a82c96 100644
--- a/lib/Ssoma/Git.pm
+++ b/lib/Ssoma/Git.pm
@@ -51,9 +51,7 @@ sub sync_do {
 	my $lock;
 
 	# we must not race here because this is concurrent:
-	sysopen($lock, $path, O_WRONLY) or
-		sysopen($lock, $path, O_CREAT|O_EXCL|O_WRONLY) or
-		sysopen($lock, $path, O_WRONLY) or
+	sysopen($lock, $path, O_WRONLY|O_CREAT) or
 		die "failed to open lock $path: $!\n";
 
 	# wait for other processes to be done
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-03-06  5:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-06  5:12 [ssoma PATCH] git: simplify sysopen usage Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).