From 1bc04c766432a9180cb011f7ca5390fc77789223 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Sun, 29 Oct 2017 20:14:08 +0100 Subject: [PATCH] BUG/MINOR: threads: Add missing THREAD_LOCAL on static here and there --- src/checks.c | 2 +- src/cli.c | 2 +- src/proto_http.c | 2 +- src/proto_tcp.c | 10 +++++----- src/raw_sock.c | 2 +- src/standard.c | 6 +++--- src/stats.c | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/checks.c b/src/checks.c index 8411fefae..c9e655dbe 100644 --- a/src/checks.c +++ b/src/checks.c @@ -2380,7 +2380,7 @@ static int start_checks() */ static int httpchk_expect(struct server *s, int done) { - static char status_msg[] = "HTTP status check returned code <000>"; + static THREAD_LOCAL char status_msg[] = "HTTP status check returned code <000>"; char status_code[] = "000"; char *contentptr; int crlf; diff --git a/src/cli.c b/src/cli.c index 97e3086e6..9ca8e1fcf 100644 --- a/src/cli.c +++ b/src/cli.c @@ -81,7 +81,7 @@ static const char stats_permission_denied_msg[] = ""; -static char *dynamic_usage_msg = NULL; +static THREAD_LOCAL char *dynamic_usage_msg = NULL; /* List head of cli keywords */ static struct cli_kw_list cli_keywords = { diff --git a/src/proto_http.c b/src/proto_http.c index 390de89ec..ca9918896 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -267,7 +267,7 @@ struct action_kw_list http_res_keywords = { struct chunk http_err_chunks[HTTP_ERR_SIZE]; /* this struct is used between calls to smp_fetch_hdr() or smp_fetch_cookie() */ -static struct hdr_ctx static_hdr_ctx; +static THREAD_LOCAL struct hdr_ctx static_hdr_ctx; #define FD_SETS_ARE_BITFIELDS #ifdef FD_SETS_ARE_BITFIELDS diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 200f642cc..d5345ee3c 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -116,8 +116,8 @@ static struct protocol proto_tcpv6 = { /* Default TCP parameters, got by opening a temporary TCP socket. */ #ifdef TCP_MAXSEG -static int default_tcp_maxseg = -1; -static int default_tcp6_maxseg = -1; +static THREAD_LOCAL int default_tcp_maxseg = -1; +static THREAD_LOCAL int default_tcp6_maxseg = -1; #endif /* Binds ipv4/ipv6 address to socket , unless is set, in which @@ -138,8 +138,8 @@ int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct so struct sockaddr_storage bind_addr; int foreign_ok = 0; int ret; - static int ip_transp_working = 1; - static int ip6_transp_working = 1; + static THREAD_LOCAL int ip_transp_working = 1; + static THREAD_LOCAL int ip6_transp_working = 1; switch (local->ss_family) { case AF_INET: @@ -433,7 +433,7 @@ int tcp_connect_server(struct connection *conn, int data, int delack) } else { #ifdef IP_BIND_ADDRESS_NO_PORT - static int bind_address_no_port = 1; + static THREAD_LOCAL int bind_address_no_port = 1; setsockopt(fd, SOL_IP, IP_BIND_ADDRESS_NO_PORT, (const void *) &bind_address_no_port, sizeof(int)); #endif ret = tcp_bind_socket(fd, flags, &src->source_addr, &conn->addr.from); diff --git a/src/raw_sock.c b/src/raw_sock.c index 5bef5f797..ad0210105 100644 --- a/src/raw_sock.c +++ b/src/raw_sock.c @@ -69,7 +69,7 @@ int raw_sock_to_pipe(struct connection *conn, struct pipe *pipe, unsigned int count) { #ifndef ASSUME_SPLICE_WORKS - static int splice_detects_close; + static THREAD_LOCAL int splice_detects_close; #endif int ret; int retval = 0; diff --git a/src/standard.c b/src/standard.c index 77641b427..34d4148d4 100644 --- a/src/standard.c +++ b/src/standard.c @@ -837,7 +837,7 @@ struct sockaddr_storage *str2ip2(const char *str, struct sockaddr_storage *sa, i */ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int *high, char **err, const char *pfx, char **fqdn, int resolve) { - static struct sockaddr_storage ss; + static THREAD_LOCAL struct sockaddr_storage ss; struct sockaddr_storage *ret = NULL; char *back, *str2; char *port1, *port2; @@ -2493,7 +2493,7 @@ int buf2ip6(const char *buf, size_t len, struct in6_addr *dst) */ const char *quote_arg(const char *ptr) { - static char val[32]; + static THREAD_LOCAL char val[32]; int i; if (!ptr || !*ptr) @@ -2764,7 +2764,7 @@ static int my_tm_diff(const struct tm *a, const struct tm *b) const char *get_gmt_offset(time_t t, struct tm *tm) { /* Cache offsets from GMT (depending on whether DST is active or not) */ - static char gmt_offsets[2][5+1] = { "", "" }; + static THREAD_LOCAL char gmt_offsets[2][5+1] = { "", "" }; char *gmt_offset; struct tm tm_gmt; diff --git a/src/stats.c b/src/stats.c index f68831933..1e4d6ffa4 100644 --- a/src/stats.c +++ b/src/stats.c @@ -218,9 +218,9 @@ const char *stat_field_names[ST_F_TOTAL_FIELDS] = { }; /* one line of info */ -static struct field info[INF_TOTAL_FIELDS]; +static THREAD_LOCAL struct field info[INF_TOTAL_FIELDS]; /* one line of stats */ -static struct field stats[ST_F_TOTAL_FIELDS]; +static THREAD_LOCAL struct field stats[ST_F_TOTAL_FIELDS];