1 #define __STDC_LIMIT_MACROS 1
21 return tm.tv_sec * 1e9 + tm.tv_nsec;
24 if (gettimeofday(&tm, 0) == 0)
25 return tm.tv_sec * 1e9 + tm.tv_usec * 1e3;
54 {
open (name, flags, perms); }
70 <<
"Destructor called on RFIO file '" <<
m_name
71 <<
"' but the file is still open";
137 if ((name == 0) || (*name == 0)) {
139 ex <<
"Cannot open a file without a name";
145 ex <<
"Must open file '" << name <<
"' at least for read or write";
150 if (lname.find (
"//") == 0)
162 else if (flags & IOFlags::OpenRead)
163 openflags |= O_RDONLY;
164 else if (flags & IOFlags::OpenWrite)
165 openflags |= O_WRONLY;
171 openflags |= O_APPEND;
174 openflags |= O_CREAT;
180 openflags |= O_TRUNC;
183 if ((newfd =
rfio_open64 (lname.c_str(), openflags, perms)) == -1) {
185 ex <<
"rfio_open(name='" << lname
186 <<
"', flags=0x" << std::hex << openflags
187 <<
", permissions=0" << std::oct << perms <<
std::dec
206 <<
"RFIOFile::close(name='" <<
m_name
207 <<
"') called but the file is not open";
217 <<
"rfio_close64(name='" <<
m_name
226 <<
"RFIOFile::close(): system level close after a failed"
227 <<
" rfio_close64 also failed with error '" << strerror (errno)
228 <<
"' (error code " << errno <<
")";
231 <<
"RFIOFile::close(): system level close after a failed"
232 <<
" rfio_close64 succeeded";
277 if ((s == -1 &&
serrno == 1004) || (s > ssize_t (n)))
280 const char *sleepTimeMsg;
281 int secondsToSleep = 5;
285 sleepTimeMsg =
"10 minutes";
286 secondsToSleep = 600;
290 sleepTimeMsg =
"5 minutes";
291 secondsToSleep = 300;
295 sleepTimeMsg =
"1 minute";
300 <<
"RFIOFile retrying read\n"
301 <<
" return value from rfio_read64 = " << s <<
" (normally this is bytes read, -1 for error)\n"
302 <<
" bytes requested = " << n <<
" (this and bytes read are equal unless error or EOF)\n"
303 <<
" rfio error message = " <<
rfio_serror() <<
" (explanation from server, if possible)\n"
304 <<
" serrno = " <<
serrno <<
" (rfio server error code, 0 = OK, 1004 = timeout, ...)\n"
305 <<
" rfio_errno = " <<
rfio_errno <<
" (rfio error from actually accessing the file)\n"
306 <<
" current position = " <<
m_curpos <<
" (in bytes, beginning of file is 0)\n"
307 <<
" retries left before quitting = " << maxRetry <<
"\n"
308 <<
" will close and reopen file " <<
m_name <<
"\n"
309 <<
" will sleep for " << sleepTimeMsg <<
" before attempting retry";
311 sleep(secondsToSleep);
320 }
while (--maxRetry > 0);
331 LogDebug(
"RFIOFileDebug") <<
"Entering RFIOFile read()";
338 ex <<
"rfio_read(name='" <<
m_name <<
"', n=" << n <<
") failed"
348 <<
"Exiting RFIOFile read(), elapsed time = " << end - start
349 <<
" ns, bytes read = " << s <<
", file position = " <<
m_curpos;
369 ex <<
"rfio_write(name='" <<
m_name <<
"', n=" << n <<
") failed"
386 ex <<
"RFIOFile::position() called on a closed file";
391 ex <<
"RFIOFile::position() called with incorrect 'whence' parameter";
395 int mywhence = (whence ==
SET ? SEEK_SET
402 ex <<
"rfio_lseek(name='" <<
m_name <<
"', offset=" << offset
403 <<
", whence=" << mywhence <<
") failed at position "
406 ex.
addContext(
"Calling RFIOFile::position()");
417 ex <<
"RFIOFile::resize(name='" <<
m_name <<
"') not implemented";
virtual IOSize write(const void *from, IOSize n)
tuple start
Check for commandline option errors.
int rfio_write64(int s, const void *ptr, int size)
virtual IOSize readv(IOPosBuffer *into, IOSize buffers)
std::vector< Variable::Flags > flags
virtual IOSize readv(IOPosBuffer *into, IOSize buffers)
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
int rfiosetopt(int opt, int *pval, int len)
int rfio_read64(int s, void *ptr, int size)
virtual void resize(IOOffset size)
virtual IOOffset position(void) const
virtual void create(const char *name, bool exclusive=false, int perms=0666)
static double realNanoSecs(void)
int rfio_open64(const char *filepath, int flags, int mode)
ssize_t retryRead(void *into, IOSize n, int maxRetry=10)
virtual bool prefetch(const IOPosBuffer *what, IOSize n)
void addContext(std::string const &context)
volatile std::atomic< bool > shutdown_flag false
off64_t rfio_lseek64(int s, off64_t offset, int how)