Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
37a5374c
Commit
37a5374c
authored
Apr 16, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
document and partially fix a race
R=r DELTA=24 (21 added, 0 deleted, 3 changed) OCL=27527 CL=27527
parent
1605176e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
fd.go
src/lib/net/fd.go
+24
-3
No files found.
src/lib/net/fd.go
View file @
37a5374c
...
...
@@ -126,13 +126,34 @@ func newPollServer() (s *pollServer, err *os.Error) {
}
func
(
s
*
pollServer
)
AddFD
(
fd
*
netFD
,
mode
int
)
{
if
err
:=
s
.
poll
.
AddFD
(
fd
.
fd
,
mode
,
false
);
err
!=
nil
{
panicln
(
"pollServer AddFD "
,
fd
.
fd
,
": "
,
err
.
String
(),
"
\n
"
);
// TODO(rsc): This check handles a race between
// one goroutine reading and another one closing,
// but it doesn't solve the race completely:
// it still could happen that one goroutine closes
// but we read fd.fd before it does, and then
// another goroutine creates a new open file with
// that fd, which we'd now be referring to.
// The fix is probably to send the Close call
// through the poll server too, except that
// not all Reads and Writes go through the poll
// server even now.
intfd
:=
fd
.
fd
;
if
intfd
<
0
{
// fd closed underfoot
if
mode
==
'r'
{
fd
.
cr
<-
fd
}
else
{
fd
.
cw
<-
fd
}
return
}
if
err
:=
s
.
poll
.
AddFD
(
intfd
,
mode
,
false
);
err
!=
nil
{
panicln
(
"pollServer AddFD "
,
intfd
,
": "
,
err
.
String
(),
"
\n
"
);
return
}
var
t
int64
;
key
:=
fd
.
fd
<<
1
;
key
:=
int
fd
<<
1
;
if
mode
==
'r'
{
fd
.
ncr
++
;
t
=
fd
.
rdeadline
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment