virNetServerProcessClients: Remove goto

This gets rid of the goto and prepares the function for automatic
mutex management.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Tim Wiederhake 2022-04-12 13:05:19 +02:00
parent 0c4b391e2a
commit 42fccb4716

View File

@ -960,13 +960,19 @@ virNetServerHasClients(virNetServer *srv)
void void
virNetServerProcessClients(virNetServer *srv) virNetServerProcessClients(virNetServer *srv)
{ {
size_t i; size_t i = 0;
while (true) {
virNetServerClient *client; virNetServerClient *client;
bool removed = false;
virObjectLock(srv); virObjectLock(srv);
reprocess: if (i >= srv->nclients) {
for (i = 0; i < srv->nclients; i++) { virObjectUnlock(srv);
return;
}
client = srv->clients[i]; client = srv->clients[i];
virObjectLock(client); virObjectLock(client);
if (virNetServerClientWantCloseLocked(client)) if (virNetServerClientWantCloseLocked(client))
@ -974,25 +980,27 @@ virNetServerProcessClients(virNetServer *srv)
if (virNetServerClientIsClosedLocked(client)) { if (virNetServerClientIsClosedLocked(client)) {
VIR_DELETE_ELEMENT(srv->clients, i, srv->nclients); VIR_DELETE_ELEMENT(srv->clients, i, srv->nclients);
removed = true;
/* Update server authentication tracking */ /* Update server authentication tracking */
virNetServerSetClientAuthCompletedLocked(srv, client); virNetServerSetClientAuthCompletedLocked(srv, client);
virNetServerCheckLimits(srv);
}
virObjectUnlock(client); virObjectUnlock(client);
virNetServerCheckLimits(srv); if (removed) {
i = 0;
virObjectUnlock(srv); virObjectUnlock(srv);
virObjectUnref(client); virObjectUnref(client);
virObjectLock(srv); continue;
}
goto reprocess; i++;
} else {
virObjectUnlock(client);
}
}
virObjectUnlock(srv); virObjectUnlock(srv);
} }
}
const char * const char *