Repository: trafficserver Updated Branches: refs/heads/master 454a2e5be -> 7229900ac
TS-3051: fix libaio error handling The libaio API functions return -errno on error, so the error handling needs to check the resturn code, not look at errno. Replace calls to perror(3) with Debug(), so debug logging works correctly. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7229900a Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7229900a Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7229900a Branch: refs/heads/master Commit: 7229900ac4dd78981cb0a7f63faf8ca03980195d Parents: 454a2e5 Author: James Peach <[email protected]> Authored: Wed Sep 10 16:12:05 2014 -0700 Committer: James Peach <[email protected]> Committed: Thu Sep 11 12:28:19 2014 -0700 ---------------------------------------------------------------------- CHANGES | 2 ++ iocore/aio/AIO.cc | 23 ++++++++++++++--------- iocore/aio/I_AIO.h | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7229900a/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 0a2c782..f8eae50 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 5.2.0 + *) [TS-3051] Fix libaio error handling. + *) [TS-3071] Optionally emit JSON numbers in stats_over_http. Thanks to Saltuk Alakus <[email protected]> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7229900a/iocore/aio/AIO.cc ---------------------------------------------------------------------- diff --git a/iocore/aio/AIO.cc b/iocore/aio/AIO.cc index 6a9c041..f24d2fe 100644 --- a/iocore/aio/AIO.cc +++ b/iocore/aio/AIO.cc @@ -564,29 +564,34 @@ Lagain: complete_list.enqueue(op); //op->handleEvent(event, e); } - if (ret == MAX_AIO_EVENTS) + + if (ret == MAX_AIO_EVENTS) { goto Lagain; - if (ret < 0) - perror("io_getevents"); + } + + if (ret < 0) { + Debug("aio", "io_getevents failed: %s (%d)", strerror(-ret), -ret); + } ink_aiocb_t *cbs[MAX_AIO_EVENTS]; int num = 0; + for (; num < MAX_AIO_EVENTS && ((op = ready_list.dequeue()) != NULL); ++num) { cbs[num] = &op->aiocb; ink_assert(op->action.continuation); } + if (num > 0) { int ret; do { ret = io_submit(ctx, num, cbs); - } while (ret < 0 && errno == EAGAIN); + } while (ret < 0 && ret == -EAGAIN); if (ret != num) { - if (ret < 0) - perror("io_submit error"); - else { - fprintf(stderr, "could not sumbit IOs"); - ink_assert(0); + if (ret < 0) { + Debug("aio", "io_submit failed: %s (%d)", strerror(-ret), -ret); + } else { + Fatal("could not sumbit IOs, io_submit(%p, %d, %p) returned %d", ctx, num, cbs, ret); } } } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7229900a/iocore/aio/I_AIO.h ---------------------------------------------------------------------- diff --git a/iocore/aio/I_AIO.h b/iocore/aio/I_AIO.h index 83f9bf5..bb95df0 100644 --- a/iocore/aio/I_AIO.h +++ b/iocore/aio/I_AIO.h @@ -145,7 +145,7 @@ struct DiskHandler: public Continuation memset(&ctx, 0, sizeof(ctx)); int ret = io_setup(MAX_AIO_EVENTS, &ctx); if (ret < 0) { - perror("io_setup error"); + Debug("aio", "io_setup error: %s (%d)", strerror(-ret), -ret); } } };
