containerd / ttrpc

GRPC for low-memory environments
Apache License 2.0
558 stars 80 forks source link

Handle EOF to prevent file descriptor leak #37

Closed georgethebeatle closed 5 years ago

georgethebeatle commented 5 years ago

Currently the EOF that the server gets when a client connection is closed is being ignored, which means that the goroutine that is processing the client connection will never exit. If it never exits it will never close the underlying unix socket and this would lead to a file descriptor leak.

Signed-off-by: Georgi Sabev georgethebeatle@gmail.com

Reprodction steps:

# create a long running task
ctr image pull docker.io/library/alpine:latest
ctr run --rm docker.io/library/alpine:latest test sleep 9999

# count number of open sockets
ls -la /proc/$(pidof containerd-shim)/fd | grep socket | wc -l
2

# restart containerd to make it reconnect to the shim 
kill $(pidof containerd)
containerd & 

# observe that socket number increased. It increases by 1 with every containerd restart
ls -la /proc/$(pidof containerd-shim)/fd | grep socket | wc -l
3
crosbymichael commented 5 years ago

LGTM