Commit ae716978 authored by unknown's avatar unknown

can't use my_pread,my_pwrite since it uses mutexes on the files

parent 1ef48556
...@@ -27,6 +27,14 @@ ...@@ -27,6 +27,14 @@
#include <NdbThread.h> #include <NdbThread.h>
#include <signaldata/FsOpenReq.hpp> #include <signaldata/FsOpenReq.hpp>
// use this to test broken pread code
//#define HAVE_BROKEN_PREAD
#ifdef HAVE_BROKEN_PREAD
#undef HAVE_PWRITE
#undef HAVE_PREAD
#endif
#if defined NDB_WIN32 || defined NDB_OSE || defined NDB_SOFTOSE #if defined NDB_WIN32 || defined NDB_OSE || defined NDB_SOFTOSE
#else #else
// For readv and writev // For readv and writev
...@@ -379,9 +387,12 @@ AsyncFile::readBuffer(char * buf, size_t size, off_t offset){ ...@@ -379,9 +387,12 @@ AsyncFile::readBuffer(char * buf, size_t size, off_t offset){
if(dwSFP != offset) { if(dwSFP != offset) {
return GetLastError(); return GetLastError();
} }
#elif defined NDB_OSE || defined NDB_SOFTOSE #elif ! defined(HAVE_PREAD)
return_value = lseek(theFd, offset, SEEK_SET); off_t seek_val;
if (return_value != offset) { while((seek_val= lseek(theFd, offset, SEEK_SET)) == (off_t)-1
&& errno == EINTR);
if(seek_val == (off_t)-1)
{
return errno; return errno;
} }
#endif #endif
...@@ -400,10 +411,10 @@ AsyncFile::readBuffer(char * buf, size_t size, off_t offset){ ...@@ -400,10 +411,10 @@ AsyncFile::readBuffer(char * buf, size_t size, off_t offset){
return GetLastError(); return GetLastError();
} }
bytes_read = dwBytesRead; bytes_read = dwBytesRead;
#elif defined NDB_OSE || defined NDB_SOFTOSE #elif ! defined(HAVE_PREAD)
return_value = ::read(theFd, buf, size); return_value = ::read(theFd, buf, size);
#else // UNIX #else // UNIX
return_value = my_pread(theFd, buf, size, offset,0); return_value = ::pread(theFd, buf, size, offset);
#endif #endif
#ifndef NDB_WIN32 #ifndef NDB_WIN32
if (return_value == -1 && errno == EINTR) { if (return_value == -1 && errno == EINTR) {
...@@ -453,7 +464,7 @@ AsyncFile::readReq( Request * request) ...@@ -453,7 +464,7 @@ AsyncFile::readReq( Request * request)
void void
AsyncFile::readvReq( Request * request) AsyncFile::readvReq( Request * request)
{ {
#if defined NDB_OSE || defined NDB_SOFTOSE #if ! defined(HAVE_PREAD)
readReq(request); readReq(request);
return; return;
#elif defined NDB_WIN32 #elif defined NDB_WIN32
...@@ -483,7 +494,7 @@ AsyncFile::readvReq( Request * request) ...@@ -483,7 +494,7 @@ AsyncFile::readvReq( Request * request)
int int
AsyncFile::extendfile(Request* request) { AsyncFile::extendfile(Request* request) {
#if defined NDB_OSE || defined NDB_SOFTOSE #if ! defined(HAVE_PWRITE)
// Find max size of this file in this request // Find max size of this file in this request
int maxOffset = 0; int maxOffset = 0;
int maxSize = 0; int maxSize = 0;
...@@ -592,28 +603,14 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset, ...@@ -592,28 +603,14 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset,
if(dwSFP != offset) { if(dwSFP != offset) {
return GetLastError(); return GetLastError();
} }
#elif defined NDB_OSE || defined NDB_SOFTOSE #elif ! defined(HAVE_PWRITE)
return_value = lseek(theFd, offset, SEEK_SET); off_t seek_val;
if (return_value != offset) { while((seek_val= lseek(theFd, offset, SEEK_SET)) == (off_t)-1
DEBUG(ndbout_c("AsyncFile::writeReq, err1: return_value=%d, offset=%d\n", && errno == EINTR);
return_value, chunk_offset)); if(seek_val == (off_t)-1)
PRINT_ERRORANDFLAGS(0); {
if (errno == 78) {
// Could not write beyond end of file, try to extend file
DEBUG(ndbout_c("AsyncFile::writeReq, Extend. file! filename=\"%s\" \n",
theFileName.c_str()));
return_value = extendfile(request);
if (return_value == -1) {
return errno;
}
return_value = lseek(theFd, offset, SEEK_SET);
if (return_value != offset) {
return errno; return errno;
} }
} else {
return errno;
}
}
#endif #endif
while (size > 0) { while (size > 0) {
...@@ -634,10 +631,10 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset, ...@@ -634,10 +631,10 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset,
DEBUG(ndbout_c("Warning partial write %d != %d", bytes_written, bytes_to_write)); DEBUG(ndbout_c("Warning partial write %d != %d", bytes_written, bytes_to_write));
} }
#elif defined NDB_OSE || defined NDB_SOFTOSE #elif ! defined(HAVE_PWRITE)
return_value = ::write(theFd, buf, bytes_to_write); return_value = ::write(theFd, buf, bytes_to_write);
#else // UNIX #else // UNIX
return_value = my_pwrite(theFd, buf, bytes_to_write, offset, 0); return_value = ::pwrite(theFd, buf, bytes_to_write, offset);
#endif #endif
#ifndef NDB_WIN32 #ifndef NDB_WIN32
if (return_value == -1 && errno == EINTR) { if (return_value == -1 && errno == EINTR) {
......
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