diff --git a/ndb/include/logger/FileLogHandler.hpp b/ndb/include/logger/FileLogHandler.hpp index be018d10102..36a35399ac8 100644 --- a/ndb/include/logger/FileLogHandler.hpp +++ b/ndb/include/logger/FileLogHandler.hpp @@ -101,7 +101,7 @@ private: bool setMaxFiles(const BaseString &files); int m_maxNoFiles; - long m_maxFileSize; + off_t m_maxFileSize; unsigned int m_maxLogEntries; File_class* m_pLogFile; }; diff --git a/ndb/include/util/File.hpp b/ndb/include/util/File.hpp index c62a9cdeac2..b9d348683ec 100644 --- a/ndb/include/util/File.hpp +++ b/ndb/include/util/File.hpp @@ -49,7 +49,7 @@ public: * @param f a pointer to a FILE descriptor. * @return the size of the file. */ - static long size(FILE* f); + static off_t size(FILE* f); /** * Renames a file. @@ -181,7 +181,7 @@ public: * * @return the file size. */ - long size() const; + off_t size() const; /** * Returns the filename. diff --git a/ndb/include/util/Vector.hpp b/ndb/include/util/Vector.hpp index 4d4c71885b7..aeddbbb22f0 100644 --- a/ndb/include/util/Vector.hpp +++ b/ndb/include/util/Vector.hpp @@ -93,6 +93,8 @@ void Vector::push_back(const T & t){ if(m_size == m_arraySize){ T * tmp = new T [m_arraySize + m_incSize]; + if(!tmp) + abort(); for (unsigned k = 0; k < m_size; k++) tmp[k] = m_items[k]; delete[] m_items; diff --git a/ndb/src/common/logger/FileLogHandler.cpp b/ndb/src/common/logger/FileLogHandler.cpp index 015b55b7a94..a4f610777eb 100644 --- a/ndb/src/common/logger/FileLogHandler.cpp +++ b/ndb/src/common/logger/FileLogHandler.cpp @@ -124,8 +124,6 @@ FileLogHandler::writeFooter() } callCount++; - // Needed on Cello since writes to the flash disk does not happen until - // we flush and fsync. m_pLogFile->flush(); } diff --git a/ndb/src/common/util/File.cpp b/ndb/src/common/util/File.cpp index bf100944cb9..23bf3415df9 100644 --- a/ndb/src/common/util/File.cpp +++ b/ndb/src/common/util/File.cpp @@ -44,17 +44,16 @@ File_class::exists(const char* aFileName) return (my_stat(aFileName, &stmp, MYF(0))!=NULL); } -long +off_t File_class::size(FILE* f) { - long cur_pos = 0, length = 0; - - cur_pos = ::ftell(f); - ::fseek(f, 0, SEEK_END); - length = ::ftell(f); - ::fseek(f, cur_pos, SEEK_SET); // restore original position + MY_STAT s; - return length; + // Note that my_fstat behaves *differently* than my_stat. ARGGGHH! + if(my_fstat(::fileno(f), &s, MYF(0))) + return 0; + + return s.st_size; } bool @@ -179,8 +178,8 @@ File_class::writeChar(const char* buf) { return writeChar(buf, 0, ::strlen(buf)); } - -long + +off_t File_class::size() const { return File_class::size(m_file); @@ -199,10 +198,6 @@ File_class::flush() const ::fflush(m_file); return ::fsync(::fileno(m_file)); #else - return 0; + return ::fflush(m_file);; #endif } - -// -// PRIVATE -//