CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
LStoreFile Class Reference

#include <LStoreFile.h>

Inheritance diagram for LStoreFile:
Storage IOInput IOOutput

Classes

class  MutexWrapper
 

Public Member Functions

virtual void abort (void)
 
virtual void close (void)
 
virtual void create (const char *name, bool exclusive=false, int perms=0666)
 
virtual void create (const std::string &name, bool exclusive=false, int perms=0666)
 
 LStoreFile (void)
 
 LStoreFile (void *fd)
 
 LStoreFile (const char *name, int flags=IOFlags::OpenRead, int perms=0666)
 
 LStoreFile (const std::string &name, int flags=IOFlags::OpenRead, int perms=0666)
 
virtual void open (const char *name, int flags=IOFlags::OpenRead, int perms=0666)
 
virtual void open (const std::string &name, int flags=IOFlags::OpenRead, int perms=0666)
 
virtual IOOffset position (IOOffset offset, Relative whence=SET)
 
virtual IOSize read (void *into, IOSize n)
 
virtual void resize (IOOffset size)
 
virtual IOSize write (const void *from, IOSize n)
 
 ~LStoreFile (void)
 
- Public Member Functions inherited from Storage
virtual bool eof (void) const
 
virtual void flush (void)
 
virtual IOOffset position (void) const
 
virtual bool prefetch (const IOPosBuffer *what, IOSize n)
 
virtual IOSize read (void *into, IOSize n, IOOffset pos)
 
IOSize read (IOBuffer into, IOOffset pos)
 
virtual IOSize readv (IOPosBuffer *into, IOSize buffers)
 
virtual void rewind (void)
 
virtual IOOffset size (void) const
 
 Storage (void)
 
virtual IOSize write (const void *from, IOSize n, IOOffset pos)
 
IOSize write (IOBuffer from, IOOffset pos)
 
virtual IOSize writev (const IOPosBuffer *from, IOSize buffers)
 
virtual ~Storage (void)
 
- Public Member Functions inherited from IOInput
int read (void)
 
IOSize read (IOBuffer into)
 
virtual IOSize readv (IOBuffer *into, IOSize buffers)
 
IOSize xread (IOBuffer into)
 
IOSize xread (void *into, IOSize n)
 
IOSize xreadv (IOBuffer *into, IOSize buffers)
 
virtual ~IOInput (void)
 Destruct the stream. A no-op. More...
 
- Public Member Functions inherited from IOOutput
IOSize write (unsigned char byte)
 
IOSize write (IOBuffer from)
 
virtual IOSize writev (const IOBuffer *from, IOSize buffers)
 
IOSize xwrite (const void *from, IOSize n)
 
IOSize xwrite (IOBuffer from)
 
IOSize xwritev (const IOBuffer *from, IOSize buffers)
 
virtual ~IOOutput (void)
 Destruct the stream. A no-op. More...
 

Static Public Attributes

static pthread_mutex_t m_dlopen_lock = PTHREAD_MUTEX_INITIALIZER
 

Private Member Functions

void closeLibrary ()
 
void loadLibrary ()
 

Private Attributes

bool m_close
 
void * m_fd
 
bool m_is_loaded
 
void * m_library_handle
 
std::string m_name
 
int32_t(* redd_close )(void *)
 
int32_t(* redd_errno )()
 
int32_t(* redd_init )()
 
int64_t(* redd_lseek )(void *, int64_t, uint32_t)
 
void *(* redd_open )(const char *, int32_t, int32_t)
 
int64_t(* redd_read )(void *, char *, int64_t)
 
const std::string &(* redd_strerror )()
 
int32_t(* redd_term )()
 
int64_t(* redd_write )(void *, const char *, int64_t)
 

Additional Inherited Members

- Public Types inherited from Storage
enum  Relative { SET, CURRENT, END }
 

Detailed Description

Definition at line 8 of file LStoreFile.h.

Constructor & Destructor Documentation

LStoreFile::LStoreFile ( void  )

Definition at line 18 of file LStoreFile.cc.

References loadLibrary().

19  : m_fd (0),
20  m_close (false),
21  m_name(),
23  m_is_loaded(false),
24  redd_init(0),
25  redd_read(0),
26  redd_close(0),
27  redd_lseek(0),
28  redd_open(0),
29  redd_write(0),
30  redd_term(0),
31  redd_errno(0),
32  redd_strerror(0)
33 {
34  loadLibrary();
35 }
void loadLibrary()
Definition: LStoreFile.cc:99
int32_t(* redd_errno)()
Definition: LStoreFile.h:76
void * m_library_handle
Definition: LStoreFile.h:63
int64_t(* redd_lseek)(void *, int64_t, uint32_t)
Definition: LStoreFile.h:72
std::string m_name
Definition: LStoreFile.h:62
int32_t(* redd_init)()
Definition: LStoreFile.h:69
int32_t(* redd_term)()
Definition: LStoreFile.h:75
bool m_close
Definition: LStoreFile.h:61
void * m_fd
Definition: LStoreFile.h:60
int64_t(* redd_write)(void *, const char *, int64_t)
Definition: LStoreFile.h:74
void *(* redd_open)(const char *, int32_t, int32_t)
Definition: LStoreFile.h:73
bool m_is_loaded
Definition: LStoreFile.h:64
const std::string &(* redd_strerror)()
Definition: LStoreFile.h:77
int32_t(* redd_close)(void *)
Definition: LStoreFile.h:71
int64_t(* redd_read)(void *, char *, int64_t)
Definition: LStoreFile.h:70
LStoreFile::LStoreFile ( void *  fd)

Definition at line 37 of file LStoreFile.cc.

References loadLibrary().

38  : m_fd (fd),
39  m_close (true),
40  m_name(),
42  m_is_loaded(false),
43  redd_init(0),
44  redd_read(0),
45  redd_close(0),
46  redd_lseek(0),
47  redd_open(0),
48  redd_write(0),
49  redd_term(0),
50  redd_errno(0),
51  redd_strerror(0)
52 {
53  loadLibrary();
54 }
void loadLibrary()
Definition: LStoreFile.cc:99
int32_t(* redd_errno)()
Definition: LStoreFile.h:76
void * m_library_handle
Definition: LStoreFile.h:63
int64_t(* redd_lseek)(void *, int64_t, uint32_t)
Definition: LStoreFile.h:72
std::string m_name
Definition: LStoreFile.h:62
int32_t(* redd_init)()
Definition: LStoreFile.h:69
int32_t(* redd_term)()
Definition: LStoreFile.h:75
bool m_close
Definition: LStoreFile.h:61
void * m_fd
Definition: LStoreFile.h:60
int64_t(* redd_write)(void *, const char *, int64_t)
Definition: LStoreFile.h:74
void *(* redd_open)(const char *, int32_t, int32_t)
Definition: LStoreFile.h:73
bool m_is_loaded
Definition: LStoreFile.h:64
const std::string &(* redd_strerror)()
Definition: LStoreFile.h:77
int32_t(* redd_close)(void *)
Definition: LStoreFile.h:71
int64_t(* redd_read)(void *, char *, int64_t)
Definition: LStoreFile.h:70
LStoreFile::LStoreFile ( const char *  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)

Definition at line 56 of file LStoreFile.cc.

References loadLibrary(), and open().

59  : m_fd (NULL),
60  m_close (false),
61  m_is_loaded(false)
62 { loadLibrary();
63  open (name, flags, perms); }
void loadLibrary()
Definition: LStoreFile.cc:99
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
#define NULL
Definition: scimark2.h:8
bool m_close
Definition: LStoreFile.h:61
void * m_fd
Definition: LStoreFile.h:60
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: LStoreFile.cc:193
bool m_is_loaded
Definition: LStoreFile.h:64
LStoreFile::LStoreFile ( const std::string &  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)

Definition at line 65 of file LStoreFile.cc.

References flags, loadLibrary(), and open().

68  : m_fd (NULL),
69  m_close (false),
70  m_is_loaded(false)
71 { loadLibrary();
72  open (name.c_str (), flags, perms); }
void loadLibrary()
Definition: LStoreFile.cc:99
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
#define NULL
Definition: scimark2.h:8
bool m_close
Definition: LStoreFile.h:61
void * m_fd
Definition: LStoreFile.h:60
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: LStoreFile.cc:193
bool m_is_loaded
Definition: LStoreFile.h:64
LStoreFile::~LStoreFile ( void  )

Definition at line 74 of file LStoreFile.cc.

References closeLibrary(), m_close, and m_name.

75 {
76  if (m_close)
77  edm::LogError("LStoreFileError")
78  << "Destructor called on LStore file '" << m_name
79  << "' but the file is still open";
80  closeLibrary();
81 }
std::string m_name
Definition: LStoreFile.h:62
bool m_close
Definition: LStoreFile.h:61
void closeLibrary()
Definition: LStoreFile.cc:135

Member Function Documentation

void LStoreFile::abort ( void  )
virtual

Definition at line 278 of file LStoreFile.cc.

References m_close, m_fd, and NULL.

279 {
280  if (m_fd != NULL)
281  (*redd_close) (m_fd);
282 
283  m_close = false;
284  m_fd = NULL;
285 }
#define NULL
Definition: scimark2.h:8
bool m_close
Definition: LStoreFile.h:61
void * m_fd
Definition: LStoreFile.h:60
void LStoreFile::close ( void  )
virtual

Reimplemented from Storage.

Definition at line 253 of file LStoreFile.cc.

References m_close, m_fd, m_name, NULL, redd_close, and redd_errno.

Referenced by lumiQTWidget.ApplicationWindow::fileQuit(), esMonitoring.AsyncLineReaderMixin::handle_close(), esMonitoring.FDJsonServer::handle_close(), Vispa.Gui.BoxContentDialog.BoxContentDialog::keyPressEvent(), Vispa.Gui.FindDialog.FindDialog::keyPressEvent(), and open().

254 {
255  if (m_fd == NULL)
256  {
257  edm::LogError("LStoreFileError")
258  << "LStoreFile::close(name='" << m_name
259  << "') called but the file is not open";
260  m_close = false;
261  return;
262  }
263  edm::LogInfo("LStoreFile::close()") << "closing " << m_name << std::endl;
264  if ((*redd_close) (m_fd) == -1)
265  edm::LogWarning("LStoreFileWarning")
266  << "redd_close(name='" << m_name
267  << "') failed with error '" << (*redd_strerror) ()
268  << "' (redd_errno=" << (*redd_errno)() << ")";
269 
270  m_close = false;
271  m_fd = NULL;
272 
273  // Caused hang. Will be added back after problem is fixed.
274  // edm::LogInfo("LStoreFileInfo") << "Closed " << m_name;
275 }
int32_t(* redd_errno)()
Definition: LStoreFile.h:76
#define NULL
Definition: scimark2.h:8
std::string m_name
Definition: LStoreFile.h:62
bool m_close
Definition: LStoreFile.h:61
void * m_fd
Definition: LStoreFile.h:60
int32_t(* redd_close)(void *)
Definition: LStoreFile.h:71
void LStoreFile::closeLibrary ( )
private

Definition at line 135 of file LStoreFile.cc.

References MillePedeFileConverter_cfg::e, Exception, m_dlopen_lock, m_is_loaded, m_library_handle, NULL, and redd_term.

Referenced by ~LStoreFile().

135  {
136  try {
137  LStoreFile::MutexWrapper lockObj( & this->m_dlopen_lock );
138 
139  // What is the correct idiom for propagating error messages
140  // in functions that are exclusively called in destructors?
141  // Seriously. I have no idea
142  // melo
143  if ( m_is_loaded ) {
144  if ( (*redd_term)() ) {
145  throw cms::Exception("LStoreFile::closeLibrary()")
146  << "Error in redd_term: " << (*redd_strerror)();
147  }
148  }
149  if ( m_library_handle != NULL ) {
150  if ( dlclose( m_library_handle ) ) {
151  throw cms::Exception("LStoreFile::closeLibrary()")
152  << "Error on dlclose(): " << dlerror();
153  }
154  }
155  } catch (cms::Exception & e) {
156  edm::LogError("LStoreFileError")
157  << "LStoreFile had an error in its destructor: " << e;
158  }
159  m_is_loaded = false;
160 }
void * m_library_handle
Definition: LStoreFile.h:63
#define NULL
Definition: scimark2.h:8
int32_t(* redd_term)()
Definition: LStoreFile.h:75
bool m_is_loaded
Definition: LStoreFile.h:64
static pthread_mutex_t m_dlopen_lock
Definition: LStoreFile.h:50
void LStoreFile::create ( const char *  name,
bool  exclusive = false,
int  perms = 0666 
)
virtual

Definition at line 165 of file LStoreFile.cc.

References open(), IOFlags::OpenCreate, IOFlags::OpenExclusive, IOFlags::OpenTruncate, and IOFlags::OpenWrite.

168 {
169  open (name,
171  | (exclusive ? IOFlags::OpenExclusive : 0)),
172  perms);
173 }
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: LStoreFile.cc:193
void LStoreFile::create ( const std::string &  name,
bool  exclusive = false,
int  perms = 0666 
)
virtual

Definition at line 176 of file LStoreFile.cc.

References open(), IOFlags::OpenCreate, IOFlags::OpenExclusive, IOFlags::OpenTruncate, and IOFlags::OpenWrite.

179 {
180  open (name.c_str (),
182  | (exclusive ? IOFlags::OpenExclusive : 0)),
183  perms);
184 }
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: LStoreFile.cc:193
void LStoreFile::loadLibrary ( )
private

Definition at line 99 of file LStoreFile.cc.

References Exception, m_dlopen_lock, m_is_loaded, m_library_handle, NULL, redd_errno, redd_init, REDD_LOAD_SYMBOL, redd_lseek, redd_open, redd_read, redd_strerror, redd_term, redd_write, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by LStoreFile().

99  {
100  edm::LogError("LStoreFile::loadLibrary()") << "Loading library\n";
101  LStoreFile::MutexWrapper lockObj( & this->m_dlopen_lock );
102  // until ACCRE removes the java dependency from their client libs,
103  // we'll dlopen() them so they don't need to be brought along with cmssw
104  // if you're running LStore at your site, you will have the libs anyway
105  // TODO add wrappers to make this work in OSX as well (CMSSW's getting ported?)
106  // TODO should be easy, just need to know the "proper" way to do #if OSX
107  // -Melo
108 
110  dlopen("libreddnet.so", RTLD_LAZY);
111  if (m_library_handle == NULL) {
112  throw cms::Exception("LStoreFile::loadLibrary()")
113  << "Can't dlopen() LStore libraries: " << dlerror();
114  }
115 
116  char * retval = NULL;
117  // Explicitly state the size of these values, keeps weird 64/32 bit stuff away
118  REDD_LOAD_SYMBOL( redd_init, int32_t(*)());
119  REDD_LOAD_SYMBOL( redd_read, int64_t(*)(void *, char*, int64_t));
120  REDD_LOAD_SYMBOL( redd_lseek, int64_t(*)(void*, int64_t, uint32_t));
121  REDD_LOAD_SYMBOL( redd_open, void*(*)(const char*,int,int));
122  REDD_LOAD_SYMBOL( redd_write, int64_t(*)(void *, const char *, int64_t));
123  REDD_LOAD_SYMBOL( redd_term, int32_t(*)());
124  REDD_LOAD_SYMBOL( redd_errno, int32_t(*)());
125  REDD_LOAD_SYMBOL( redd_strerror, const std::string & (*)());
126 
127  if ( (*redd_init)() ) {
128  throw cms::Exception("LStoreFile::loadLibrary()")
129  << "Error in redd_init: " << (*redd_strerror)();
130  }
131  m_is_loaded = true;
132 
133 }
int32_t(* redd_errno)()
Definition: LStoreFile.h:76
void * m_library_handle
Definition: LStoreFile.h:63
int64_t(* redd_lseek)(void *, int64_t, uint32_t)
Definition: LStoreFile.h:72
#define NULL
Definition: scimark2.h:8
int32_t(* redd_init)()
Definition: LStoreFile.h:69
int32_t(* redd_term)()
Definition: LStoreFile.h:75
int64_t(* redd_write)(void *, const char *, int64_t)
Definition: LStoreFile.h:74
void *(* redd_open)(const char *, int32_t, int32_t)
Definition: LStoreFile.h:73
#define REDD_LOAD_SYMBOL(NAME, TYPE)
Definition: LStoreFile.cc:87
bool m_is_loaded
Definition: LStoreFile.h:64
const std::string &(* redd_strerror)()
Definition: LStoreFile.h:77
int64_t(* redd_read)(void *, char *, int64_t)
Definition: LStoreFile.h:70
static pthread_mutex_t m_dlopen_lock
Definition: LStoreFile.h:50
void LStoreFile::open ( const char *  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)
virtual

Definition at line 193 of file LStoreFile.cc.

References close(), TauDecayModes::dec, Exception, m_close, m_fd, m_name, dataset::name, NULL, O_NONBLOCK, IOFlags::OpenAppend, IOFlags::OpenCreate, IOFlags::OpenExclusive, IOFlags::OpenNonBlock, IOFlags::OpenRead, IOFlags::OpenTruncate, IOFlags::OpenWrite, redd_errno, and redd_open.

Referenced by create(), LStoreFile(), and open().

196 {
197  // Actual open
198  if ((name == 0) || (*name == 0))
199  throw cms::Exception("LStoreFile::open()")
200  << "Cannot open a file without a name";
201 
202  if ((flags & (IOFlags::OpenRead | IOFlags::OpenWrite)) == 0)
203  throw cms::Exception("LStoreFile::open()")
204  << "Must open file '" << name << "' at least for read or write";
205 
206  // If I am already open, close old file first
207  if (m_fd != NULL && m_close)
208  close ();
209 
210  // Translate our flags to system flags
211  int openflags = 0;
212 
214  openflags |= O_RDWR;
215  else if (flags & IOFlags::OpenRead)
216  openflags |= O_RDONLY;
217  else if (flags & IOFlags::OpenWrite)
218  openflags |= O_WRONLY;
219 
221  openflags |= O_NONBLOCK;
222 
224  openflags |= O_APPEND;
225 
227  openflags |= O_CREAT;
228 
230  openflags |= O_EXCL;
231 
233  openflags |= O_TRUNC;
234 
235  void * newfd = NULL;
236  if ((newfd = (*redd_open) (name, openflags, perms)) == NULL)
237  throw cms::Exception("LStoreFile::open()")
238  << "redd_open(name='" << name
239  << "', flags=0x" << std::hex << openflags
240  << ", permissions=0" << std::oct << perms << std::dec
241  << ") => error '" << (*redd_strerror)()
242  << "' (redd_errno=" << (*redd_errno)() << ")";
243 
244  m_name = name;
245  m_fd = newfd;
246 
247  m_close = true;
248 
249  edm::LogInfo("LStoreFileInfo") << "Opened " << m_name;
250 }
int32_t(* redd_errno)()
Definition: LStoreFile.h:76
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
#define NULL
Definition: scimark2.h:8
std::string m_name
Definition: LStoreFile.h:62
bool m_close
Definition: LStoreFile.h:61
void * m_fd
Definition: LStoreFile.h:60
void *(* redd_open)(const char *, int32_t, int32_t)
Definition: LStoreFile.h:73
#define O_NONBLOCK
Definition: SysFile.h:21
virtual void close(void)
Definition: LStoreFile.cc:253
void LStoreFile::open ( const std::string &  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)
virtual

Definition at line 187 of file LStoreFile.cc.

References flags, and open().

190 { open (name.c_str (), flags, perms); }
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: LStoreFile.cc:193
IOOffset LStoreFile::position ( IOOffset  offset,
Relative  whence = SET 
)
virtual

Implements Storage.

Definition at line 326 of file LStoreFile.cc.

References Storage::CURRENT, Storage::END, Exception, m_fd, m_name, NULL, redd_errno, redd_lseek, mps_fire::result, and Storage::SET.

Referenced by LStoreStorageMaker::check().

327 {
328  if (m_fd == NULL)
329  throw cms::Exception("LStoreFile::position()")
330  << "LStoreFile::position() called on a closed file";
331  if (whence != CURRENT && whence != SET && whence != END)
332  throw cms::Exception("LStoreFile::position()")
333  << "LStoreFile::position() called with incorrect 'whence' parameter";
334 
336  uint32_t mywhence = (whence == SET ? SEEK_SET
337  : whence == CURRENT ? SEEK_CUR
338  : SEEK_END);
339  if ((result = (*redd_lseek) (m_fd, (off_t) offset, (uint32_t)mywhence)) == -1)
340  throw cms::Exception("LStoreFile::position()")
341  << "redd_lseek64(name='" << m_name << "', offset=" << offset
342  << ", whence=" << mywhence << ") failed with error '"
343  << (*redd_strerror) () << "' (redd_errno=" << (*redd_errno)() << ")";
344  return result;
345 }
int32_t(* redd_errno)()
Definition: LStoreFile.h:76
int64_t(* redd_lseek)(void *, int64_t, uint32_t)
Definition: LStoreFile.h:72
#define NULL
Definition: scimark2.h:8
std::string m_name
Definition: LStoreFile.h:62
void * m_fd
Definition: LStoreFile.h:60
int64_t IOOffset
Definition: IOTypes.h:19
IOSize LStoreFile::read ( void *  into,
IOSize  n 
)
virtual

Read into into at most n number of bytes.

If this is a blocking stream, the call will block until some data can be read, end of input is reached, or an exception is thrown. For a non-blocking stream the available input is returned. If none is available, an exception is thrown.

Returns
The number of bytes actually read. This is less or equal to the size of the buffer. Zero indicates that the end of the input has been reached: end of file, or remote end closing for a connected channel like a pipe or a socket. Otherwise the value can be less than requested if limited amount of input is currently available for platform or implementation reasons.
Exceptions
Incase of error, a #IOError exception is thrown. This includes the situation where the input stream is in non-blocking mode and no input is currently available (FIXME: make this simpler; clarify which exception).

Implements IOInput.

Definition at line 289 of file LStoreFile.cc.

References Exception, m_fd, m_name, redd_errno, redd_strerror, and alignCSCRings::s.

290 {
291  IOSize done = 0;
292  while (done < n)
293  {
294  ssize_t s = (*redd_read) (m_fd, (char *) into + done, n - done);
295  if (s == -1)
296  throw cms::Exception("LStoreFile::read()")
297  << "redd_read(name='" << m_name << "', n=" << (n-done)
298  << ") failed with error '" << (*redd_strerror)()
299  << "' (redd_errno=" << (*redd_errno)() << ")";
300  done += s;
301  }
302  return done;
303 }
int32_t(* redd_errno)()
Definition: LStoreFile.h:76
std::string m_name
Definition: LStoreFile.h:62
void * m_fd
Definition: LStoreFile.h:60
const std::string &(* redd_strerror)()
Definition: LStoreFile.h:77
size_t IOSize
Definition: IOTypes.h:14
void LStoreFile::resize ( IOOffset  size)
virtual

Implements Storage.

Definition at line 348 of file LStoreFile.cc.

References Exception, and m_name.

Referenced by Vispa.Gui.TextDialog.TextDialog::__init__(), Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog::__init__(), Vispa.Main.MainWindow.MainWindow::_loadIni(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

349 {
350  throw cms::Exception("LStoreFile::resize()")
351  << "LStoreFile::resize(name='" << m_name << "') not implemented";
352 }
std::string m_name
Definition: LStoreFile.h:62
IOSize LStoreFile::write ( const void *  from,
IOSize  n 
)
virtual

Write n bytes of data starting at address from.

Returns
The number of bytes written. Normally this will be n, but can be less, even zero, for example if the stream is non-blocking mode and cannot accept input at this time.
Exceptions
Incase of error, an exception is thrown. However if the stream is in non-blocking mode and cannot accept output, it will not throw an exception – the return value will be less than requested.

Implements IOOutput.

Definition at line 306 of file LStoreFile.cc.

References Exception, m_fd, m_name, redd_errno, redd_strerror, and alignCSCRings::s.

307 {
308  IOSize done = 0;
309  while (done < n)
310  {
311  ssize_t s = (*redd_write) (m_fd, (const char *) from + done, n - done);
312  if (s == -1)
313  throw cms::Exception("LStoreFile::write()")
314  << "redd_write(name='" << m_name << "', n=" << (n-done)
315  << ") failed with error '" << (*redd_strerror)()
316  << "' (redd_errno=" << (*redd_errno)() << ")";
317  done += s;
318  }
319 
320  return done;
321 }
int32_t(* redd_errno)()
Definition: LStoreFile.h:76
std::string m_name
Definition: LStoreFile.h:62
void * m_fd
Definition: LStoreFile.h:60
const std::string &(* redd_strerror)()
Definition: LStoreFile.h:77
size_t IOSize
Definition: IOTypes.h:14

Member Data Documentation

bool LStoreFile::m_close
private

Definition at line 61 of file LStoreFile.h.

Referenced by abort(), close(), open(), and ~LStoreFile().

pthread_mutex_t LStoreFile::m_dlopen_lock = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 50 of file LStoreFile.h.

Referenced by closeLibrary(), and loadLibrary().

void* LStoreFile::m_fd
private

Definition at line 60 of file LStoreFile.h.

Referenced by abort(), close(), open(), position(), read(), and write().

bool LStoreFile::m_is_loaded
private

Definition at line 64 of file LStoreFile.h.

Referenced by closeLibrary(), and loadLibrary().

void* LStoreFile::m_library_handle
private

Definition at line 63 of file LStoreFile.h.

Referenced by closeLibrary(), and loadLibrary().

std::string LStoreFile::m_name
private

Definition at line 62 of file LStoreFile.h.

Referenced by close(), open(), position(), read(), resize(), write(), and ~LStoreFile().

int32_t(* LStoreFile::redd_close) (void *)
private

Definition at line 71 of file LStoreFile.h.

Referenced by close().

int32_t(* LStoreFile::redd_errno) ()
private

Definition at line 76 of file LStoreFile.h.

Referenced by close(), loadLibrary(), open(), position(), read(), and write().

int32_t(* LStoreFile::redd_init) ()
private

Definition at line 69 of file LStoreFile.h.

Referenced by loadLibrary().

int64_t(* LStoreFile::redd_lseek) (void *, int64_t, uint32_t)
private

Definition at line 72 of file LStoreFile.h.

Referenced by loadLibrary(), and position().

void*(* LStoreFile::redd_open) (const char *, int32_t, int32_t)
private

Definition at line 73 of file LStoreFile.h.

Referenced by loadLibrary(), and open().

int64_t(* LStoreFile::redd_read) (void *, char *, int64_t)
private

Definition at line 70 of file LStoreFile.h.

Referenced by loadLibrary().

const std::string&(* LStoreFile::redd_strerror) ()
private

Definition at line 77 of file LStoreFile.h.

Referenced by loadLibrary(), read(), and write().

int32_t(* LStoreFile::redd_term) ()
private

Definition at line 75 of file LStoreFile.h.

Referenced by closeLibrary(), and loadLibrary().

int64_t(* LStoreFile::redd_write) (void *, const char *, int64_t)
private

Definition at line 74 of file LStoreFile.h.

Referenced by loadLibrary().