Skip to content

Commit f270cbd

Browse files
author
Venkatesh Duggirala
committed
Bug #18808072 MYSQLBINLOG USES LOCALTIME() TO PRINT EVENTS,
CAUSES KERNEL MUTEX CONTENTION Merging fix from mysql-5.5
2 parents 5ac6c4b + a3cc647 commit f270cbd

File tree

5 files changed

+21
-37
lines changed

5 files changed

+21
-37
lines changed

client/mysqlbinlog.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -2917,16 +2917,17 @@ int main(int argc, char** argv)
29172917
DBUG_PROCESS(argv[0]);
29182918

29192919
my_init_time(); // for time functions
2920-
/*
2920+
tzset(); // set tzname
2921+
/*
29212922
A pointer of type Log_event can point to
29222923
INTVAR
29232924
USER_VAR
29242925
RANDOM
2925-
events, when we allocate a element of sizeof(Log_event*)
2926+
events, when we allocate a element of sizeof(Log_event*)
29262927
for the DYNAMIC_ARRAY.
29272928
*/
29282929

2929-
if((my_init_dynamic_array(&buff_ev, sizeof(buff_event_info),
2930+
if((my_init_dynamic_array(&buff_ev, sizeof(buff_event_info),
29302931
INTVAR_DYNAMIC_INIT, INTVAR_DYNAMIC_INCR)))
29312932
exit(1);
29322933

cmake/os/WindowsCache.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -88,7 +88,7 @@ SET(HAVE_GETRLIMIT CACHE INTERNAL "")
8888
SET(HAVE_GETRUSAGE CACHE INTERNAL "")
8989
SET(HAVE_GETTIMEOFDAY CACHE INTERNAL "")
9090
SET(HAVE_GETWD CACHE INTERNAL "")
91-
SET(HAVE_GMTIME_R CACHE INTERNAL "")
91+
SET(HAVE_GMTIME_R 1 CACHE INTERNAL "")
9292
SET(HAVE_GRP_H CACHE INTERNAL "")
9393
SET(HAVE_IA64INTRIN_H CACHE INTERNAL "")
9494
SET(HAVE_IEEEFP_H CACHE INTERNAL "")
@@ -111,7 +111,7 @@ SET(HAVE_LANGINFO_H CACHE INTERNAL "")
111111
SET(HAVE_LDIV 1 CACHE INTERNAL "")
112112
SET(HAVE_LIMITS_H 1 CACHE INTERNAL "")
113113
SET(HAVE_LOCALE_H 1 CACHE INTERNAL "")
114-
SET(HAVE_LOCALTIME_R CACHE INTERNAL "")
114+
SET(HAVE_LOCALTIME_R 1 CACHE INTERNAL "")
115115
SET(HAVE_LOG2 CACHE INTERNAL "")
116116
SET(HAVE_LONGJMP 1 CACHE INTERNAL "")
117117
SET(HAVE_LRAND48 CACHE INTERNAL "")

include/my_pthread.h

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -144,8 +144,18 @@ int pthread_attr_init(pthread_attr_t *connect_att);
144144
int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
145145
int pthread_attr_destroy(pthread_attr_t *connect_att);
146146
int my_pthread_once(my_pthread_once_t *once_control,void (*init_routine)(void));
147-
struct tm *localtime_r(const time_t *timep,struct tm *tmp);
148-
struct tm *gmtime_r(const time_t *timep,struct tm *tmp);
147+
148+
static inline struct tm *localtime_r(const time_t *timep, struct tm *tmp)
149+
{
150+
localtime_s(tmp, timep);
151+
return tmp;
152+
}
153+
154+
static inline struct tm *gmtime_r(const time_t *clock, struct tm *res)
155+
{
156+
gmtime_s(res, clock);
157+
return res;
158+
}
149159

150160
void pthread_exit(void *a);
151161
int pthread_join(pthread_t thread, void **value_ptr);

mysys/my_wincond.c

+1-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -344,26 +344,4 @@ int pthread_attr_destroy(pthread_attr_t *connect_att)
344344
return 0;
345345
}
346346

347-
/****************************************************************************
348-
** Fix localtime_r() to be a bit safer
349-
****************************************************************************/
350-
351-
struct tm *localtime_r(const time_t *timep,struct tm *tmp)
352-
{
353-
if (*timep == (time_t) -1) /* This will crash win32 */
354-
{
355-
memset(tmp, 0, sizeof(*tmp));
356-
}
357-
else
358-
{
359-
struct tm *res=localtime(timep);
360-
if (!res) /* Wrong date */
361-
{
362-
memset(tmp, 0, sizeof(*tmp)); /* Keep things safe */
363-
return 0;
364-
}
365-
*tmp= *res;
366-
}
367-
return tmp;
368-
}
369347
#endif /* __WIN__ */

sql/log_event.cc

-5
Original file line numberDiff line numberDiff line change
@@ -2591,13 +2591,8 @@ void Log_event::print_timestamp(IO_CACHE* file, time_t *ts)
25912591
*/
25922592
time_t ts_tmp= ts ? *ts : (ulong)when.tv_sec;
25932593
DBUG_ENTER("Log_event::print_timestamp");
2594-
#ifdef MYSQL_SERVER // This is always false
25952594
struct tm tm_tmp;
25962595
localtime_r(&ts_tmp, (res= &tm_tmp));
2597-
#else
2598-
res= localtime(&ts_tmp);
2599-
#endif
2600-
26012596
my_b_printf(file,"%02d%02d%02d %2d:%02d:%02d",
26022597
res->tm_year % 100,
26032598
res->tm_mon+1,

0 commit comments

Comments
 (0)