main 5d6fa26

duplicate_test.go RawHistoryFolder

1package fdwait
2
3import (
4	"golang.org/x/sys/unix"
5	"testing"
6	"time"
7)
8
9// Epoll retains a registration after its fd closes if another descriptor
10// still refers to the same open file description.
11func TestRemovedDuplicatedDescriptorDoesNotKeepPollReadable(t *testing.T) {
12	p, err := New()
13	if err != nil {
14		t.Fatal(err)
15	}
16	defer p.Close()
17	old, err := unix.Eventfd(0, unix.EFD_NONBLOCK|unix.EFD_CLOEXEC)
18	if err != nil {
19		t.Fatal(err)
20	}
21	dup, err := unix.Dup(old)
22	if err != nil {
23		unix.Close(old)
24		t.Fatal(err)
25	}
26	defer unix.Close(dup)
27	if _, err := p.Poll([]unix.PollFd{{Fd: int32(old), Events: unix.POLLIN}}, 1); err != nil {
28		t.Fatal(err)
29	}
30	// Create the next descriptor before closing old so its number is not
31	// reused. This leaves an old epoll registration with no usable fd.
32	fresh, err := unix.Eventfd(0, unix.EFD_NONBLOCK|unix.EFD_CLOEXEC)
33	if err != nil {
34		t.Fatal(err)
35	}
36	defer unix.Close(fresh)
37	unix.Close(old)
38	if _, err := unix.Write(dup, []byte{1, 0, 0, 0, 0, 0, 0, 0}); err != nil {
39		t.Fatal(err)
40	}
41	if err := p.raw.Control(func(ep uintptr) {
42		var events [1]unix.EpollEvent
43		if n, err := unix.EpollWait(int(ep), events[:], 0); n != 0 || err != nil {
44			t.Errorf("closed watched descriptor still makes epoll readable: %d %v", n, err)
45		}
46	}); err != nil {
47		t.Fatal(err)
48	}
49	done := make(chan error, 1)
50	go func() { _, err := p.Poll([]unix.PollFd{{Fd: int32(fresh), Events: unix.POLLIN}}, 20); done <- err }()
51	select {
52	case err := <-done:
53		if err != nil {
54			t.Fatal(err)
55		}
56	case <-time.After(time.Second):
57		p.Close()
58		t.Fatal("stale epoll readiness prevents timeout")
59	}
60}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 23

Tags 10

↑↓ moveenter openesc close