On Thu, Oct 18, 2018 at 02:26:49PM +0200, Michal Privoznik wrote:
The threads are JOINABLE by default. No need to go through pthread_attr_* circus to set what is default anyway. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/libvirtSnmp.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/libvirtSnmp.c b/src/libvirtSnmp.c index 3b5c17f..88f2ec6 100644 --- a/src/libvirtSnmp.c +++ b/src/libvirtSnmp.c @@ -205,7 +205,7 @@ pollingThreadFunc(void *foo) int libvirtRegisterEvents(virConnectPtr conn) { struct sigaction action_stop; - pthread_attr_t thread_attr; + int ret = -1; memset(&action_stop, 0, sizeof action_stop); @@ -226,15 +226,12 @@ libvirtRegisterEvents(virConnectPtr conn) { return -1; /* we need a thread to poll for events */ - pthread_attr_init(&thread_attr); - pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE); + if (pthread_create(&poll_thread, NULL, pollingThreadFunc, NULL)) + goto cleanup; - if (pthread_create(&poll_thread, &thread_attr, pollingThreadFunc, NULL)) - return -1; - - pthread_attr_destroy(&thread_attr); - - return 0; + ret = 0; + cleanup:
Not really a need for cleanup here, but I'm guessing you just want to have everything follow the same pattern.
+ return ret; } /* Unregister domain events collection */ -- 2.18.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list