On Wed, 14 Aug 2019, Brian Reichert wrote:
> On Thu, Aug 01, 2019 at 07:18:20PM +0000, Zbigniew J??drzejewski-Szmek wrote:
> > Yes. (With the caveat that there *are* legitimate reasons to have new
> > long-lived fds created, so not every long-lived fd is "wrong".)
> 
> I finally was able to track down what's happening on my system.
> 
> This is sufficient to reproduce the effect of increasing the number
> of file descriptors open to /run/systemd/private; at least, on my
> box, in it's current state:
> 
>   sh -c 'exec 1>&-; /usr/bin/systemctl status ntpd.service'

I can reproduce this on CentOS 7's systemd 219, but not on Fedora 29's 
systemd 239.

On CentOS 7 I took two `strace -e desc -p 1` runs, comparing:

  # good
  sh -c 'exec 1>/dev/null; systemctl status tmp.mount'

with:

  # bad
  sh -c 'exec 1>&-; systemctl status tmp.mount'

The diff is:

  # diff -u /tmp/good /tmp/bad
  --- /tmp/good 2019-08-14 18:11:20.100792406 +1000
  +++ /tmp/bad  2019-08-14 18:11:24.882886972 +1000
  @@ -6,7 +6,7 @@
   fstat(24, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
   epoll_ctl(4, EPOLL_CTL_ADD, 24, {0, {u32=107062384, u64=94382013391984}}) = 0
   epoll_ctl(4, EPOLL_CTL_MOD, 24, {EPOLLIN|EPOLLOUT, {u32=107062384, 
u64=94382013391984}}) = 0
  -timerfd_settime(3, TFD_TIMER_ABSTIME, {it_interval={0, 0}, 
it_value={1136546, 444853000}}, NULL) = 0
  +timerfd_settime(3, TFD_TIMER_ABSTIME, {it_interval={0, 0}, 
it_value={1136551, 444853000}}, NULL) = 0
   epoll_wait(4, [{EPOLLOUT, {u32=107062384, u64=94382013391984}}], 58, -1) = 1
   epoll_ctl(4, EPOLL_CTL_MOD, 24, {EPOLLIN, {u32=107062384, 
u64=94382013391984}}) = 0
   epoll_wait(4, [{EPOLLIN, {u32=107062384, u64=94382013391984}}], 58, -1) = 1
  @@ -23,13 +23,7 @@
   openat(AT_FDCWD, "/usr/local/lib/systemd/system/tmp.mount.d", 
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or 
directory)
   openat(AT_FDCWD, "/usr/lib/systemd/system/tmp.mount.d", 
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or 
directory)
   openat(AT_FDCWD, "/run/systemd/generator.late/tmp.mount.d", 
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or 
directory)
  -epoll_wait(4, [{EPOLLIN|EPOLLHUP, {u32=107062384, u64=94382013391984}}], 58, 
-1) = 1
  -epoll_ctl(4, EPOLL_CTL_MOD, 24, {0, {u32=107062384, u64=94382013391984}}) = 0
  -timerfd_settime(3, TFD_TIMER_ABSTIME, {it_interval={0, 0}, it_value={0, 1}}, 
NULL) = 0
  -epoll_wait(4, [{EPOLLHUP, {u32=107062384, u64=94382013391984}}, {EPOLLIN, 
{u32=3, u64=3}}], 58, -1) = 2
  -read(3, "\1\0\0\0\0\0\0\0", 8)          = 8
  +epoll_wait(4, [{EPOLLIN, {u32=107062384, u64=94382013391984}}], 58, -1) = 1
   epoll_ctl(4, EPOLL_CTL_DEL, 24, NULL)   = 0
  -close(24)                               = 0
  -timerfd_settime(3, TFD_TIMER_ABSTIME, {it_interval={0, 0}, 
it_value={1136622, 194853000}}, NULL) = 0
   epoll_wait(4, strace: Process 1 detached
  <detached ...>

So it looks like systemd is removing the file descriptor from the epoll 
instance in both cases. However, in the "bad" case no EOF was reached, and 
the file descriptor is never closed. Looking at `ss` there is still 387 
bytes in this descriptor's receive queue.
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to