mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Make HostBountEndpoint.SetBoundSocketFD take ownership of bound socket FD.
Earlier SetBoundSocketFD() was taking ownership of bound socket FD only on success. Having it take ownership unconditionally is cleaner. PiperOrigin-RevId: 516903597
This commit is contained in:
@@ -595,10 +595,11 @@ func (e *connectionedEndpoint) OnSetSendBufferSize(v int64) (newSz int64) {
|
||||
func (e *connectionedEndpoint) WakeupWriters() {}
|
||||
|
||||
// SetBoundSocketFD implement HostBountEndpoint.SetBoundSocketFD.
|
||||
func (e *connectionedEndpoint) SetBoundSocketFD(bsFD BoundSocketFD) error {
|
||||
func (e *connectionedEndpoint) SetBoundSocketFD(ctx context.Context, bsFD BoundSocketFD) error {
|
||||
e.Lock()
|
||||
defer e.Unlock()
|
||||
if e.path != "" || e.boundSocketFD != nil {
|
||||
bsFD.Close(ctx)
|
||||
return syserr.ErrAlreadyBound.ToError()
|
||||
}
|
||||
e.boundSocketFD = bsFD
|
||||
|
||||
@@ -269,9 +269,9 @@ type BoundEndpoint interface {
|
||||
type HostBoundEndpoint interface {
|
||||
// SetBoundSocketFD will be called on supporting endpoints after
|
||||
// binding a socket on the host filesystem. Implementations should
|
||||
// delegate Listen and Accept calls to the BoundSocketFD. On success,
|
||||
// the ownership of bsFD is transferred to the endpoint.
|
||||
SetBoundSocketFD(bsFD BoundSocketFD) error
|
||||
// delegate Listen and Accept calls to the BoundSocketFD. The ownership
|
||||
// of bsFD is transferred to the endpoint.
|
||||
SetBoundSocketFD(ctx context.Context, bsFD BoundSocketFD) error
|
||||
|
||||
// ResetBoundSocketFD cleans up the BoundSocketFD set by the last successful
|
||||
// SetBoundSocketFD call.
|
||||
|
||||
Reference in New Issue
Block a user