summaryrefslogtreecommitdiff
path: root/include/my_sys.h
diff options
context:
space:
mode:
authorDavi Arnaut <davi.arnaut@oracle.com>2011-01-07 16:33:36 -0200
committerDavi Arnaut <davi.arnaut@oracle.com>2011-01-07 16:33:36 -0200
commit82dade88f04fe59290a7a9da305384e731eb8b6a (patch)
treeba6cafa745b463dda5c02cec1d1fdeacc9953310 /include/my_sys.h
parentd8e7d060cc1bc1ab4bb5fa6d249d5f49cbf976f6 (diff)
downloadmariadb-git-82dade88f04fe59290a7a9da305384e731eb8b6a.tar.gz
Bug#51023: Mysql server crashes on SIGHUP and destroys InnoDB files
From a user perspective, the problem is that a FLUSH LOGS or SIGHUP signal could end up associating the stdout and stderr to random files. In the case of this bug report, the streams would end up associated to InnoDB ibd files. The freopen(3) function is not thread-safe on FreeBSD. What this means is that if another thread calls open(2) during freopen() is executing that another thread's fd returned by open(2) may get re-associated with the file being passed to freopen(3). See FreeBSD PR number 79887 for reference: http://www.freebsd.org/cgi/query-pr.cgi?pr=79887 This problem is worked around by substituting a internal hook within the FILE structure. This avoids the loss of atomicity by not having the original fd closed before its duplicated. Patch based on the original work by Vasil Dimov. include/my_sys.h: Export my_freopen. mysys/my_fopen.c: Add a my_freopen abstraction to workaround bugs in specific OSes. Add a prototype for getosreldate() as older FreeBSD versions did not define one. sql/log.cc: Move freopen abstraction code over to mysys. The streams are now only reopened for writing.
Diffstat (limited to 'include/my_sys.h')
-rw-r--r--include/my_sys.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/my_sys.h b/include/my_sys.h
index 90fd78f77ba..0ac220cec31 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -664,6 +664,7 @@ extern void init_glob_errs(void);
extern void wait_for_free_space(const char *filename, int errors);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
+extern FILE *my_freopen(const char *path, const char *mode, FILE *stream);
extern int my_fclose(FILE *fd,myf MyFlags);
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
extern int my_sync(File fd, myf my_flags);