From a3a1c372cb5d3e97bbd83192cfedb0f07f186c14 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 27 Dec 2019 15:19:22 +0100 Subject: [PATCH] xbps_array_foreach_cb_multi: improve previous. Do not wait for the other threads to finish, just exit early. --- lib/plist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/plist.c b/lib/plist.c index 7a4008a8..afa2a974 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -152,7 +152,7 @@ xbps_array_foreach_cb_multi(struct xbps_handle *xhp, if ((rv = pthread_create(&thd[i].thread, NULL, array_foreach_thread, &thd[i])) != 0) { error = rv; - break; + goto out; } } @@ -160,6 +160,7 @@ xbps_array_foreach_cb_multi(struct xbps_handle *xhp, for (int i = 0; i < maxthreads; i++) rv = pthread_join(thd[i].thread, NULL); +out: free(thd); pthread_spin_destroy(&reserved_lock);