The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / uclibc / 0.9.33.2 / 0022-inet-rpc-fix-authnone_marshal-in-multithreading-cont.patch
1 From 5c797a24a7d6337b5e654079a8d815199b1e8364 Mon Sep 17 00:00:00 2001
2 From: Carmelo Amoroso <carmelo.amoroso@st.com>
3 Date: Thu, 2 Feb 2012 18:22:36 +0100
4 Subject: [PATCH] inet:rpc: fix authnone_marshal in multithreading context
5
6 This is a port of glibc's fix by Zack Weinberg as reported
7 in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=142312,
8 and discussed in http://sourceware.org/ml/libc-alpha/2002-04/msg00069.html
9 and following.
10
11 Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
12 ---
13  libc/inet/rpc/auth_none.c   |   59 +++++++++++++++++++++----------------------
14  libc/inet/rpc/rpc_private.h |    2 --
15  libc/inet/rpc/rpc_thread.c  |    1 -
16  3 files changed, 29 insertions(+), 33 deletions(-)
17
18 diff --git a/libc/inet/rpc/auth_none.c b/libc/inet/rpc/auth_none.c
19 index c48bbfe..d066f6b 100644
20 --- a/libc/inet/rpc/auth_none.c
21 +++ b/libc/inet/rpc/auth_none.c
22 @@ -66,49 +66,48 @@ struct authnone_private_s {
23    char marshalled_client[MAX_MARSHAL_SIZE];
24    u_int mcnt;
25  };
26 -#ifdef __UCLIBC_HAS_THREADS__
27 -#define authnone_private (*(struct authnone_private_s **)&RPC_THREAD_VARIABLE(authnone_private_s))
28 -#else
29 -static struct authnone_private_s *authnone_private;
30 -#endif
31  
32 -AUTH *
33 -authnone_create (void)
34 +static struct authnone_private_s authnone_private;
35 +__libc_once_define(static, authnone_private_guard);
36 +
37 +static void authnone_create_once (void);
38 +
39 +static void
40 +authnone_create_once (void)
41  {
42    struct authnone_private_s *ap;
43    XDR xdr_stream;
44    XDR *xdrs;
45  
46 -  ap = (struct authnone_private_s *) authnone_private;
47 -  if (ap == NULL)
48 -    {
49 -      ap = (struct authnone_private_s *) calloc (1, sizeof (*ap));
50 -      if (ap == NULL)
51 -       return NULL;
52 -      authnone_private = ap;
53 -    }
54 -  if (!ap->mcnt)
55 -    {
56 -      ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
57 -      ap->no_client.ah_ops = (struct auth_ops *)&ops;
58 -      xdrs = &xdr_stream;
59 -      xdrmem_create (xdrs, ap->marshalled_client, (u_int) MAX_MARSHAL_SIZE,
60 -                    XDR_ENCODE);
61 -      (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_cred);
62 -      (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_verf);
63 -      ap->mcnt = XDR_GETPOS (xdrs);
64 -      XDR_DESTROY (xdrs);
65 -    }
66 -  return (&ap->no_client);
67 +  ap = &authnone_private;
68 +
69 +  ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
70 +  ap->no_client.ah_ops = (struct auth_ops *) &ops;
71 +  xdrs = &xdr_stream;
72 +  xdrmem_create(xdrs, ap->marshalled_client,
73 +                        (u_int) MAX_MARSHAL_SIZE, XDR_ENCODE);
74 +  (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
75 +  (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
76 +  ap->mcnt = XDR_GETPOS (xdrs);
77 +  XDR_DESTROY (xdrs);
78 +}
79 +
80 +AUTH *
81 +authnone_create (void)
82 +{
83 +  __libc_once (authnone_private_guard, authnone_create_once);
84 +  return &authnone_private.no_client;
85  }
86  libc_hidden_def(authnone_create)
87  
88  static bool_t
89 -authnone_marshal (AUTH *client attribute_unused, XDR *xdrs)
90 +authnone_marshal (AUTH *client, XDR *xdrs)
91  {
92    struct authnone_private_s *ap;
93  
94 -  ap = authnone_private;
95 +  /* authnone_create returned authnone_private->no_client, which is
96 +     the first field of struct authnone_private_s.  */
97 +  ap = (struct authnone_private_s *) client;
98    if (ap == NULL)
99      return FALSE;
100    return (*xdrs->x_ops->x_putbytes) (xdrs, ap->marshalled_client, ap->mcnt);
101 diff --git a/libc/inet/rpc/rpc_private.h b/libc/inet/rpc/rpc_private.h
102 index ede3ddf..e1214d2 100644
103 --- a/libc/inet/rpc/rpc_private.h
104 +++ b/libc/inet/rpc/rpc_private.h
105 @@ -18,8 +18,6 @@ struct rpc_thread_variables {
106         struct pollfd   *svc_pollfd_s;          /* Global, rpc_common.c */
107         int             svc_max_pollfd_s;       /* Global, rpc_common.c */
108  
109 -       void            *authnone_private_s;    /* auth_none.c */
110 -
111         void            *clnt_perr_buf_s;       /* clnt_perr.c */
112  
113         void            *clntraw_private_s;     /* clnt_raw.c */
114 diff --git a/libc/inet/rpc/rpc_thread.c b/libc/inet/rpc/rpc_thread.c
115 index 71303b2..3367659 100644
116 --- a/libc/inet/rpc/rpc_thread.c
117 +++ b/libc/inet/rpc/rpc_thread.c
118 @@ -32,7 +32,6 @@ __rpc_thread_destroy (void)
119                 __rpc_thread_svc_cleanup ();
120                 __rpc_thread_clnt_cleanup ();
121                 /*__rpc_thread_key_cleanup (); */
122 -               free (tvp->authnone_private_s);
123                 free (tvp->clnt_perr_buf_s);
124                 free (tvp->clntraw_private_s);
125                 free (tvp->svcraw_private_s);
126 -- 
127 1.7.10.4
128