@@ -33,25 +33,26 @@ func httpListener() (net.Listener, error) {
33
33
return ln , nil
34
34
}
35
35
36
- func unixgramListener ( vn * virtualnetwork. VirtualNetwork ) (* net.UnixConn , error ) {
36
+ func setupUnixgramListener ( ) (net.Conn , error ) {
37
37
_ = os .Remove (constants .UnixgramSocketPath )
38
38
conn , err := transport .ListenUnixgram (fmt .Sprintf ("unixgram://%v" , constants .UnixgramSocketPath ))
39
39
if err != nil {
40
- return conn , errors .Wrap (err , "failed to listen unixgram" )
40
+ return nil , errors .Wrap (err , "failed to listen unixgram" )
41
41
}
42
- logging .Infof ("listening on %s: " , constants .UnixgramSocketPath )
42
+ logging .Infof ("listening on %s" , constants .UnixgramSocketPath )
43
43
vfkitConn , err := transport .AcceptVfkit (conn )
44
44
if err != nil {
45
- return conn , errors .Wrap (err , "failed to accept vfkit connection" )
45
+ return nil , errors .Wrap (err , "failed to accept vfkit connection" )
46
46
}
47
- go func () {
48
- err := vn .AcceptVfkit (context .Background (), vfkitConn )
49
- if err != nil {
50
- logging .Errorf ("failed to accept vfkit connection: %v" , err )
51
- return
52
- }
53
- }()
54
- return conn , err
47
+ return vfkitConn , nil
48
+ }
49
+
50
+ func handleUnixgramConnection (ctx context.Context , vn * virtualnetwork.VirtualNetwork , vfkitConn net.Conn ) {
51
+ defer vfkitConn .Close ()
52
+ if err := vn .AcceptVfkit (ctx , vfkitConn ); err != nil {
53
+ logging .Errorf ("failed to accept vfkit connection: %v" , err )
54
+ }
55
+ logging .Debugf ("Closed connection from %s" , vfkitConn .LocalAddr ().String ())
55
56
}
56
57
57
58
func checkIfDaemonIsRunning () (bool , error ) {
0 commit comments