mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Rename kernel.SocketEntry to kernel.SocketRecord
SocketEntry can be confusing with the template types as the 'Entry' is usually used as a suffix for list element types, e.g. socketEntry in the same package. Suggested by Dean (@dean-deng). Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
This commit is contained in:
@@ -69,8 +69,8 @@ go_template_instance(
|
||||
prefix = "socket",
|
||||
template = "//pkg/ilist:generic_list",
|
||||
types = {
|
||||
"Element": "*SocketEntry",
|
||||
"Linker": "*SocketEntry",
|
||||
"Element": "*SocketRecord",
|
||||
"Linker": "*SocketRecord",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
+14
-14
@@ -224,9 +224,9 @@ type Kernel struct {
|
||||
// extMu.
|
||||
sockets socketList
|
||||
|
||||
// nextSocketEntry is the next entry number to use in sockets. Protected
|
||||
// nextSocketRecord is the next entry number to use in sockets. Protected
|
||||
// by extMu.
|
||||
nextSocketEntry uint64
|
||||
nextSocketRecord uint64
|
||||
|
||||
// deviceRegistry is used to save/restore device.SimpleDevices.
|
||||
deviceRegistry struct{} `state:".(*device.Registry)"`
|
||||
@@ -1509,11 +1509,11 @@ func (k *Kernel) SupervisorContext() context.Context {
|
||||
}
|
||||
}
|
||||
|
||||
// SocketEntry represents a socket recorded in Kernel.sockets. It implements
|
||||
// SocketRecord represents a socket recorded in Kernel.sockets. It implements
|
||||
// refs.WeakRefUser for sockets stored in the socket table.
|
||||
//
|
||||
// +stateify savable
|
||||
type SocketEntry struct {
|
||||
type SocketRecord struct {
|
||||
socketEntry
|
||||
k *Kernel
|
||||
Sock *refs.WeakRef
|
||||
@@ -1522,7 +1522,7 @@ type SocketEntry struct {
|
||||
}
|
||||
|
||||
// WeakRefGone implements refs.WeakRefUser.WeakRefGone.
|
||||
func (s *SocketEntry) WeakRefGone(context.Context) {
|
||||
func (s *SocketRecord) WeakRefGone(context.Context) {
|
||||
s.k.extMu.Lock()
|
||||
s.k.sockets.Remove(s)
|
||||
s.k.extMu.Unlock()
|
||||
@@ -1533,9 +1533,9 @@ func (s *SocketEntry) WeakRefGone(context.Context) {
|
||||
// Precondition: Caller must hold a reference to sock.
|
||||
func (k *Kernel) RecordSocket(sock *fs.File) {
|
||||
k.extMu.Lock()
|
||||
id := k.nextSocketEntry
|
||||
k.nextSocketEntry++
|
||||
s := &SocketEntry{k: k, ID: id}
|
||||
id := k.nextSocketRecord
|
||||
k.nextSocketRecord++
|
||||
s := &SocketRecord{k: k, ID: id}
|
||||
s.Sock = refs.NewWeakRef(sock, s)
|
||||
k.sockets.PushBack(s)
|
||||
k.extMu.Unlock()
|
||||
@@ -1550,9 +1550,9 @@ func (k *Kernel) RecordSocket(sock *fs.File) {
|
||||
// vfs.FileDescription, because we do not support weak refs on VFS2 files.
|
||||
func (k *Kernel) RecordSocketVFS2(sock *vfs.FileDescription) {
|
||||
k.extMu.Lock()
|
||||
id := k.nextSocketEntry
|
||||
k.nextSocketEntry++
|
||||
s := &SocketEntry{
|
||||
id := k.nextSocketRecord
|
||||
k.nextSocketRecord++
|
||||
s := &SocketRecord{
|
||||
k: k,
|
||||
ID: id,
|
||||
SockVFS2: sock,
|
||||
@@ -1563,11 +1563,11 @@ func (k *Kernel) RecordSocketVFS2(sock *vfs.FileDescription) {
|
||||
|
||||
// ListSockets returns a snapshot of all sockets.
|
||||
//
|
||||
// Callers of ListSockets() in VFS2 should use SocketEntry.SockVFS2.TryIncRef()
|
||||
// Callers of ListSockets() in VFS2 should use SocketRecord.SockVFS2.TryIncRef()
|
||||
// to get a reference on a socket in the table.
|
||||
func (k *Kernel) ListSockets() []*SocketEntry {
|
||||
func (k *Kernel) ListSockets() []*SocketRecord {
|
||||
k.extMu.Lock()
|
||||
var socks []*SocketEntry
|
||||
var socks []*SocketRecord
|
||||
for s := k.sockets.Front(); s != nil; s = s.Next() {
|
||||
socks = append(socks, s)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user