summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2004-12-01 18:02:34 +0200
committerunknown <heikki@hundin.mysql.fi>2004-12-01 18:02:34 +0200
commit62446e4c1805392168e3d152dd7baabc1af8163e (patch)
treeb8c0c43ac6f20d5c71990bc3ce8fa2598bf09525
parentb72c899e65375c42f9d3943c8b0229dd15da8e63 (diff)
downloadmariadb-git-62446e4c1805392168e3d152dd7baabc1af8163e.tar.gz
configure.in:
Let MySQL check the existence of readdir_r with 3 arguments; Solaris seems to have just 2 args Check the existence of readdir_r and localtime_r; even though MySQL does check these too, we need our own check for Hot Backup code os0file.c: Use re-entrant readdir_r where available ut0ut.c: Make a function to use thread-safe localtime_r where available; that particular function was not called from anywhere, though innobase/ut/ut0ut.c: Make a function to use thread-safe localtime_r where available; the function was not called from anywhere, though innobase/os/os0file.c: Use re-entrant readdir_r where available innobase/configure.in: Let MySQL check the existence of readdir_r with 3 arguments; Solaris seems to have just 2 args
-rw-r--r--innobase/configure.in4
-rw-r--r--innobase/os/os0file.c30
-rw-r--r--innobase/ut/ut0ut.c7
3 files changed, 38 insertions, 3 deletions
diff --git a/innobase/configure.in b/innobase/configure.in
index d83da9fdc5c..baf11272ab9 100644
--- a/innobase/configure.in
+++ b/innobase/configure.in
@@ -41,7 +41,9 @@ AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(void*, 4)
AC_CHECK_FUNCS(sched_yield)
AC_CHECK_FUNCS(fdatasync)
-#AC_CHECK_FUNCS(localtime_r) # Already checked by MySQL
+AC_CHECK_FUNCS(localtime_r)
+#AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
+# Some versions of Unix only take 2 arguments.
#AC_C_INLINE Already checked in MySQL
AC_C_BIGENDIAN
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 5c140e4b798..8b9a0582781 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -711,13 +711,41 @@ http://www.mysql.com/doc/en/Windows_symbolic_links.html */
char* full_path;
int ret;
struct stat statinfo;
+#ifdef HAVE_READDIR_R
+ char dirent_buf[sizeof(struct dirent) + _POSIX_PATH_MAX +
+ 100];
+ /* In /mysys/my_lib.c, _POSIX_PATH_MAX + 1 is used as
+ the max file name len; but in most standards, the
+ length is NAME_MAX; we add 100 to be even safer */
+#endif
+
next_file:
- ent = readdir(dir);
+
+#ifdef HAVE_READDIR_R
+ ret = readdir_r(dir, (struct dirent*)dirent_buf, &ent);
+
+ if (ret != 0) {
+ fprintf(stderr,
+"InnoDB: cannot read directory %s, error %lu\n", dirname, (ulong)ret);
+
+ return(-1);
+ }
if (ent == NULL) {
+ /* End of directory */
+
return(1);
}
+ ut_a(strlen(ent->d_name) < _POSIX_PATH_MAX + 100 - 1);
+#else
+ ent = readdir(dir);
+
+ if (ent == NULL) {
+
+ return(1);
+ }
+#endif
ut_a(strlen(ent->d_name) < OS_FILE_MAX_PATH);
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) {
diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c
index b67be77b29e..732380bcb1f 100644
--- a/innobase/ut/ut0ut.c
+++ b/innobase/ut/ut0ut.c
@@ -235,13 +235,18 @@ ut_get_year_month_day(
*month = (ulint)cal_tm.wMonth;
*day = (ulint)cal_tm.wDay;
#else
+ struct tm cal_tm;
struct tm* cal_tm_ptr;
time_t tm;
time(&tm);
+#ifdef HAVE_LOCALTIME_R
+ localtime_r(&tm, &cal_tm);
+ cal_tm_ptr = &cal_tm;
+#else
cal_tm_ptr = localtime(&tm);
-
+#endif
*year = (ulint)cal_tm_ptr->tm_year + 1900;
*month = (ulint)cal_tm_ptr->tm_mon + 1;
*day = (ulint)cal_tm_ptr->tm_mday;