Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11355)

Issue 59220048: code review 59220048: leveldb-go: implement file lock on FreeBSD.

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by wathiede
Modified:
10 years, 2 months ago
Reviewers:
nigeltao
CC:
golang-codereviews, nigeltao, bradfitz
Visibility:
Public.

Description

leveldb-go: implement file lock on FreeBSD. I do not believe FreeBSD requires a 32-bit and 64-bit version like Linux for the following reasons (although I don't have a 32-bit FreeBSD box to test on). According to this, off_t is the same size on 32 and 64-bit, and not like linux's two APIs for everything to support LARGEFILE: http://freecode.com/articles/largefile-support-problems pid_t is an __int32_t, independent of arch AFAICT https://github.com/freebsd/freebsd/blob/master/sys/sys/_types.h Type and Whence being shorts made me a bit nervous. This test on my 64-bit machines: $ cat short.c #include int main() { printf("sizeof short %lu\n", sizeof(short)); } $ rm short; make CC=gcc short; ./short; rm short; make CC=clang short; ./short gcc -O2 -pipe -fno-omit-frame-pointer short.c -o short sizeof short 2 clang -O2 -pipe -fno-omit-frame-pointer short.c -o short sizeof short 2 Makes me think we're safe, as I believe short would be 16-bit on 32-bit, and was unsure about its size on 64-bit. $ cat int.c #include <stdio.h> int main() { printf("sizeof int %lu\n", sizeof(int)); } $ rm int; make CC=gcc int; ./int; rm int; make CC=clang int; ./int gcc -O2 -pipe -fno-omit-frame-pointer int.c -o int sizeof int 4 clang -O2 -pipe -fno-omit-frame-pointer int.c -o int sizeof int 4 So int is 32-bit on FreeBSD even on 64-bit machines. Running go test code.google.com/p/leveldb-go/... passes, as does filelock, i.e.: $ go run main.go /tmp/lock Locking /tmp/lock Unlocking /tmp/lock OK

Patch Set 1 #

Patch Set 2 : diff -r a2c0ed4d6198 https://code.google.com/p/leveldb-go #

Patch Set 3 : diff -r 0b4dffc91e3b https://code.google.com/p/leveldb-go #

Patch Set 4 : diff -r 0b4dffc91e3b https://code.google.com/p/leveldb-go #

Unified diffs Side-by-side diffs Delta from patch set Stats (+54 lines, -0 lines) Patch
A leveldb/db/file_lock_freebsd.go View 1 1 chunk +53 lines, -0 lines 0 comments Download
M leveldb/db/file_lock_generic.go View 1 2 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 5
wathiede
Hello golang-codereviews@googlegroups.com, I'd like you to review this change to https://code.google.com/p/leveldb-go
10 years, 2 months ago (2014-02-08 22:02:22 UTC) #1
nigeltao
LGTM. I presume that when you say that running filelock works, you run multiple concurrent ...
10 years, 2 months ago (2014-02-18 05:49:20 UTC) #2
bradfitz
Ideally the filelock test should invoke multiple child processes of itself. On Mon, Feb 17, ...
10 years, 2 months ago (2014-02-18 05:52:29 UTC) #3
nigeltao
*** Submitted as https://code.google.com/p/leveldb-go/source/detail?r=b6ab03c49ef6 *** leveldb-go: implement file lock on FreeBSD. I do not believe ...
10 years, 2 months ago (2014-02-19 02:02:39 UTC) #4
wathiede
10 years, 2 months ago (2014-02-19 04:09:18 UTC) #5
On 2014/02/18 05:49:20, nigeltao wrote:
> LGTM.
> 
> I presume that when you say that running filelock works, you run multiple
> concurrent instances of filelock, not just one "go run main.go /tmp/lock".

Apologies, I failed to read the docstring of filelock/main.go, so I only ran one
copy.  As a consolation prize I've sent a CL implementing Brad's suggestion:

https://codereview.appspot.com/65870043

Which does pass with this CL when run on FreeBSD.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b