Files
snapd/daemon
Alberto Mardegan da1caa8b12 daemon: use the syscall connection to get the socket credentials
For some reason, the old code was causing snapd to hang when asked to
terminate if there were still some clients connected: the connection
would not move to the "idle" state.

This was found while investigating LP#1946656, and as a matter of facts
it fixes it. While debugging, an inspection of snapd threads while in
hanging state revealed that one thread was stuck in

    daemon.(*ucrednetConn).Read

and it was verified that removing the Accept function completely would
resolve the issue (though also considerably changing snapd behaviour).

The problem with the old code does not lie in duplicating the file
descriptor (which is done by calling UnixConn.File()), but rather in the
apparently innocuous call to File.Fd(): as it can be seen by looking at
its source code[^note1], this function sets the file descriptor mode to
blocking, and this is what causes our connections to hang.

[^note1]: https://cs.opensource.google/go/go/+/refs/tags/go1.17.2:src/os/file_unix.go;l=81-88
2021-10-18 12:56:16 -05:00
..
2021-06-03 13:49:26 +02:00
2021-06-03 13:49:26 +02:00
2021-06-03 13:49:26 +02:00
2021-06-03 13:49:26 +02:00
2021-06-03 13:49:26 +02:00
2021-06-03 13:49:26 +02:00
2021-06-03 13:49:26 +02:00
2021-06-03 13:49:26 +02:00
2021-06-03 13:49:26 +02:00
2021-06-03 13:49:26 +02:00
2021-06-03 13:49:26 +02:00
2021-06-03 13:49:26 +02:00
2020-12-08 09:53:13 +01:00