0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

eircd::aio: Update some assumptions; minor cleanup.

This commit is contained in:
Jason Volk 2018-08-16 07:16:13 -07:00
parent 850fd0238a
commit 682c4651d2
2 changed files with 19 additions and 20 deletions

View file

@ -153,32 +153,31 @@ noexcept try
*reinterpret_cast<aio::request *>(event.data)
};
// The relevant iocb is repeated back to us in the result; we assert
// some basic sanity here about the layout of the request conglomerate.
assert(reinterpret_cast<iocb *>(event.obj) == static_cast<iocb *>(&request));
// error conventions are like so
assert(event.res >= -1); // unix syscall return value semantic
assert(event.res2 >= 0); // errno code semantic
assert(event.res2 >= 0);
assert(event.res == -1 || event.res2 == 0);
// Set result indicators
request.retval = event.res;
request.errcode = event.res2;
request.retval = std::max(event.res, -1LL);
request.errcode = event.res >= -1? event.res2 : std::abs(event.res);
if(likely(request.waiter && request.waiter != ctx::current))
ctx::notify(*request.waiter);
/*
log::debug("AIO request(%p) fd:%d op:%d bytes:%lu off:%ld prio:%d ctx:%p result: bytes:%ld errno:%ld",
request,
request->aio_fildes,
request->aio_lio_opcode,
request->aio_nbytes,
request->aio_offset,
request->aio_reqprio,
request->waiter,
request->retval,
request->errcode);
log::debug
{
"AIO request(%p) fd:%d op:%d bytes:%lu off:%ld prio:%d ctx:%p result: bytes:%ld errno:%ld",
request,
request->aio_fildes,
request->aio_lio_opcode,
request->aio_nbytes,
request->aio_offset,
request->aio_reqprio,
request->waiter,
request->retval,
request->errcode
};
*/
}
catch(const std::exception &e)
@ -246,7 +245,7 @@ try
{
ctx::wait();
}
while(retval == -2);
while(retval == std::numeric_limits<ssize_t>::min());
if(retval == -1)
throw_system_error(errcode);

View file

@ -60,7 +60,7 @@ struct ircd::fs::aio::request
struct read;
struct write;
ssize_t retval {-2};
ssize_t retval {std::numeric_limits<ssize_t>::min()};
ssize_t errcode {0};
ctx::ctx *waiter {ctx::current};