github.com/forest33/wtun@v0.3.1/conn/bind_std_test.go (about)

     1  package conn
     2  
     3  import "testing"
     4  
     5  func TestStdNetBindReceiveFuncAfterClose(t *testing.T) {
     6  	bind := NewStdNetBind().(*StdNetBind)
     7  	fns, _, err := bind.Open(0)
     8  	if err != nil {
     9  		t.Fatal(err)
    10  	}
    11  	bind.Close()
    12  	bufs := make([][]byte, 1)
    13  	bufs[0] = make([]byte, 1)
    14  	sizes := make([]int, 1)
    15  	eps := make([]Endpoint, 1)
    16  	for _, fn := range fns {
    17  		// The ReceiveFuncs must not access conn-related fields on StdNetBind
    18  		// unguarded. Close() nils the conn-related fields resulting in a panic
    19  		// if they violate the mutex.
    20  		fn(bufs, sizes, eps)
    21  	}
    22  }