Commit befcff9b authored by unknown's avatar unknown
Browse files

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
parent 561ee8fd
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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

+29 −1
Original line number Diff line number Diff line
@@ -711,13 +711,41 @@ dbname.sym can redirect a database directory:
	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) {
+6 −1
Original line number Diff line number Diff line
@@ -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;