Page MenuHome GnuPG

agent: Clean up check_own_socket to monitor socket takeover
Testing, WishlistPublic

Description

So far, our implementation does a bit awkward way to monitor socket takeover.

  • it is checked from handle_tick when CHECK_OWN_SOCKET_INTERVAL interval is detected
  • it is checked by spawning a thread (because it may take some time, which would be not good from handle_tick)
    • each time, sockname is allocated, and the thread is spawned

It is rather simpler to have a thread monitoring the takeover with a loop by the interval of CHECK_OWN_SOCKET_INTERVAL.

Event Timeline

gniibe triaged this task as Wishlist priority.Aug 30 2023, 3:56 AM
gniibe created this task.

FWIW: These days a thread on Linux is not that costly but nevertheless takes up resources. On other Unices (and WindowsCE) threads have quite some overhead and that was the reason I implemented it the way it was.

I see the reason.

These days, having a thread (or more) is OK for memory resource wise. Creating a thread may be still costly for execution resources. Once created and keep using the one makes sense.

This case of gpg-agent is a fallback (when inotify doesn't work or when gpg-agent is invoked as a child process). There is no monitoring thread usually.

For master, I'll look into dirmngr and keyboxd, which have similar code.