Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
cb78c842
Commit
cb78c842
authored
Jul 04, 2018
by
antirez
Browse files
Use nolocks_localtime() for safer logging.
parent
81778d91
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Makefile
View file @
cb78c842
...
...
@@ -144,7 +144,7 @@ endif
REDIS_SERVER_NAME
=
redis-server
REDIS_SENTINEL_NAME
=
redis-sentinel
REDIS_SERVER_OBJ
=
adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o
REDIS_SERVER_OBJ
=
adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o
localtime.o
REDIS_CLI_NAME
=
redis-cli
REDIS_CLI_OBJ
=
anet.o adlist.o dict.o redis-cli.o zmalloc.o release.o anet.o ae.o crc64.o siphash.o crc16.o
REDIS_BENCHMARK_NAME
=
redis-benchmark
...
...
src/server.c
View file @
cb78c842
...
...
@@ -326,6 +326,10 @@ struct redisCommand redisCommandTable[] = {
/*============================ Utility functions ============================ */
/* We use a private localtime implementation which is fork-safe. The logging
* function of Redis may be called from other threads. */
void
nolocks_localtime
(
struct
tm
*
tmp
,
time_t
t
,
time_t
tz
,
int
dst
);
/* Low level logging. To use only for very big messages, otherwise
* serverLog() is to prefer. */
void
serverLogRaw
(
int
level
,
const
char
*
msg
)
{
...
...
@@ -351,7 +355,9 @@ void serverLogRaw(int level, const char *msg) {
pid_t
pid
=
getpid
();
gettimeofday
(
&
tv
,
NULL
);
off
=
strftime
(
buf
,
sizeof
(
buf
),
"%d %b %H:%M:%S."
,
localtime
(
&
tv
.
tv_sec
));
struct
tm
tm
;
nolocks_localtime
(
&
tm
,
tv
.
tv_sec
,
server
.
timezone
,
server
.
daylight_active
);
off
=
strftime
(
buf
,
sizeof
(
buf
),
"%d %b %H:%M:%S."
,
&
tm
);
snprintf
(
buf
+
off
,
sizeof
(
buf
)
-
off
,
"%03d"
,(
int
)
tv
.
tv_usec
/
1000
);
if
(
server
.
sentinel_mode
)
{
role_char
=
'X'
;
/* Sentinel. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment