// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris

package socktest

import 

// Accept4 wraps syscall.Accept4.
func ( *Switch) (,  int) ( int,  syscall.Sockaddr,  error) {
	 := .sockso()
	if  == nil {
		return syscall.Accept4(, )
	}
	.fmu.RLock()
	 := .fltab[FilterAccept]
	.fmu.RUnlock()

	,  := .apply()
	if  != nil {
		return -1, nil, 
	}
	, , .Err = syscall.Accept4(, )
	if  = .apply();  != nil {
		if .Err == nil {
			syscall.Close()
		}
		return -1, nil, 
	}

	.smu.Lock()
	defer .smu.Unlock()
	if .Err != nil {
		.stats.getLocked(.Cookie).AcceptFailed++
		return -1, nil, .Err
	}
	 := .addLocked(, .Cookie.Family(), .Cookie.Type(), .Cookie.Protocol())
	.stats.getLocked(.Cookie).Accepted++
	return , , nil
}