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:
parent
850fd0238a
commit
682c4651d2
2 changed files with 19 additions and 20 deletions
21
ircd/aio.cc
21
ircd/aio.cc
|
@ -153,23 +153,21 @@ 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",
|
||||
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,
|
||||
|
@ -178,7 +176,8 @@ noexcept try
|
|||
request->aio_reqprio,
|
||||
request->waiter,
|
||||
request->retval,
|
||||
request->errcode);
|
||||
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);
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
|
Loading…
Reference in a new issue