]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: threads/time: Many global variables from time.h are now thread-local
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 11 May 2017 09:00:15 +0000 (11:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 12:58:30 +0000 (13:58 +0100)
include/common/time.h
src/time.c

index 8be47188a697509582e63733ff4cdc12db64636e..f3dd3ba1d8f76a65041760fc773ca9fdaf7f24f0 100644 (file)
 #define MINTIME(old, new)      (((new)<0)?(old):(((old)<0||(new)<(old))?(new):(old)))
 #define SETNOW(a)              (*a=now)
 
-extern unsigned int   curr_sec_ms;      /* millisecond of current second (0..999) */
-extern unsigned int   ms_left_scaled;   /* milliseconds left for current second (0..2^32-1) */
-extern unsigned int   curr_sec_ms_scaled;  /* millisecond of current second (0..2^32-1) */
-extern unsigned int   now_ms;           /* internal date in milliseconds (may wrap) */
-extern unsigned int   samp_time;        /* total elapsed time over current sample */
-extern unsigned int   idle_time;        /* total idle time over current sample */
-extern unsigned int   idle_pct;         /* idle to total ratio over last sample (percent) */
-extern struct timeval now;              /* internal date is a monotonic function of real clock */
-extern struct timeval date;             /* the real current date */
+extern THREAD_LOCAL unsigned int   curr_sec_ms;      /* millisecond of current second (0..999) */
+extern THREAD_LOCAL unsigned int   ms_left_scaled;   /* milliseconds left for current second (0..2^32-1) */
+extern THREAD_LOCAL unsigned int   curr_sec_ms_scaled;  /* millisecond of current second (0..2^32-1) */
+extern THREAD_LOCAL unsigned int   now_ms;           /* internal date in milliseconds (may wrap) */
+extern THREAD_LOCAL unsigned int   samp_time;        /* total elapsed time over current sample */
+extern THREAD_LOCAL unsigned int   idle_time;        /* total idle time over current sample */
+extern THREAD_LOCAL unsigned int   idle_pct;         /* idle to total ratio over last sample (percent) */
+extern THREAD_LOCAL struct timeval now;              /* internal date is a monotonic function of real clock */
+extern THREAD_LOCAL struct timeval date;             /* the real current date */
 extern struct timeval start_date;       /* the process's start date */
-extern struct timeval before_poll;      /* system date before calling poll() */
-extern struct timeval after_poll;       /* system date after leaving poll() */
+extern THREAD_LOCAL struct timeval before_poll;      /* system date before calling poll() */
+extern THREAD_LOCAL struct timeval after_poll;       /* system date after leaving poll() */
 
 
 /**** exported functions *************************************************/
index a63968ad40c9b6e935df5171d83b8303632007d7..188ccf5b12416b139ab05e13ea91346cb8306f4a 100644 (file)
 #include <common/standard.h>
 #include <common/time.h>
 
-unsigned int   ms_left_scaled;  /* milliseconds left for current second (0..2^32-1) */
-unsigned int   now_ms;          /* internal date in milliseconds (may wrap) */
-unsigned int   samp_time;       /* total elapsed time over current sample */
-unsigned int   idle_time;       /* total idle time over current sample */
-unsigned int   idle_pct;        /* idle to total ratio over last sample (percent) */
-struct timeval now;             /* internal date is a monotonic function of real clock */
-struct timeval date;            /* the real current date */
+THREAD_LOCAL unsigned int   ms_left_scaled;  /* milliseconds left for current second (0..2^32-1) */
+THREAD_LOCAL unsigned int   now_ms;          /* internal date in milliseconds (may wrap) */
+THREAD_LOCAL unsigned int   samp_time;       /* total elapsed time over current sample */
+THREAD_LOCAL unsigned int   idle_time;       /* total idle time over current sample */
+THREAD_LOCAL unsigned int   idle_pct;        /* idle to total ratio over last sample (percent) */
+THREAD_LOCAL struct timeval now;             /* internal date is a monotonic function of real clock */
+THREAD_LOCAL struct timeval date;            /* the real current date */
 struct timeval start_date;      /* the process's start date */
-struct timeval before_poll;     /* system date before calling poll() */
-struct timeval after_poll;      /* system date after leaving poll() */
+THREAD_LOCAL struct timeval before_poll;     /* system date before calling poll() */
+THREAD_LOCAL struct timeval after_poll;      /* system date after leaving poll() */
 
 /*
  * adds <ms> ms to <from>, set the result to <tv> and returns a pointer <tv>