Fix: Handle close_connection when writefds is 0 #2042
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Ensure that close_connection is set when writefds is 0.
Check close_connection before doing select.
Why
To make sure the serve_gmp select loop exits in situations where EOF is received before writefds is set. This happens for example if EOF is received before we queue a response to the client.
For me this solved the problem of many gvmd processes hanging around when using GSA. If I clicked around GSA enough I would eventually get these:
md manage:WARNING:2023-07-10 15h10.16 utc:2550706: sql_open: PQerrorMessage (conn): connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: remaining connection slots are reserved for non-replication superuser connections
References
Problem introduced in /pull/2028.
Closes #2038.
GEA-242