diff options
author | unknown <kaa@kaamos.(none)> | 2008-03-03 17:34:43 +0300 |
---|---|---|
committer | unknown <kaa@kaamos.(none)> | 2008-03-03 17:34:43 +0300 |
commit | ca753c3a75c1094ca7765243792b5c9b94e6da88 (patch) | |
tree | 1caa0ffe1bc856d0fdddbc2d7d778326ff96be03 /mysys/my_create.c | |
parent | ed6f54dabc787eb0461e701d8faf77ca58d2efe4 (diff) | |
parent | 162eadbe68d6029522b23ab57c84a0b64f6699a9 (diff) | |
download | mariadb-git-ca753c3a75c1094ca7765243792b5c9b94e6da88.tar.gz |
Merge kaamos.(none):/data/src/opt/bug31781/my50
into kaamos.(none):/data/src/opt/bug31781/my51
mysys/my_create.c:
Auto merged
Diffstat (limited to 'mysys/my_create.c')
-rw-r--r-- | mysys/my_create.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/mysys/my_create.c b/mysys/my_create.c index 55878318ead..0a40e245de0 100644 --- a/mysys/my_create.c +++ b/mysys/my_create.c @@ -34,7 +34,7 @@ File my_create(const char *FileName, int CreateFlags, int access_flags, myf MyFlags) { - int fd; + int fd, rc; DBUG_ENTER("my_create"); DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d", FileName, CreateFlags, access_flags, MyFlags)); @@ -52,6 +52,20 @@ File my_create(const char *FileName, int CreateFlags, int access_flags, fd = open(FileName, access_flags); #endif - DBUG_RETURN(my_register_filename(fd, FileName, FILE_BY_CREATE, - EE_CANTCREATEFILE, MyFlags)); + rc= my_register_filename(fd, FileName, FILE_BY_CREATE, + EE_CANTCREATEFILE, MyFlags); + /* + my_register_filename() may fail on some platforms even if the call to + *open() above succeeds. In this case, don't leave the stale file because + callers assume the file to not exist if my_create() fails, so they don't + do any cleanups. + */ + if (unlikely(fd >= 0 && rc < 0)) + { + int tmp= my_errno; + my_delete(FileName, MyFlags); + my_errno= tmp; + } + + DBUG_RETURN(rc); } /* my_create */ |