From nobody Mon Feb 9 21:37:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1628169066; cv=none; d=zohomail.com; s=zohoarc; b=iL11elvK4IGYFPpOmSZiEgIfY2iHnKRtWkYU1IdZ5c0xUUcqfWfqsTOo0h6aV9MXUHHfwG0I/2WjHfdrOxgL38hHfscdxcLltuYYdVWOSdpH/kbKpmT/iuF6jaxdpnJv4IQI6s+C5A8y3baZj0/9tgzg75P4vTNpG8OnlyEDoFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628169066; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t9iOjLXZQ6v1dXpI4t47hNZxb0chAc1cenDJLQgjSPE=; b=K2Oma7QkqaiwArXYPZbjK229VPR0KSoCaXeD+ADDE+JiTW/N89KmWmVAQj0R84rBFqxKaacQ/aPgEp4PivnPRzsUWrcxk+oRrNZe9Pum36ZyC43ipS3cFJfCVEK+VfURyZ9LSh9Mg39un+8vgYCDdchgpPsUnZITwny1MhW2r24= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1628169066496508.2285700214526; Thu, 5 Aug 2021 06:11:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-sPuabFBTNQmnkmDREkcmeQ-1; Thu, 05 Aug 2021 09:11:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC8CC1006C84; Thu, 5 Aug 2021 13:10:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 87FE75C25D; Thu, 5 Aug 2021 13:10:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4F3164A7CA; Thu, 5 Aug 2021 13:10:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 175D92dh007223 for ; Thu, 5 Aug 2021 09:09:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 65FF910016F2; Thu, 5 Aug 2021 13:09:02 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.194.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB9581002D71; Thu, 5 Aug 2021 13:09:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628169065; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=t9iOjLXZQ6v1dXpI4t47hNZxb0chAc1cenDJLQgjSPE=; b=HK784ol4hDoevVUdxtYR8blLJojPKOZKARD89b2+DktveyLAOO9w5GXNIB5642vY3Xz0RU f8lwcFMwy/kOI+yooigsPITImaR8sgIvLbsWY3mw7gYTLCNac0bRlD+KHhljJ/GoTyYIJT mX9EoP9sN0UDuz+i4cpmz6oDpb8iF2I= X-MC-Unique: sPuabFBTNQmnkmDREkcmeQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 6/7] virMutex*: Warn on error Date: Thu, 5 Aug 2021 15:08:50 +0200 Message-Id: <20210805130851.55552-7-twiederh@redhat.com> In-Reply-To: <20210805130851.55552-1-twiederh@redhat.com> References: <20210805130851.55552-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1628169067906100001 Content-Type: text/plain; charset="utf-8" `pthread_mutex_destroy`, `pthread_mutex_lock` and `pthread_mutex_unlock` return an error code that is currently ignored. Add debug information if one of these operations failed, e.g. when there is an attempt to destroy a still locked mutex or unlock and already unlocked mutex. Signed-off-by: Tim Wiederhake --- src/util/virthread.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/util/virthread.c b/src/util/virthread.c index e89c1a09fb..f64dbee9e9 100644 --- a/src/util/virthread.c +++ b/src/util/virthread.c @@ -35,7 +35,10 @@ =20 #include "viralloc.h" #include "virthreadjob.h" +#include "virlog.h" =20 +#define VIR_FROM_THIS VIR_FROM_THREAD +VIR_LOG_INIT("util.thread"); =20 int virOnce(virOnceControl *once, virOnceFunc init) { @@ -83,17 +86,23 @@ int virMutexInitRecursive(virMutex *m) =20 void virMutexDestroy(virMutex *m) { - pthread_mutex_destroy(&m->lock); + if (pthread_mutex_destroy(&m->lock)) { + VIR_WARN("Failed to destroy mutex=3D%p", m); + } } =20 void virMutexLock(virMutex *m) { - pthread_mutex_lock(&m->lock); + if (pthread_mutex_lock(&m->lock)) { + VIR_WARN("Failed to lock mutex=3D%p", m); + } } =20 void virMutexUnlock(virMutex *m) { - pthread_mutex_unlock(&m->lock); + if (pthread_mutex_unlock(&m->lock)) { + VIR_WARN("Failed to unlock mutex=3D%p", m); + } } =20 =20 --=20 2.31.1