37AIODiskFile::AIODiskFile(
char const *aPath, AIODiskIOStrategy *aStrategy) : fd(-1), closed(true), error_(false)
42 debugs(79, 3,
"AIODiskFile::AIODiskFile: " << aPath);
45AIODiskFile::~AIODiskFile()
59 fd = aio_open(path.termedBuf(), flags);
64 ioRequestor = callback;
67 debugs(79, 3,
"got failure (" << errno <<
")");
72 debugs(79, 3,
"opened FD " << fd);
82 open(flags, mode, callback);
89 async_queue_entry_t *qe;
91 assert(strategy->aq.aq_state == AQ_STATE_SETUP);
94 slot = strategy->findSlot();
98 fatal(
"Aiee! out of aiocb slots! - TODO fix and wrap file_read\n");
106 qe = &strategy->aq.aq_queue[slot];
108 qe->aq_e_state = AQ_ENTRY_USED;
114 qe->aq_e_type = AQ_ENTRY_READ;
116 qe->aq_e_free =
nullptr;
118 qe->aq_e_buf = request->
buf;
120 qe->aq_e_fd = getFD();
122 qe->aq_e_aiocb.aio_fildes = getFD();
124 qe->aq_e_aiocb.aio_nbytes = request->
len;
126 qe->aq_e_aiocb.aio_offset = request->
offset;
128 qe->aq_e_aiocb.aio_buf = request->
buf;
131 ++ strategy->aq.aq_numpending;
134 if (aio_read(&qe->aq_e_aiocb) < 0) {
136 fatalf(
"Aiee! aio_read() returned error (%d) TODO fix and wrap file_read !\n", xerrno);
148 async_queue_entry_t *qe;
150 assert(strategy->aq.aq_state == AQ_STATE_SETUP);
153 slot = strategy->findSlot();
157 fatal(
"Aiee! out of aiocb slots TODO fix and wrap file_write !\n");
165 qe = &strategy->aq.aq_queue[slot];
167 qe->aq_e_state = AQ_ENTRY_USED;
173 qe->aq_e_type = AQ_ENTRY_WRITE;
177 qe->aq_e_buf = (
void *)request->
buf;
181 qe->aq_e_aiocb.aio_fildes = fd;
183 qe->aq_e_aiocb.aio_nbytes = request->
len;
185 qe->aq_e_aiocb.aio_offset = request->
offset;
187 qe->aq_e_aiocb.aio_buf = (
void *)request->
buf;
190 ++strategy->aq.aq_numpending;
193 if (aio_write(&qe->aq_e_aiocb) < 0) {
195 fatalf(
"Aiee! aio_write() returned error (%d) TODO fix and wrap file_write !\n", xerrno);
214 assert (ioRequestor !=
nullptr);
215 ioRequestor->closeCompleted();
219AIODiskFile::canRead()
const
225AIODiskFile::canWrite()
const
231AIODiskFile::getFD()
const
243AIODiskFile::ioInProgress()
const
CBDATA_CLASS_INIT(AIODiskFile)
void error(char *format,...)
#define cbdataReference(var)
virtual void ioCompletedNotification()=0
#define debugs(SECTION, LEVEL, CONTENT)
void fatal(const char *message)
void fatalf(const char *fmt,...)
int file_open(const char *path, int mode)
const char * xstrerr(int error)