0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +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) *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)); assert(reinterpret_cast<iocb *>(event.obj) == static_cast<iocb *>(&request));
assert(event.res2 >= 0);
// error conventions are like so
assert(event.res >= -1); // unix syscall return value semantic
assert(event.res2 >= 0); // errno code semantic
assert(event.res == -1 || event.res2 == 0); assert(event.res == -1 || event.res2 == 0);
// Set result indicators // Set result indicators
request.retval = event.res; request.retval = std::max(event.res, -1LL);
request.errcode = event.res2; request.errcode = event.res >= -1? event.res2 : std::abs(event.res);
if(likely(request.waiter && request.waiter != ctx::current)) if(likely(request.waiter && request.waiter != ctx::current))
ctx::notify(*request.waiter); 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", log::debug
request, {
request->aio_fildes, "AIO request(%p) fd:%d op:%d bytes:%lu off:%ld prio:%d ctx:%p result: bytes:%ld errno:%ld",
request->aio_lio_opcode, request,
request->aio_nbytes, request->aio_fildes,
request->aio_offset, request->aio_lio_opcode,
request->aio_reqprio, request->aio_nbytes,
request->waiter, request->aio_offset,
request->retval, request->aio_reqprio,
request->errcode); request->waiter,
request->retval,
request->errcode
};
*/ */
} }
catch(const std::exception &e) catch(const std::exception &e)
@ -246,7 +245,7 @@ try
{ {
ctx::wait(); ctx::wait();
} }
while(retval == -2); while(retval == std::numeric_limits<ssize_t>::min());
if(retval == -1) if(retval == -1)
throw_system_error(errcode); throw_system_error(errcode);

View file

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