You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ok...@apache.org on 2018/03/03 09:55:38 UTC
[trafficserver] branch master updated: Create a new AIOCallback to
call back aio_err_callbck if there is an error from Linux Native AIO
This is an automated email from the ASF dual-hosted git repository.
oknet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 42b1a8c Create a new AIOCallback to call back aio_err_callbck if there is an error from Linux Native AIO
42b1a8c is described below
commit 42b1a8cb349c0a013a1d72dd7bf3b7c9790224ae
Author: Oknet Xu <xu...@skyguard.com.cn>
AuthorDate: Sat Feb 24 20:14:33 2018 +0800
Create a new AIOCallback to call back aio_err_callbck if there is an error from Linux Native AIO
---
iocore/aio/AIO.cc | 23 +++++++++--------------
iocore/aio/P_AIO.h | 48 +++++++++++++++++++++---------------------------
2 files changed, 30 insertions(+), 41 deletions(-)
diff --git a/iocore/aio/AIO.cc b/iocore/aio/AIO.cc
index 76a6ee6..e760354 100644
--- a/iocore/aio/AIO.cc
+++ b/iocore/aio/AIO.cc
@@ -495,16 +495,7 @@ aio_thread_main(void *arg)
aio_bytes_read += op->aiocb.aio_nbytes;
}
ink_mutex_release(¤t_req->aio_mutex);
- if (cache_op((AIOCallbackInternal *)op) <= 0) {
- if (aio_err_callbck) {
- AIOCallback *callback_op = new AIOCallbackInternal();
- callback_op->aiocb.aio_fildes = op->aiocb.aio_fildes;
- callback_op->aiocb.aio_lio_opcode = op->aiocb.aio_lio_opcode;
- callback_op->mutex = aio_err_callbck->mutex;
- callback_op->action = aio_err_callbck;
- eventProcessor.schedule_imm(callback_op);
- }
- }
+ cache_op((AIOCallbackInternal *)op);
ink_atomic_increment((int *)¤t_req->requests_queued, -1);
#ifdef AIO_STATS
ink_atomic_increment((int *)¤t_req->pending, -1);
@@ -514,9 +505,7 @@ aio_thread_main(void *arg)
op->mutex = op->action.mutex;
if (op->thread == AIO_CALLBACK_THREAD_AIO) {
SCOPED_MUTEX_LOCK(lock, op->mutex, thr_info->mutex->thread_holding);
- if (!op->action.cancelled) {
- op->action.continuation->handleEvent(AIO_EVENT_DONE, op);
- }
+ op->handleEvent(EVENT_NONE, nullptr);
} else if (op->thread == AIO_CALLBACK_THREAD_ANY) {
eventProcessor.schedule_imm_signal(op);
} else {
@@ -587,7 +576,13 @@ Lagain:
}
while ((op = complete_list.dequeue()) != nullptr) {
- op->handleEvent(event, e);
+ op->mutex = op->action.mutex;
+ MUTEX_TRY_LOCK(lock, op->mutex, trigger_event->ethread);
+ if (!lock.is_locked()) {
+ trigger_event->ethread->schedule_imm(op);
+ } else {
+ op->handleEvent(EVENT_NONE, nullptr);
+ }
}
return EVENT_CONT;
}
diff --git a/iocore/aio/P_AIO.h b/iocore/aio/P_AIO.h
index 49f0ba5..696d9b5 100644
--- a/iocore/aio/P_AIO.h
+++ b/iocore/aio/P_AIO.h
@@ -46,10 +46,10 @@ AIOCallback::ok()
return (off_t)aiocb.aio_nbytes == (off_t)aio_result;
}
-#if AIO_MODE == AIO_MODE_NATIVE
-
extern Continuation *aio_err_callbck;
+#if AIO_MODE == AIO_MODE_NATIVE
+
struct AIOCallbackInternal : public AIOCallback {
int io_complete(int event, void *data);
AIOCallbackInternal()
@@ -60,21 +60,6 @@ struct AIOCallbackInternal : public AIOCallback {
};
TS_INLINE int
-AIOCallbackInternal::io_complete(int event, void *data)
-{
- (void)event;
- (void)data;
-
- if (!ok() && aio_err_callbck)
- eventProcessor.schedule_imm(aio_err_callbck, ET_CALL, AIO_EVENT_DONE);
- mutex = action.mutex;
- SCOPED_MUTEX_LOCK(lock, mutex, this_ethread());
- if (!action.cancelled)
- action.continuation->handleEvent(AIO_EVENT_DONE, this);
- return EVENT_DONE;
-}
-
-TS_INLINE int
AIOVec::mainEvent(int /* event */, Event *)
{
++completed;
@@ -104,16 +89,6 @@ struct AIOCallbackInternal : public AIOCallback {
AIOCallbackInternal() { SET_HANDLER(&AIOCallbackInternal::io_complete); }
};
-TS_INLINE int
-AIOCallbackInternal::io_complete(int event, void *data)
-{
- (void)event;
- (void)data;
- if (!action.cancelled)
- action.continuation->handleEvent(AIO_EVENT_DONE, this);
- return EVENT_DONE;
-}
-
struct AIO_Reqs {
Que(AIOCallback, link) aio_todo; /* queue for holding non-http requests */
Que(AIOCallback, link) http_aio_todo; /* queue for http requests */
@@ -130,6 +105,25 @@ struct AIO_Reqs {
};
#endif // AIO_MODE == AIO_MODE_NATIVE
+
+TS_INLINE int
+AIOCallbackInternal::io_complete(int event, void *data)
+{
+ (void)event;
+ (void)data;
+ if (aio_err_callbck && !ok()) {
+ AIOCallback *err_op = new AIOCallbackInternal();
+ err_op->aiocb.aio_fildes = this->aiocb.aio_fildes;
+ err_op->aiocb.aio_lio_opcode = this->aiocb.aio_lio_opcode;
+ err_op->mutex = aio_err_callbck->mutex;
+ err_op->action = aio_err_callbck;
+ eventProcessor.schedule_imm(err_op);
+ }
+ if (!action.cancelled)
+ action.continuation->handleEvent(AIO_EVENT_DONE, this);
+ return EVENT_DONE;
+}
+
#ifdef AIO_STATS
class AIOTestData : public Continuation
{
--
To stop receiving notification emails like this one, please contact
oknet@apache.org.