• Keith Randall's avatar
    runtime: simplify chan ops, take 2 · e410a527
    Keith Randall authored
    This change is the same as CL #9345 which was reverted,
    except for a small bug fix.
    
    The only change is to the body of sendDirect and its callsite.
    Also added a test.
    
    The problem was during a channel send operation.  The target
    of the send was a sleeping goroutine waiting to receive.  We
    basically do:
    1) Read the destination pointer out of the sudog structure
    2) Copy the value we're sending to that destination pointer
    Unfortunately, the previous change had a goroutine suspend
    point between 1 & 2 (the call to sendDirect).  At that point
    the destination goroutine's stack could be copied (shrunk).
    The pointer we read in step 1 is no longer valid for step 2.
    
    Fixed by not allowing any suspension points between 1 & 2.
    I suspect the old code worked correctly basically by accident.
    
    Fixes #13169
    
    The original 9345:
    
    This change removes the retry mechanism we use for buffered channels.
    Instead, any sender waking up a receiver or vice versa completes the
    full protocol with its counterpart.  This means the counterpart does
    not need to relock the channel when it wakes up.  (Currently
    buffered channels need to relock on wakeup.)
    
    For sends on a channel with waiting receivers, this change replaces
    two copies (sender->queue, queue->receiver) with one (sender->receiver).
    For receives on channels with a waiting sender, two copies are still required.
    
    This change unifies to a large degree the algorithm for buffered
    and unbuffered channels, simplifying the overall implementation.
    
    Fixes #11506
    
    Change-Id: I57dfa3fc219cffa4d48301ee15fe5479299efa09
    Reviewed-on: https://go-review.googlesource.com/16740Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    e410a527
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
cmd Loading commit data...
compress Loading commit data...
container Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
internal Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
vendor/golang.org/x/net/http2/hpack Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
androidtest.bash Loading commit data...
bootstrap.bash Loading commit data...
buildall.bash Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
iostest.bash Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
nacltest.bash Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...