Reformat codebase.

PiperOrigin-RevId: 449358041
This commit is contained in:
Ayush Ranjan
2022-05-17 17:48:35 -07:00
committed by gVisor bot
parent 251f2c0561
commit f6ed4523dc
265 changed files with 2566 additions and 2382 deletions
+2 -2
View File
@@ -411,8 +411,8 @@ type SignalInfo struct {
//
// The si_code we get from Linux may contain the kernel-specific code in the
// top 16 bits if it's positive (e.g., from ptrace). Linux's
// copy_siginfo_to_user does
// err |= __put_user((short)from->si_code, &to->si_code);
// copy_siginfo_to_user does:
// err |= __put_user((short)from->si_code, &to->si_code);
// to mask out those bits and we need to do the same.
func (s *SignalInfo) FixSignalCodeForUser() {
if s.Code > 0 {
+5 -4
View File
@@ -206,10 +206,11 @@ type Itimerspec struct {
}
// ItimerVal mimics the following struct in <sys/time.h>
// struct itimerval {
// struct timeval it_interval; /* next value */
// struct timeval it_value; /* current value */
// };
//
// struct itimerval {
// struct timeval it_interval; /* next value */
// struct timeval it_value; /* current value */
// };
//
// +marshal
type ItimerVal struct {
+12
View File
@@ -42,12 +42,14 @@ type Int32 struct {
}
// FromInt32 returns an Int32 initialized to value v.
//
//go:nosplit
func FromInt32(v int32) Int32 {
return Int32{value: v}
}
// Load is analogous to atomic.LoadInt32.
//
//go:nosplit
func (i *Int32) Load() int32 {
return atomic.LoadInt32(&i.value)
@@ -64,6 +66,7 @@ func (i *Int32) RacyLoad() int32 {
}
// Store is analogous to atomic.StoreInt32.
//
//go:nosplit
func (i *Int32) Store(v int32) {
atomic.StoreInt32(&i.value, v)
@@ -83,6 +86,7 @@ func (i *Int32) RacyStore(v int32) {
}
// Add is analogous to atomic.AddInt32.
//
//go:nosplit
func (i *Int32) Add(v int32) int32 {
return atomic.AddInt32(&i.value, v)
@@ -100,12 +104,14 @@ func (i *Int32) RacyAdd(v int32) int32 {
}
// Swap is analogous to atomic.SwapInt32.
//
//go:nosplit
func (i *Int32) Swap(v int32) int32 {
return atomic.SwapInt32(&i.value, v)
}
// CompareAndSwap is analogous to atomic.CompareAndSwapInt32.
//
//go:nosplit
func (i *Int32) CompareAndSwap(oldVal, newVal int32) bool {
return atomic.CompareAndSwapInt32(&i.value, oldVal, newVal)
@@ -127,12 +133,14 @@ type Uint32 struct {
}
// FromUint32 returns an Uint32 initialized to value v.
//
//go:nosplit
func FromUint32(v uint32) Uint32 {
return Uint32{value: v}
}
// Load is analogous to atomic.LoadUint32.
//
//go:nosplit
func (u *Uint32) Load() uint32 {
return atomic.LoadUint32(&u.value)
@@ -149,6 +157,7 @@ func (u *Uint32) RacyLoad() uint32 {
}
// Store is analogous to atomic.StoreUint32.
//
//go:nosplit
func (u *Uint32) Store(v uint32) {
atomic.StoreUint32(&u.value, v)
@@ -165,6 +174,7 @@ func (u *Uint32) RacyStore(v uint32) {
}
// Add is analogous to atomic.AddUint32.
//
//go:nosplit
func (u *Uint32) Add(v uint32) uint32 {
return atomic.AddUint32(&u.value, v)
@@ -182,12 +192,14 @@ func (u *Uint32) RacyAdd(v uint32) uint32 {
}
// Swap is analogous to atomic.SwapUint32.
//
//go:nosplit
func (u *Uint32) Swap(v uint32) uint32 {
return atomic.SwapUint32(&u.value, v)
}
// CompareAndSwap is analogous to atomic.CompareAndSwapUint32.
//
//go:nosplit
func (u *Uint32) CompareAndSwap(oldVal, newVal uint32) bool {
return atomic.CompareAndSwapUint32(&u.value, oldVal, newVal)
+12
View File
@@ -42,12 +42,14 @@ type Int32 struct {
}
// FromInt32 returns an Int32 initialized to value v.
//
//go:nosplit
func FromInt32(v int32) Int32 {
return Int32{value: v}
}
// Load is analogous to atomic.LoadInt32.
//
//go:nosplit
func (i *Int32) Load() int32 {
return atomic.LoadInt32(&i.value)
@@ -64,6 +66,7 @@ func (i *Int32) RacyLoad() int32 {
}
// Store is analogous to atomic.StoreInt32.
//
//go:nosplit
func (i *Int32) Store(v int32) {
atomic.StoreInt32(&i.value, v)
@@ -83,6 +86,7 @@ func (i *Int32) RacyStore(v int32) {
}
// Add is analogous to atomic.AddInt32.
//
//go:nosplit
func (i *Int32) Add(v int32) int32 {
return atomic.AddInt32(&i.value, v)
@@ -100,12 +104,14 @@ func (i *Int32) RacyAdd(v int32) int32 {
}
// Swap is analogous to atomic.SwapInt32.
//
//go:nosplit
func (i *Int32) Swap(v int32) int32 {
return atomic.SwapInt32(&i.value, v)
}
// CompareAndSwap is analogous to atomic.CompareAndSwapInt32.
//
//go:nosplit
func (i *Int32) CompareAndSwap(oldVal, newVal int32) bool {
return atomic.CompareAndSwapInt32(&i.value, oldVal, newVal)
@@ -127,12 +133,14 @@ type Uint32 struct {
}
// FromUint32 returns an Uint32 initialized to value v.
//
//go:nosplit
func FromUint32(v uint32) Uint32 {
return Uint32{value: v}
}
// Load is analogous to atomic.LoadUint32.
//
//go:nosplit
func (u *Uint32) Load() uint32 {
return atomic.LoadUint32(&u.value)
@@ -149,6 +157,7 @@ func (u *Uint32) RacyLoad() uint32 {
}
// Store is analogous to atomic.StoreUint32.
//
//go:nosplit
func (u *Uint32) Store(v uint32) {
atomic.StoreUint32(&u.value, v)
@@ -165,6 +174,7 @@ func (u *Uint32) RacyStore(v uint32) {
}
// Add is analogous to atomic.AddUint32.
//
//go:nosplit
func (u *Uint32) Add(v uint32) uint32 {
return atomic.AddUint32(&u.value, v)
@@ -182,12 +192,14 @@ func (u *Uint32) RacyAdd(v uint32) uint32 {
}
// Swap is analogous to atomic.SwapUint32.
//
//go:nosplit
func (u *Uint32) Swap(v uint32) uint32 {
return atomic.SwapUint32(&u.value, v)
}
// CompareAndSwap is analogous to atomic.CompareAndSwapUint32.
//
//go:nosplit
func (u *Uint32) CompareAndSwap(oldVal, newVal uint32) bool {
return atomic.CompareAndSwapUint32(&u.value, oldVal, newVal)
+12
View File
@@ -53,6 +53,7 @@ func (i *Int64) ptr() *int64 {
}
// FromInt64 returns an Int64 initialized to value v.
//
//go:nosplit
func FromInt64(v int64) Int64 {
var i Int64
@@ -61,6 +62,7 @@ func FromInt64(v int64) Int64 {
}
// Load is analogous to atomic.LoadInt64.
//
//go:nosplit
func (i *Int64) Load() int64 {
return atomic.LoadInt64(i.ptr())
@@ -77,6 +79,7 @@ func (i *Int64) RacyLoad() int64 {
}
// Store is analogous to atomic.StoreInt64.
//
//go:nosplit
func (i *Int64) Store(v int64) {
atomic.StoreInt64(i.ptr(), v)
@@ -93,6 +96,7 @@ func (i *Int64) RacyStore(v int64) {
}
// Add is analogous to atomic.AddInt64.
//
//go:nosplit
func (i *Int64) Add(v int64) int64 {
return atomic.AddInt64(i.ptr(), v)
@@ -110,12 +114,14 @@ func (i *Int64) RacyAdd(v int64) int64 {
}
// Swap is analogous to atomic.SwapInt64.
//
//go:nosplit
func (i *Int64) Swap(v int64) int64 {
return atomic.SwapInt64(i.ptr(), v)
}
// CompareAndSwap is analogous to atomic.CompareAndSwapInt64.
//
//go:nosplit
func (i *Int64) CompareAndSwap(oldVal, newVal int64) bool {
return atomic.CompareAndSwapInt64(&i.value, oldVal, newVal)
@@ -150,6 +156,7 @@ func (u *Uint64) ptr() *uint64 {
}
// FromUint64 returns an Uint64 initialized to value v.
//
//go:nosplit
func FromUint64(v uint64) Uint64 {
var u Uint64
@@ -158,6 +165,7 @@ func FromUint64(v uint64) Uint64 {
}
// Load is analogous to atomic.LoadUint64.
//
//go:nosplit
func (u *Uint64) Load() uint64 {
return atomic.LoadUint64(u.ptr())
@@ -174,6 +182,7 @@ func (u *Uint64) RacyLoad() uint64 {
}
// Store is analogous to atomic.StoreUint64.
//
//go:nosplit
func (u *Uint64) Store(v uint64) {
atomic.StoreUint64(u.ptr(), v)
@@ -190,6 +199,7 @@ func (u *Uint64) RacyStore(v uint64) {
}
// Add is analogous to atomic.AddUint64.
//
//go:nosplit
func (u *Uint64) Add(v uint64) uint64 {
return atomic.AddUint64(u.ptr(), v)
@@ -207,12 +217,14 @@ func (u *Uint64) RacyAdd(v uint64) uint64 {
}
// Swap is analogous to atomic.SwapUint64.
//
//go:nosplit
func (u *Uint64) Swap(v uint64) uint64 {
return atomic.SwapUint64(u.ptr(), v)
}
// CompareAndSwap is analogous to atomic.CompareAndSwapUint64.
//
//go:nosplit
func (u *Uint64) CompareAndSwap(oldVal, newVal uint64) bool {
return atomic.CompareAndSwapUint64(u.ptr(), oldVal, newVal)
+12
View File
@@ -41,12 +41,14 @@ type Int64 struct {
}
// FromInt64 returns an Int64 initialized to value v.
//
//go:nosplit
func FromInt64(v int64) Int64 {
return Int64{value: v}
}
// Load is analogous to atomic.LoadInt64.
//
//go:nosplit
func (i *Int64) Load() int64 {
return atomic.LoadInt64(&i.value)
@@ -63,6 +65,7 @@ func (i *Int64) RacyLoad() int64 {
}
// Store is analogous to atomic.StoreInt64.
//
//go:nosplit
func (i *Int64) Store(v int64) {
atomic.StoreInt64(&i.value, v)
@@ -79,6 +82,7 @@ func (i *Int64) RacyStore(v int64) {
}
// Add is analogous to atomic.AddInt64.
//
//go:nosplit
func (i *Int64) Add(v int64) int64 {
return atomic.AddInt64(&i.value, v)
@@ -96,12 +100,14 @@ func (i *Int64) RacyAdd(v int64) int64 {
}
// Swap is analogous to atomic.SwapInt64.
//
//go:nosplit
func (i *Int64) Swap(v int64) int64 {
return atomic.SwapInt64(&i.value, v)
}
// CompareAndSwap is analogous to atomic.CompareAndSwapInt64.
//
//go:nosplit
func (i *Int64) CompareAndSwap(oldVal, newVal int64) bool {
return atomic.CompareAndSwapInt64(&i.value, oldVal, newVal)
@@ -128,12 +134,14 @@ type Uint64 struct {
}
// FromUint64 returns an Uint64 initialized to value v.
//
//go:nosplit
func FromUint64(v uint64) Uint64 {
return Uint64{value: v}
}
// Load is analogous to atomic.LoadUint64.
//
//go:nosplit
func (u *Uint64) Load() uint64 {
return atomic.LoadUint64(&u.value)
@@ -150,6 +158,7 @@ func (u *Uint64) RacyLoad() uint64 {
}
// Store is analogous to atomic.StoreUint64.
//
//go:nosplit
func (u *Uint64) Store(v uint64) {
atomic.StoreUint64(&u.value, v)
@@ -166,6 +175,7 @@ func (u *Uint64) RacyStore(v uint64) {
}
// Add is analogous to atomic.AddUint64.
//
//go:nosplit
func (u *Uint64) Add(v uint64) uint64 {
return atomic.AddUint64(&u.value, v)
@@ -183,12 +193,14 @@ func (u *Uint64) RacyAdd(v uint64) uint64 {
}
// Swap is analogous to atomic.SwapUint64.
//
//go:nosplit
func (u *Uint64) Swap(v uint64) uint64 {
return atomic.SwapUint64(&u.value, v)
}
// CompareAndSwap is analogous to atomic.CompareAndSwapUint64.
//
//go:nosplit
func (u *Uint64) CompareAndSwap(oldVal, newVal uint64) bool {
return atomic.CompareAndSwapUint64(&u.value, oldVal, newVal)
+3 -3
View File
@@ -34,11 +34,11 @@ const (
//
// In the comments below:
//
// - A, X, and M[] are BPF virtual machine registers.
// - A, X, and M[] are BPF virtual machine registers.
//
// - K refers to the instruction field linux.BPFInstruction.K.
// - K refers to the instruction field linux.BPFInstruction.K.
//
// - Bits are counted from the LSB position.
// - Bits are counted from the LSB position.
const (
// Instruction class, stored in bits 0-2.
Ld = 0x00 // load into A
+7 -7
View File
@@ -225,15 +225,15 @@ func Compile(insns []linux.BPFInstruction) (Program, error) {
//
// For all of Input's Load methods:
//
// - The second (bool) return value is true if the load succeeded and false
// otherwise.
// - The second (bool) return value is true if the load succeeded and false
// otherwise.
//
// - Inputs should not assume that the loaded range falls within the input
// data's length. Inputs should return false if the load falls outside of the
// input data.
// - Inputs should not assume that the loaded range falls within the input
// data's length. Inputs should return false if the load falls outside of the
// input data.
//
// - Inputs should not assume that the offset is correctly aligned. Inputs may
// choose to service or reject loads to unaligned addresses.
// - Inputs should not assume that the offset is correctly aligned. Inputs may
// choose to service or reject loads to unaligned addresses.
type Input interface {
// Load32 reads 32 bits from the input starting at the given byte offset.
Load32(off uint32) (uint32, bool)
+8 -7
View File
@@ -17,13 +17,14 @@ package cleanup
// Cleanup allows defers to be aborted when cleanup needs to happen
// conditionally. Usage:
// cu := cleanup.Make(func() { f.Close() })
// defer cu.Clean() // failure before release is called will close the file.
// ...
// cu.Add(func() { f2.Close() }) // Adds another cleanup function
// ...
// cu.Release() // on success, aborts closing the file.
// return f
//
// cu := cleanup.Make(func() { f.Close() })
// defer cu.Clean() // failure before release is called will close the file.
// ...
// cu.Add(func() { f2.Close() }) // Adds another cleanup function
// ...
// cu.Release() // on success, aborts closing the file.
// return f
type Cleanup struct {
cleaners []func()
}
+3 -3
View File
@@ -35,9 +35,9 @@
//
// where each subsequent hash is calculated from the following items in order
//
// compressed data
// compressed data size
// previous hash
// compressed data
// compressed data size
// previous hash
//
// so the stream integrity cannot be compromised by switching and mixing
// compressed chunks.
+5 -5
View File
@@ -140,12 +140,12 @@ func (*NoTask) UninterruptibleSleepFinish(bool) {}
// context.Context, the standard type represents the state of an operation
// rather than that of a goroutine. This is a critical distinction:
//
// - Unlike context.Context, which "may be passed to functions running in
// different goroutines", it is *not safe* to use the same Context in multiple
// concurrent goroutines.
// - Unlike context.Context, which "may be passed to functions running in
// different goroutines", it is *not safe* to use the same Context in multiple
// concurrent goroutines.
//
// - It is *not safe* to retain a Context passed to a function beyond the scope
// of that function call.
// - It is *not safe* to retain a Context passed to a function beyond the scope
// of that function call.
//
// In both cases, values extracted from the Context should be used instead.
type Context interface {
+2 -2
View File
@@ -60,8 +60,8 @@ func FromContext(ctx context) FeatureSet {
// On x86, features are numbered according to "blocks". Each block is 32 bits, and
// feature bits from the same source (cpuid leaf/level) are in the same block.
//
// On arm64, features are numbered according to the ELF HWCAP definition, from:
// arch/arm64/include/uapi/asm/hwcap.h
// On arm64, features are numbered according to the ELF HWCAP definition, from
// arch/arm64/include/uapi/asm/hwcap.h.
type Feature int
// allFeatureInfo is the value for allFeatures.
+3 -3
View File
@@ -27,11 +27,11 @@ import (
// Common references:
//
// Intel:
// * Intel SDM Volume 2, Chapter 3.2 "CPUID" (more up-to-date)
// * Intel Application Note 485 (more detailed)
// - Intel SDM Volume 2, Chapter 3.2 "CPUID" (more up-to-date)
// - Intel Application Note 485 (more detailed)
//
// AMD:
// * AMD64 APM Volume 3, Appendix 3 "Obtaining Processor Information ..."
// - AMD64 APM Volume 3, Appendix 3 "Obtaining Processor Information ..."
//
// +stateify savable
type FeatureSet struct {
+21 -20
View File
@@ -150,26 +150,27 @@ func initCPUInfo() {
// decimal key-value pairs on the 64-bit system.
//
// $ od -t d8 /proc/self/auxv
// 0000000 33 140734615224320
// 0000020 16 3219913727
// 0000040 6 4096
// 0000060 17 100
// 0000100 3 94665627353152
// 0000120 4 56
// 0000140 5 9
// 0000160 7 140425502162944
// 0000200 8 0
// 0000220 9 94665627365760
// 0000240 11 1000
// 0000260 12 1000
// 0000300 13 1000
// 0000320 14 1000
// 0000340 23 0
// 0000360 25 140734614619513
// 0000400 26 0
// 0000420 31 140734614626284
// 0000440 15 140734614619529
// 0000460 0 0
//
// 0000000 33 140734615224320
// 0000020 16 3219913727
// 0000040 6 4096
// 0000060 17 100
// 0000100 3 94665627353152
// 0000120 4 56
// 0000140 5 9
// 0000160 7 140425502162944
// 0000200 8 0
// 0000220 9 94665627365760
// 0000240 11 1000
// 0000260 12 1000
// 0000300 13 1000
// 0000320 14 1000
// 0000340 23 0
// 0000360 25 140734614619513
// 0000400 26 0
// 0000420 31 140734614626284
// 0000440 15 140734614619529
// 0000460 0 0
func initHwCap() {
auxv, err := ioutil.ReadFile("/proc/self/auxv")
if err != nil {
+15 -15
View File
@@ -181,9 +181,9 @@ const (
// Connect blocks until the peer Endpoint has called Endpoint.RecvFirst().
//
// Preconditions:
// * ep is a client Endpoint.
// * ep.Connect(), ep.RecvFirst(), ep.SendRecv(), and ep.SendLast() have never
// been called.
// - ep is a client Endpoint.
// - ep.Connect(), ep.RecvFirst(), ep.SendRecv(), and ep.SendLast() have never
// been called.
func (ep *Endpoint) Connect() error {
err := ep.ctrlConnect()
if err == nil {
@@ -196,8 +196,8 @@ func (ep *Endpoint) Connect() error {
// returns the datagram length specified by that call.
//
// Preconditions:
// * ep is a server Endpoint.
// * ep.SendRecv(), ep.RecvFirst(), and ep.SendLast() have never been called.
// - ep is a server Endpoint.
// - ep.SendRecv(), ep.RecvFirst(), and ep.SendLast() have never been called.
func (ep *Endpoint) RecvFirst() (uint32, error) {
if err := ep.ctrlWaitFirst(); err != nil {
return 0, err
@@ -216,11 +216,11 @@ func (ep *Endpoint) RecvFirst() (uint32, error) {
// Endpoint.SendRecv() or Endpoint.SendLast().
//
// Preconditions:
// * dataLen <= ep.DataCap().
// * No previous call to ep.SendRecv() or ep.RecvFirst() has returned an error.
// * ep.SendLast() has never been called.
// * If ep is a client Endpoint, ep.Connect() has previously been called and
// returned nil.
// - dataLen <= ep.DataCap().
// - No previous call to ep.SendRecv() or ep.RecvFirst() has returned an error.
// - ep.SendLast() has never been called.
// - If ep is a client Endpoint, ep.Connect() has previously been called and
// returned nil.
func (ep *Endpoint) SendRecv(dataLen uint32) (uint32, error) {
return ep.sendRecv(dataLen, false /* mayRetainP */)
}
@@ -264,11 +264,11 @@ func (ep *Endpoint) sendRecv(dataLen uint32, mayRetainP bool) (uint32, error) {
// Endpoint.RecvFirst() to return with the given datagram length.
//
// Preconditions:
// * dataLen <= ep.DataCap().
// * No previous call to ep.SendRecv() or ep.RecvFirst() has returned an error.
// * ep.SendLast() has never been called.
// * If ep is a client Endpoint, ep.Connect() has previously been called and
// returned nil.
// - dataLen <= ep.DataCap().
// - No previous call to ep.SendRecv() or ep.RecvFirst() has returned an error.
// - ep.SendLast() has never been called.
// - If ep is a client Endpoint, ep.Connect() has previously been called and
// returned nil.
func (ep *Endpoint) SendLast(dataLen uint32) error {
if dataLen > ep.dataCap {
panic(fmt.Sprintf("attempting to send packet with datagram length %d (maximum %d)", dataLen, ep.dataCap))
+9 -9
View File
@@ -25,11 +25,11 @@ import (
// Packets consist of a 16-byte header followed by an arbitrarily-sized
// datagram. The header consists of:
//
// - A 4-byte native-endian connection state.
// - A 4-byte native-endian connection state.
//
// - A 4-byte native-endian datagram length in bytes.
// - A 4-byte native-endian datagram length in bytes.
//
// - 8 reserved bytes.
// - 8 reserved bytes.
const (
// PacketHeaderBytes is the size of a flipcall packet header in bytes. The
// maximum datagram size supported by a flipcall connection is equal to the
@@ -55,13 +55,13 @@ func (ep *Endpoint) dataLen() *atomicbitops.Uint32 {
// Endpoint, which may concurrently mutate the contents of the packet window.
// Thus:
//
// - Readers must not assume that two reads of the same byte in Data() will
// return the same result. In other words, readers should read any given byte
// in Data() at most once.
// - Readers must not assume that two reads of the same byte in Data() will
// return the same result. In other words, readers should read any given byte
// in Data() at most once.
//
// - Writers must not assume that they will read back the same data that they
// have written. In other words, writers should avoid reading from Data() at
// all.
// - Writers must not assume that they will read back the same data that they
// have written. In other words, writers should avoid reading from Data() at
// all.
func (ep *Endpoint) Data() (bs []byte) {
bshdr := (*reflect.SliceHeader)(unsafe.Pointer(&bs))
bshdr.Data = ep.packet + PacketHeaderBytes
+10 -10
View File
@@ -83,9 +83,9 @@ func AddrRangeSeqFromSlice(slice []AddrRange) AddrRangeSeq {
}
// Preconditions:
// * The combined length of all AddrRanges in slice <= limit.
// * limit >= 0.
// * If len(slice) != 0, then limit > 0.
// - The combined length of all AddrRanges in slice <= limit.
// - limit >= 0.
// - If len(slice) != 0, then limit > 0.
func addrRangeSeqFromSliceLimited(slice []AddrRange, limit int64) AddrRangeSeq {
switch len(slice) {
case 0:
@@ -179,13 +179,13 @@ func (ars AddrRangeSeq) externalTail() AddrRangeSeq {
// at least ars.Head(), even if n == 0. This guarantees that the basic pattern
// of:
//
// for !ars.IsEmpty() {
// n, err = doIOWith(ars.Head())
// if err != nil {
// return err
// }
// ars = ars.DropFirst(n)
// }
// for !ars.IsEmpty() {
// n, err = doIOWith(ars.Head())
// if err != nil {
// return err
// }
// ars = ars.DropFirst(n)
// }
//
// works even in the presence of zero-length AddrRanges.
//
+4 -3
View File
@@ -55,9 +55,10 @@ func (ElementMapper) linkerFor(elem Element) Linker { return elem }
// The zero value for List is an empty list ready to use.
//
// To iterate over a list (where l is a List):
// for e := l.Front(); e != nil; e = e.Next() {
// // do something with e.
// }
//
// for e := l.Front(); e != nil; e = e.Next() {
// // do something with e.
// }
//
// +stateify savable
type List struct {
+4 -4
View File
@@ -402,10 +402,10 @@ func debugf(action string, comm Communicator, debugMsg debugStringer) {
// Postcondition: releaseCommunicator() must be called on the returned value.
func (c *Client) acquireCommunicator() Communicator {
// Prefer using channel over socket because:
// - Channel uses a shared memory region for passing messages. IO from shared
// memory is faster and does not involve making a syscall.
// - No intermediate buffer allocation needed. With a channel, the message
// can be directly pasted into the shared memory region.
// - Channel uses a shared memory region for passing messages. IO from shared
// memory is faster and does not involve making a syscall.
// - No intermediate buffer allocation needed. With a channel, the message
// can be directly pasted into the shared memory region.
if ch := c.getChannel(); ch != nil {
return ch
}
+6 -6
View File
@@ -37,10 +37,10 @@ import (
// RPC concurrency.
//
// Reference model:
// * When any FD is created, the connection takes a ref on it which represents
// the client's ref on the FD.
// * The client can drop its ref via the Close RPC which will in turn make the
// connection drop its ref.
// - When any FD is created, the connection takes a ref on it which represents
// the client's ref on the FD.
// - The client can drop its ref via the Close RPC which will in turn make the
// connection drop its ref.
type Connection struct {
// server is the server on which this connection was created. It is immutably
// associated with it for its entire lifetime.
@@ -343,8 +343,8 @@ func (c *Connection) removeFD(id FDID) {
// removeControlFDLocked is the same as removeFD with added preconditions.
//
// Preconditions:
// * server's rename mutex must at least be read locked.
// * id must be pointing to a control FD.
// - server's rename mutex must at least be read locked.
// - id must be pointing to a control FD.
func (c *Connection) removeControlFDLocked(id FDID) {
c.fdsMu.Lock()
fd := c.stopTrackingFD(id)

Some files were not shown because too many files have changed in this diff Show More