CLEANUP: server: make it clear that srv_check_for_deletion() is thread-safe

This function was marked as requiring thread isolation because its code
was extracted from cli_parse_delete_server() and was running under
isolation. But upon closer inspection, and using atomic loads to check
a few counters, it is actually safe to run without isolation, so let's
reflect that in its description.

However, it remains true that cli_parse_delete_server() continues to call
it under isolation.
This commit is contained in:
Willy Tarreau 2025-03-18 11:38:56 +01:00
parent 0e8c573b4b
commit aad8e74cb9

View File

@ -6044,11 +6044,13 @@ out:
} }
/* Check if the server <bename>/<svname> exists and is ready for being deleted. /* Check if the server <bename>/<svname> exists and is ready for being deleted.
* Both <bename> and <svname> must be valid strings. This must be called under * This means that the server is in maintenance with no streams attached to it,
* thread isolation. If pb/ps are not null, upon success, the pointer to * no queue and no used idle conns. This is not supposed to change during all
* the backend and server respectively will be put there. If pm is not null, * the maintenance phase (except for force-persist etc, which are not covered).
* a pointer to an error/success message is returned there (possibly NULL if * Both <bename> and <svname> must be valid strings. If pb/ps are not null,
* nothing to say). Returned values: * upon success, the pointer to the backend and server respectively will be put
* there. If pm is not null, a pointer to an error/success message is returned
* there (possibly NULL if nothing to say). Returned values:
* >0 if OK * >0 if OK
* 0 if not yet (should wait if it can) * 0 if not yet (should wait if it can)
* <0 if not possible * <0 if not possible
@ -6091,8 +6093,8 @@ int srv_check_for_deletion(const char *bename, const char *svname, struct proxy
ret = 0; ret = 0;
/* Ensure that there is no active/pending connection on the server. */ /* Ensure that there is no active/pending connection on the server. */
if (srv->curr_used_conns || if (_HA_ATOMIC_LOAD(&srv->curr_used_conns) ||
srv->queueslength || srv_has_streams(srv)) { _HA_ATOMIC_LOAD(&srv->queueslength) || srv_has_streams(srv)) {
msg = "Server still has connections attached to it, cannot remove it."; msg = "Server still has connections attached to it, cannot remove it.";
goto leave; goto leave;
} }