|
|
Go to the documentation of this file.
20 m_library_handle(nullptr),
30 redd_strerror(nullptr) {
38 m_library_handle(nullptr),
48 redd_strerror(nullptr) {
53 : m_fd(nullptr), m_close(
false), m_is_loaded(
false) {
59 : m_fd(nullptr), m_close(
false), m_is_loaded(
false) {
67 <<
"' but the file is still open";
74 #define REDD_LOAD_SYMBOL(NAME, TYPE) \
76 NAME = reinterpret_cast<TYPE>(reinterpret_cast<size_t>(dlsym(m_library_handle, #NAME))); \
77 if ((retval = dlerror())) { \
78 throw cms::Exception("LStoreFile::loadLibrary()") << "Failed to load dlsym LStore library: " << retval; \
81 throw cms::Exception("LStoreFile::loadLibrary()") << "Got a null pointer back from dlsym()\n"; \
85 edm::LogError(
"LStoreFile::loadLibrary()") <<
"Loading library\n";
96 throw cms::Exception(
"LStoreFile::loadLibrary()") <<
"Can't dlopen() LStore libraries: " << dlerror();
99 char *retval =
nullptr;
111 throw cms::Exception(
"LStoreFile::loadLibrary()") <<
"Error in redd_init: " << (*redd_strerror)();
126 throw cms::Exception(
"LStoreFile::closeLibrary()") <<
"Error in redd_term: " << (*redd_strerror)();
131 throw cms::Exception(
"LStoreFile::closeLibrary()") <<
"Error on dlclose(): " << dlerror();
135 edm::LogError(
"LStoreFileError") <<
"LStoreFile had an error in its destructor: " <<
e;
159 if ((
name ==
nullptr) || (*
name == 0))
160 throw cms::Exception(
"LStoreFile::open()") <<
"Cannot open a file without a name";
163 throw cms::Exception(
"LStoreFile::open()") <<
"Must open file '" <<
name <<
"' at least for read or write";
175 openflags |= O_RDONLY;
177 openflags |= O_WRONLY;
183 openflags |= O_APPEND;
186 openflags |= O_CREAT;
192 openflags |= O_TRUNC;
194 void *newfd =
nullptr;
195 if ((newfd = (*
redd_open)(
name, openflags, perms)) ==
nullptr)
197 <<
"redd_open(name='" <<
name <<
"', flags=0x" << std::hex << openflags <<
", permissions=0" << std::oct
198 << perms <<
std::dec <<
") => error '" << (*redd_strerror)() <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
209 if (
m_fd ==
nullptr) {
210 edm::LogError(
"LStoreFileError") <<
"LStoreFile::close(name='" <<
m_name <<
"') called but the file is not open";
217 << (*redd_strerror)() <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
241 <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
250 ssize_t
s = (*redd_write)(
m_fd, (
const char *)from +
done,
n -
done);
254 <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
265 throw cms::Exception(
"LStoreFile::position()") <<
"LStoreFile::position() called on a closed file";
267 throw cms::Exception(
"LStoreFile::position()") <<
"LStoreFile::position() called with incorrect 'whence' parameter";
270 uint32_t mywhence = (whence ==
SET ? SEEK_SET : whence ==
CURRENT ? SEEK_CUR : SEEK_END);
273 <<
"redd_lseek64(name='" <<
m_name <<
"', offset=" <<
offset <<
", whence=" << mywhence
274 <<
") failed with error '" << (*redd_strerror)() <<
"' (redd_errno=" << (*
redd_errno)() <<
")";
279 throw cms::Exception(
"LStoreFile::resize()") <<
"LStoreFile::resize(name='" <<
m_name <<
"') not implemented";
286 pthread_mutex_lock(
m_lock);
291 if ((retval = pthread_mutex_unlock(m_lock))) {
299 edm::LogError(
"LStoreFileError") <<
"LStoreFile couldn't unlock a mutex. Not good."
300 << strerror_r(retval,
buf, 1024);
int64_t(* redd_write)(void *, const char *, int64_t)
const std::string &(* redd_strerror)()
virtual void create(const char *name, bool exclusive=false, int perms=0666)
IOSize write(const void *from, IOSize n) override
Log< level::Info, false > LogInfo
Log< level::Warning, false > LogWarning
MutexWrapper(pthread_mutex_t *lock)
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
int64_t(* redd_lseek)(void *, int64_t, uint32_t)
static pthread_mutex_t m_dlopen_lock
int32_t(* redd_close)(void *)
int64_t(* redd_read)(void *, char *, int64_t)
void close(void) override
~LStoreFile(void) override
#define REDD_LOAD_SYMBOL(NAME, TYPE)
Log< level::Error, false > LogError
virtual IOOffset position(void) const
void *(* redd_open)(const char *, int32_t, int32_t)
void resize(IOOffset size) override