Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Dec 2020 17:39:32 +0000
From:      Jessica Clarke <jrtc27@freebsd.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        Edward Tomasz Napierala <trasz@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@freebsd.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@freebsd.org>
Subject:   Re: git: 89e3d5671ba1 - main - bsnmpclient(3): make it thread-safe
Message-ID:  <CE843E61-D12E-4F6C-A117-FFC4B8677F61@freebsd.org>
In-Reply-To: <X%2Btpp0Q%2BfbFGHjs0@kib.kiev.ua>
References:  <202012291500.0BTF0vGw034594@gitrepo.freebsd.org> <DBC0C62C-1280-4ADE-BF03-18D781330E5A@freebsd.org> <X%2Btpp0Q%2BfbFGHjs0@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On 29 Dec 2020, at 17:38, Konstantin Belousov <kostikbel@gmail.com> =
wrote:
> On Tue, Dec 29, 2020 at 03:11:55PM +0000, Jessica Clarke wrote:
>> On 29 Dec 2020, at 15:00, Edward Tomasz Napierala <trasz@FreeBSD.org> =
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
>>>=20
>>> /* global context */
>>> -struct snmp_client snmp_client;
>>> +__thread struct snmp_client snmp_client;
>>=20
>> That comment is no longer true.
>>=20
>>> /* List of all outstanding requests */
>>> struct sent_pdu {
>>> @@ -86,7 +86,7 @@ struct sent_pdu {
>>> };
>>> LIST_HEAD(sent_pdu_list, sent_pdu);
>>>=20
>>> -static struct sent_pdu_list sent_pdus;
>>> +__thread static struct sent_pdu_list sent_pdus;
>>>=20
>>> /*
>>> * 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 {
>>> };
>>>=20
>>> /* the global context */
>>> -extern struct snmp_client snmp_client;
>>> +extern __thread struct snmp_client snmp_client;
>>=20
>> Ditto.
>>=20
>> 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.
>=20
> 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 ?

The exported functions implicitly use them to track state.

Jess




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CE843E61-D12E-4F6C-A117-FFC4B8677F61>