Skip to content

Commit

Permalink
Merge pull request redis#5489 from devnexen/unstable
Browse files Browse the repository at this point in the history
Fix non Linux build.
  • Loading branch information
antirez authored Oct 29, 2018
2 parents b8febe6 + ae3bfe5 commit f1408b1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ void initServerConfig(void) {
server.runid[CONFIG_RUN_ID_SIZE] = '\0';
changeReplicationId();
clearReplicationId2();
server.timezone = timezone; /* Initialized by tzset(). */
server.timezone = getTimeZone(); /* Initialized by tzset(). */
server.configfile = NULL;
server.executable = NULL;
server.config_hz = CONFIG_DEFAULT_HZ;
Expand Down
19 changes: 19 additions & 0 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <float.h>
#include <stdint.h>
#include <errno.h>
#include <time.h>

#include "util.h"
#include "sha1.h"
Expand Down Expand Up @@ -652,6 +653,24 @@ sds getAbsolutePath(char *filename) {
return abspath;
}

/*
* Gets the proper timezone in a more portable fashion
* i.e timezone variables are linux specific.
*/

unsigned long getTimeZone(void) {
#ifdef __linux__
return timezone;
#else
struct timeval tv;
struct timezone tz;

gettimeofday(&tv, &tz);

return tz.tz_minuteswest * 60UL;
#endif
}

/* Return true if the specified path is just a file basename without any
* relative or absolute path. This function just checks that no / or \
* character exists inside the specified path, that's enough in the
Expand Down
1 change: 1 addition & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ int string2ld(const char *s, size_t slen, long double *dp);
int d2string(char *buf, size_t len, double value);
int ld2string(char *buf, size_t len, long double value, int humanfriendly);
sds getAbsolutePath(char *filename);
unsigned long getTimeZone(void);
int pathIsBaseName(char *path);

#ifdef REDIS_TEST
Expand Down

0 comments on commit f1408b1

Please sign in to comment.