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

Delta Between Two Patch Sets: src/pkg/net/fd_poll_runtime.go

Issue 12418043: code review 12418043: net: add special netFD mutex (Closed)
Left Patch Set: diff -r 2585605c42c0 https://dvyukov%40google.com@code.google.com/p/go/ Created 11 years, 7 months ago
Right Patch Set: diff -r 5a51d54e34bb https://dvyukov%40google.com@code.google.com/p/go/ Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/net/fd_mutex_test.go ('k') | src/pkg/net/fd_unix.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin linux windows 5 // +build darwin linux windows
6 6
7 package net 7 package net
8 8
9 import ( 9 import (
10 "sync" 10 "sync"
(...skipping 20 matching lines...) Expand all
31 serverInit.Do(runtime_pollServerInit) 31 serverInit.Do(runtime_pollServerInit)
32 ctx, errno := runtime_pollOpen(uintptr(fd.sysfd)) 32 ctx, errno := runtime_pollOpen(uintptr(fd.sysfd))
33 if errno != 0 { 33 if errno != 0 {
34 return syscall.Errno(errno) 34 return syscall.Errno(errno)
35 } 35 }
36 pd.runtimeCtx = ctx 36 pd.runtimeCtx = ctx
37 return nil 37 return nil
38 } 38 }
39 39
40 func (pd *pollDesc) Close() { 40 func (pd *pollDesc) Close() {
41 if pd.runtimeCtx == 0 {
42 return
43 }
41 runtime_pollClose(pd.runtimeCtx) 44 runtime_pollClose(pd.runtimeCtx)
45 pd.runtimeCtx = 0
42 } 46 }
43 47
44 func (pd *pollDesc) Lock() { 48 func (pd *pollDesc) Lock() {
45 } 49 }
46 50
47 func (pd *pollDesc) Unlock() { 51 func (pd *pollDesc) Unlock() {
48 } 52 }
49 53
50 func (pd *pollDesc) Wakeup() { 54 func (pd *pollDesc) Wakeup() {
51 } 55 }
52 56
53 // Evict evicts fd from the pending list, unblocking any I/O running on fd. 57 // Evict evicts fd from the pending list, unblocking any I/O running on fd.
54 // Return value is whether the pollServer should be woken up. 58 // Return value is whether the pollServer should be woken up.
55 func (pd *pollDesc) Evict() bool { 59 func (pd *pollDesc) Evict() bool {
60 if pd.runtimeCtx == 0 {
61 return false
62 }
56 runtime_pollUnblock(pd.runtimeCtx) 63 runtime_pollUnblock(pd.runtimeCtx)
57 return false 64 return false
58 } 65 }
59 66
60 func (pd *pollDesc) Prepare(mode int) error { 67 func (pd *pollDesc) Prepare(mode int) error {
61 res := runtime_pollReset(pd.runtimeCtx, mode) 68 res := runtime_pollReset(pd.runtimeCtx, mode)
62 return convertErr(res) 69 return convertErr(res)
63 } 70 }
64 71
65 func (pd *pollDesc) PrepareRead() error { 72 func (pd *pollDesc) PrepareRead() error {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 125
119 func setDeadline(fd *netFD, t time.Time) error { 126 func setDeadline(fd *netFD, t time.Time) error {
120 return setDeadlineImpl(fd, t, 'r'+'w') 127 return setDeadlineImpl(fd, t, 'r'+'w')
121 } 128 }
122 129
123 func setDeadlineImpl(fd *netFD, t time.Time, mode int) error { 130 func setDeadlineImpl(fd *netFD, t time.Time, mode int) error {
124 d := t.UnixNano() 131 d := t.UnixNano()
125 if t.IsZero() { 132 if t.IsZero() {
126 d = 0 133 d = 0
127 } 134 }
128 » if err := fd.lock(false); err != nil { 135 » if err := fd.incref(); err != nil {
129 return err 136 return err
130 } 137 }
131 runtime_pollSetDeadline(fd.pd.runtimeCtx, d, mode) 138 runtime_pollSetDeadline(fd.pd.runtimeCtx, d, mode)
132 » fd.unlock() 139 » fd.decref()
133 return nil 140 return nil
134 } 141 }
LEFTRIGHT

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