Commit 4faf77a9 authored by unknown's avatar unknown

BUG#8208 don't fsync unless something has been written

+ ion shutdown - don't close files that are not open
+ abort in debug - if closing a fd == -1


BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
parent f5729e2c
...@@ -224,6 +224,7 @@ tonu@x153.internalnet ...@@ -224,6 +224,7 @@ tonu@x153.internalnet
tonu@x3.internalnet tonu@x3.internalnet
tsmith@build.mysql.com tsmith@build.mysql.com
tulin@build.mysql.com tulin@build.mysql.com
tulin@mysql.com
ulli@morbus.(none) ulli@morbus.(none)
venu@hundin.mysql.fi venu@hundin.mysql.fi
venu@myvenu.com venu@myvenu.com
......
...@@ -219,7 +219,8 @@ AsyncFile::run() ...@@ -219,7 +219,8 @@ AsyncFile::run()
rmrfReq(request, (char*)theFileName.c_str(), request->par.rmrf.own_directory); rmrfReq(request, (char*)theFileName.c_str(), request->par.rmrf.own_directory);
break; break;
case Request:: end: case Request:: end:
closeReq(request); if (theFd > 0)
closeReq(request);
endReq(); endReq();
return; return;
default: default:
...@@ -239,6 +240,7 @@ void AsyncFile::openReq(Request* request) ...@@ -239,6 +240,7 @@ void AsyncFile::openReq(Request* request)
{ {
m_openedWithSync = false; m_openedWithSync = false;
m_syncFrequency = 0; m_syncFrequency = 0;
m_syncCount= 0;
// for open.flags, see signal FSOPENREQ // for open.flags, see signal FSOPENREQ
#ifdef NDB_WIN32 #ifdef NDB_WIN32
...@@ -329,7 +331,6 @@ void AsyncFile::openReq(Request* request) ...@@ -329,7 +331,6 @@ void AsyncFile::openReq(Request* request)
} else { } else {
#endif #endif
m_openedWithSync = false; m_openedWithSync = false;
m_syncCount = 0;
m_syncFrequency = Global_syncFreq; m_syncFrequency = Global_syncFreq;
#if 0 #if 0
} }
...@@ -656,6 +657,7 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset, ...@@ -656,6 +657,7 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset,
} }
#endif #endif
m_syncCount+= bytes_written;
buf += bytes_written; buf += bytes_written;
size -= bytes_written; size -= bytes_written;
offset += bytes_written; offset += bytes_written;
...@@ -682,6 +684,10 @@ AsyncFile::closeReq(Request * request) ...@@ -682,6 +684,10 @@ AsyncFile::closeReq(Request * request)
hFile = INVALID_HANDLE_VALUE; hFile = INVALID_HANDLE_VALUE;
#else #else
if (-1 == ::close(theFd)) { if (-1 == ::close(theFd)) {
#ifndef DBUG_OFF
if (theFd == -1)
abort();
#endif
request->error = errno; request->error = errno;
} }
theFd = -1; theFd = -1;
...@@ -700,7 +706,8 @@ bool AsyncFile::isOpen(){ ...@@ -700,7 +706,8 @@ bool AsyncFile::isOpen(){
void void
AsyncFile::syncReq(Request * request) AsyncFile::syncReq(Request * request)
{ {
if(m_openedWithSync){ if(m_openedWithSync ||
m_syncCount == 0){
return; return;
} }
#ifdef NDB_WIN32 #ifdef NDB_WIN32
...@@ -756,7 +763,6 @@ AsyncFile::appendReq(Request * request){ ...@@ -756,7 +763,6 @@ AsyncFile::appendReq(Request * request){
if(m_syncFrequency != 0 && m_syncCount > m_syncFrequency){ if(m_syncFrequency != 0 && m_syncCount > m_syncFrequency){
syncReq(request); syncReq(request);
request->error = 0;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment