[libvirt] [snmp PATCH 11/20] libvirtRegisterEvents: Drop pthread_attr_init

Martin Kletzander mkletzan at redhat.com
Fri Oct 19 10:43:09 UTC 2018


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 at redhat.com>
>---
> 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 at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20181019/13065715/attachment-0001.sig>


More information about the libvir-list mailing list