gofrs / flock

Thread-safe file locking library in Go
https://pkg.go.dev/github.com/gofrs/flock
BSD 3-Clause "New" or "Revised" License
578 stars 66 forks source link

Add AIX support with fcntl #40

Closed Helflym closed 4 years ago

Helflym commented 5 years ago

AIX doesn't provide a true flock() syscall. It does exist but it's just a wrapper around fcntl. It doesn't provide safe locks under file descriptors of a same process.

The current implementation is based on the file cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go.

Using fcntl implementation doesn't allow to have several RLocks at the same time as closing a file descriptor might release the lock if even others RLocks remain attached.

theckman commented 5 years ago

I plan to do a review of this with the intent to merge it. One concern I have is that without an AIX test environment, we can't be confident in our implementation when making future changes. I'm doing some research on that, but not looking promising. 😄

Helflym commented 5 years ago

I'm not sure there is any "free" AIX which can be used for testing. My aim is just to provide a "first port" hoping AIX users will get use to it and will fix it if anything ever go wrong.
Note that Solaris, according to cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go should also use this fcntl version instead of flock version.

Helflym commented 5 years ago

Hi Theckman,

Any news about this PR ? Have you find any way to make tests on an AIX machine ?

Helflym commented 4 years ago

Hi Theckman,

Any news about this PR ? gofrs/flock is used in many others projects like Beats software and at the moment, we have to manually update "vendor" folder if we want to build them. I know that you can't test any future modifications on an AIX environment by yourself but I suppose letting the AIX community fixing it if it ever goes wrong is a viable solution

fearful-symmetry commented 4 years ago

@bcmills / @theckman Any update on this? We'd like this get this merged if possible. @Helflym should still be available but I can take over development if needed.

bcmills commented 4 years ago

@fearful-symmetry, I'm not in the gofrs organization. My involvement in this PR is purely as the maintainer of a Go package with similar functionality (namely, cmd/go/internal/lockedfile; see also golang/go#33974).

fearful-symmetry commented 4 years ago

@bcmills anyone I should ping about getting this updated/approved?

Helflym commented 4 years ago

@Helflym @fearful-symmetry @bcmills apologies, my hesitation has been that there are zero AIX build resources available for the community and it looked prohibitively expensive to try and learn AIX / gain access to one.

Yeah, it's not really possible. IBM doesn't provide free AIX VM for OpenSource developers... As I said for other Go packages, the AIX community should report if anything go wrong and should be able to fix it. Anyway, you can tag me if you want some tests on AIX.

At this point I'm okay ignoring that discomfort and merging this in for the benefit of the community, but there is a blocker in getting this merged. There were some changes released in v0.7.2 (#43) that need to be included here and tested on an AIX system.

Is there someone with access to AIX hardware that can develop / test that change?

I've made the change it and the tests are all OK.

theckman commented 4 years ago

@Helflym thank you! I'll work to get v0.8.0 out within the next 10-15 minutes.

AlejandrosTesla8 commented 1 year ago

AIX doesn't provide a true flock() syscall. It does exist but it's just

a wrapper around fcntl. It doesn't provide safe locks under file

descriptors of a same process.

The current implementation is based on the file

cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go.

Using fcntl implementation doesn't allow to have several RLocks at the

same time as closing a file descriptor might release the lock if even

others RLocks remain attached.