git: 89e3d5671ba1 - main - bsnmpclient(3): make it thread-safe

Jessica Clarke jrtc27 at freebsd.org
Tue Dec 29 15:11:59 UTC 2020


On 29 Dec 2020, at 15:00, Edward Tomasz Napierala <trasz at 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
> 
> /* 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.

Jess



More information about the dev-commits-src-all mailing list