From owner-dev-commits-src-main@freebsd.org Tue Dec 29 17:38:55 2020 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3EE1A4C5F32; Tue, 29 Dec 2020 17:38:55 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4D51qf6TYFz4s70; Tue, 29 Dec 2020 17:38:54 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 0BTHcl75062674 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 29 Dec 2020 19:38:50 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 0BTHcl75062674 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 0BTHclVG062672; Tue, 29 Dec 2020 19:38:47 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 29 Dec 2020 19:38:47 +0200 From: Konstantin Belousov To: Jessica Clarke Cc: Edward Tomasz Napierala , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Subject: Re: git: 89e3d5671ba1 - main - bsnmpclient(3): make it thread-safe Message-ID: References: <202012291500.0BTF0vGw034594@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4D51qf6TYFz4s70 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "Commit messages for the main branch of the src repository." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Dec 2020 17:38:55 -0000 On Tue, Dec 29, 2020 at 03:11:55PM +0000, Jessica Clarke wrote: > On 29 Dec 2020, at 15:00, Edward Tomasz Napierala wrote: > > diff --git a/contrib/bsnmp/lib/snmpclient.c b/contrib/bsnmp/lib/snmpclient.c > > index c22d8e125a14..e49105918416 100644 > > --- a/contrib/bsnmp/lib/snmpclient.c > > +++ b/contrib/bsnmp/lib/snmpclient.c > > @@ -71,7 +71,7 @@ > > #define DEBUG_PARSE 0 > > > > /* global context */ > > -struct snmp_client snmp_client; > > +__thread struct snmp_client snmp_client; > > That comment is no longer true. > > > /* List of all outstanding requests */ > > struct sent_pdu { > > @@ -86,7 +86,7 @@ struct sent_pdu { > > }; > > LIST_HEAD(sent_pdu_list, sent_pdu); > > > > -static struct sent_pdu_list sent_pdus; > > +__thread static struct sent_pdu_list sent_pdus; > > > > /* > > * Prototype table entry. All C-structure produced by the table function must > > diff --git a/contrib/bsnmp/lib/snmpclient.h b/contrib/bsnmp/lib/snmpclient.h > > index a19bdb2ea653..1bc3780de038 100644 > > --- a/contrib/bsnmp/lib/snmpclient.h > > +++ b/contrib/bsnmp/lib/snmpclient.h > > @@ -114,7 +114,7 @@ struct snmp_client { > > }; > > > > /* the global context */ > > -extern struct snmp_client snmp_client; > > +extern __thread struct snmp_client snmp_client; > > Ditto. > > Is there really a documented requirement for everything to be called > from the same thread? I can see consumers of the library that already > use proper locking breaking because of this. So this variable is supposed to be used by consumers ? The change requires the library version bump, at least. I suppose libsnmpclient does not use symbol versioning ?