This is an automated email from the ASF dual-hosted git repository. bcall 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 cefe482 remove TSContSchedule, then rename TSContScheduleOnPool to TSContSchedule cefe482 is described below commit cefe4826c919847385aa9d8459b9d5cfc20377f9 Author: Fei Deng <duke8...@gmail.com> AuthorDate: Tue Mar 31 14:12:38 2020 -0500 remove TSContSchedule, then rename TSContScheduleOnPool to TSContSchedule --- doc/.tx/config | 6 +- .../api/functions/TSContScheduleEvery.en.rst | 58 --------------- ...ule.en.rst => TSContScheduleEveryOnPool.en.rst} | 28 +++---- .../api/functions/TSContScheduleOnPool.en.rst | 25 +++++-- .../api/functions/TSContScheduleOnThread.en.rst | 17 ++++- .../api/functions/TSContThreadAffinitySet.en.rst | 4 +- .../continuations/activating-continuations.en.rst | 2 +- .../plugins/continuations/index.en.rst | 2 +- .../continuations/writing-handler-functions.en.rst | 5 +- ...ntSchedule.en.po => TSContScheduleOnPool.en.po} | 10 +-- .../continuations/activating-continuations.en.po | 4 +- .../plugins/continuations/index.en.po | 4 +- .../continuations/writing-handler-functions.en.po | 8 +- include/ts/ts.h | 2 - src/traffic_server/InkAPI.cc | 63 ---------------- tests/gold_tests/cont_schedule/gold/schedule.gold | 4 - tests/gold_tests/cont_schedule/schedule.test.py | 49 ------------ tests/tools/plugins/cont_schedule.cc | 87 ++-------------------- 18 files changed, 75 insertions(+), 303 deletions(-) diff --git a/doc/.tx/config b/doc/.tx/config index 250615d..5ddb722 100644 --- a/doc/.tx/config +++ b/doc/.tx/config @@ -697,9 +697,9 @@ file_filter = locale/<lang>/LC_MESSAGES/developer-guide/api/functions/TSContMute source_file = _build/locale/pot/developer-guide/api/functions/TSContMutexGet.en.pot source_lang = en -[apache-traffic-server-6x.developer-guide--api--functions--TSContSchedule_en] -file_filter = locale/<lang>/LC_MESSAGES/developer-guide/api/functions/TSContSchedule.en.po -source_file = _build/locale/pot/developer-guide/api/functions/TSContSchedule.en.pot +[apache-traffic-server-6x.developer-guide--api--functions--TSContScheduleOnPool_en] +file_filter = locale/<lang>/LC_MESSAGES/developer-guide/api/functions/TSContScheduleOnPool.en.po +source_file = _build/locale/pot/developer-guide/api/functions/TSContScheduleOnPool.en.pot source_lang = en [apache-traffic-server-6x.developer-guide--api--functions--TSDebug_en] diff --git a/doc/developer-guide/api/functions/TSContScheduleEvery.en.rst b/doc/developer-guide/api/functions/TSContScheduleEvery.en.rst deleted file mode 100644 index bc61392..0000000 --- a/doc/developer-guide/api/functions/TSContScheduleEvery.en.rst +++ /dev/null @@ -1,58 +0,0 @@ -.. Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed - with this work for additional information regarding copyright - ownership. The ASF licenses this file to you under the Apache - License, Version 2.0 (the "License"); you may not use this file - except in compliance with the License. You may obtain a copy of - the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied. See the License for the specific language governing - permissions and limitations under the License. - -.. include:: ../../../common.defs - -.. default-domain:: c - -TSContScheduleEvery -******************* - -Synopsis -======== - -.. code-block:: cpp - - #include <ts/ts.h> - -.. function:: TSAction TSContScheduleEvery(TSCont contp, TSHRTime every) - -Description -=========== - -Schedules :arg:`contp` to periodically run every :arg:`delay` milliseconds in the future. -This is approximate. The delay will be at least :arg:`delay` but possibly more. -Resolutions finer than roughly 5 milliseconds will not be effective. :arg:`contp` is -required to have a mutex, which is provided to :func:`TSContCreate`. - -The return value can be used to cancel the scheduled event via :func:`TSActionCancel`. This is -effective until the continuation :arg:`contp` is being dispatched. However, if it is scheduled on -another thread this can be problematic to be correctly timed. The return value can be checked with -:func:`TSActionDone` to see if the continuation ran before the return, which is possible if -:arg:`timeout` is `0`. Returns ``nullptr`` if thread affinity was cleared. - -TSContSchedule() or TSContScheduleEvery() will default to set the thread affinity to the calling thread -when no affinity is already set for example, using :func:`TSContThreadAffinitySet` - -Note that the TSContSchedule() family of API shall only be called from an ATS EThread. -Calling it from raw non-EThreads can result in unpredictable behavior. - -See Also -======== - -:doc:`TSContSchedule.en` -:doc:`TSContScheduleOnPool.en` -:doc:`TSContScheduleOnThread.en` diff --git a/doc/developer-guide/api/functions/TSContSchedule.en.rst b/doc/developer-guide/api/functions/TSContScheduleEveryOnPool.en.rst similarity index 56% rename from doc/developer-guide/api/functions/TSContSchedule.en.rst rename to doc/developer-guide/api/functions/TSContScheduleEveryOnPool.en.rst index 4dbb9f6..0116395 100644 --- a/doc/developer-guide/api/functions/TSContSchedule.en.rst +++ b/doc/developer-guide/api/functions/TSContScheduleEveryOnPool.en.rst @@ -18,8 +18,8 @@ .. default-domain:: c -TSContSchedule -************** +TSContScheduleEveryOnPool +************************* Synopsis ======== @@ -28,24 +28,25 @@ Synopsis #include <ts/ts.h> -.. function:: TSAction TSContSchedule(TSCont contp, TSHRTime timeout) +.. function:: TSAction TSContScheduleEveryOnPool(TSCont contp, TSHRTime every) Description =========== -Schedules :arg:`contp` to run :arg:`delay` milliseconds in the future. This is approximate. The delay -will be at least :arg:`delay` but possibly more. Resolutions finer than roughly 5 milliseconds will -not be effective. :arg:`contp` is required to have a mutex, which is provided to +Schedules :arg:`contp` to run :arg:`every` milliseconds, on a random thread that belongs to +:arg:`tp`. The :arg:`every` is an approximation, meaning it will be at least :arg:`every` +milliseconds but possibly more. Resolutions finer than roughly 5 milliseconds will not be +effective. Note that :arg:`contp` is required to have a mutex, which is provided to :func:`TSContCreate`. -The return value can be used to cancel the scheduled event via :func:`TSActionCancel`. This is -effective until the continuation :arg:`contp` is being dispatched. However, if it is scheduled on -another thread this can be problematic to be correctly timed. The return value can be checked with -:func:`TSActionDone` to see if the continuation ran before the return, which is possible if -:arg:`timeout` is `0`. Returns ``nullptr`` if thread affinity was cleared. +The return value can be used to cancel the scheduled event via :func:`TSActionCancel`. This +is effective until the continuation :arg:`contp` is being dispatched. However, if it is +scheduled on another thread this can be problematic to be correctly timed. The return value +can be checked with :func:`TSActionDone` to see if the continuation ran before the return, +which is possible if :arg:`timeout` is `0`. -TSContSchedule() or TSContScheduleEvery() will default to set the thread affinity to the calling thread -when no affinity is already set for example, using :func:`TSContThreadAffinitySet` +If :arg:`contp` has no thread affinity set, the thread it is now scheduled on will be set +as its thread affinity thread. Note that the TSContSchedule() family of API shall only be called from an ATS EThread. Calling it from raw non-EThreads can result in unpredictable behavior. @@ -53,6 +54,5 @@ Calling it from raw non-EThreads can result in unpredictable behavior. See Also ======== -:doc:`TSContScheduleEvery.en` :doc:`TSContScheduleOnPool.en` :doc:`TSContScheduleOnThread.en` diff --git a/doc/developer-guide/api/functions/TSContScheduleOnPool.en.rst b/doc/developer-guide/api/functions/TSContScheduleOnPool.en.rst index e1b3dbf..511894a 100644 --- a/doc/developer-guide/api/functions/TSContScheduleOnPool.en.rst +++ b/doc/developer-guide/api/functions/TSContScheduleOnPool.en.rst @@ -33,11 +33,16 @@ Synopsis Description =========== -Mostly the same as :func:`TSContSchedule`. Schedules :arg:`contp` on a random thread that belongs to :arg:`tp`. -If thread type of the thread specified by thread affinity is the same as :arg:`tp`, the :arg:`contp` will -be scheduled on the thread specified by thread affinity. +Schedules :arg:`contp` to run :arg:`timeout` milliseconds in the future, on a random thread that +belongs to :arg:`tp`. The :arg:`timeout` is an approximation, meaning it will be at least +:arg:`timeout` milliseconds but possibly more. Resolutions finer than roughly 5 milliseconds will +not be effective. Note that :arg:`contp` is required to have a mutex, which is provided to +:func:`TSContCreate`. -The continuation is scheduled for a particular thread selected from a group of similar threads, as indicated by :arg:`tp`. +The continuation is scheduled for a particular thread selected from a group of similar threads, +as indicated by :arg:`tp`. If :arg:`contp` already has an thread affinity set, and the thread +type of thread affinity is the same as :arg:`tp`, then :arg:`contp` will be scheduled on the +thread specified by thread affinity. =========================== ======================================================================================= Pool Properties @@ -54,6 +59,15 @@ called and continuations that use them have the same restrictions. ``TS_THREAD_P are threads that exist to perform long or blocking actions, although sufficiently long operation can impact system performance by blocking other continuations on the threads. +The return value can be used to cancel the scheduled event via :func:`TSActionCancel`. This is +effective until the continuation :arg:`contp` is being dispatched. However, if it is scheduled on +another thread this can be problematic to be correctly timed. The return value can be checked with +:func:`TSActionDone` to see if the continuation ran before the return, which is possible if +:arg:`timeout` is `0`. + +If :arg:`contp` has no thread affinity set, the thread it is now scheduled on will be set +as its thread affinity thread. + Note that the TSContSchedule() family of API shall only be called from an ATS EThread. Calling it from raw non-EThreads can result in unpredictable behavior. @@ -124,6 +138,5 @@ the same continuation on two different threads of the same type. See Also ======== -:doc:`TSContSchedule.en` -:doc:`TSContScheduleEvery.en` +:doc:`TSContScheduleEveryOnPool.en` :doc:`TSContScheduleOnThread.en` diff --git a/doc/developer-guide/api/functions/TSContScheduleOnThread.en.rst b/doc/developer-guide/api/functions/TSContScheduleOnThread.en.rst index 0f91166..41148a9 100644 --- a/doc/developer-guide/api/functions/TSContScheduleOnThread.en.rst +++ b/doc/developer-guide/api/functions/TSContScheduleOnThread.en.rst @@ -33,7 +33,19 @@ Synopsis Description =========== -Mostly the same as :func:`TSContSchedule`. Schedules :arg:`contp` on :arg:`ethread`. +Schedules :arg:`contp` to run :arg:`timeout` milliseconds in the future, on the thread specified by +:arg:`ethread`. The :arg:`timeout` is an approximation, meaning it will be at least :arg:`timeout` +milliseconds but possibly more. Resolutions finer than roughly 5 milliseconds will not be effective. +Note that :arg:`contp` is required to have a mutex, which is provided to :func:`TSContCreate`. + +The return value can be used to cancel the scheduled event via :func:`TSActionCancel`. This is +effective until the continuation :arg:`contp` is being dispatched. However, if it is scheduled on +another thread this can be problematic to be correctly timed. The return value can be checked with +:func:`TSActionDone` to see if the continuation ran before the return, which is possible if +:arg:`timeout` is `0`. + +If :arg:`contp` has no thread affinity set, the thread it is now scheduled on will be set +as its thread affinity thread. Note that the TSContSchedule() family of API shall only be called from an ATS EThread. Calling it from raw non-EThreads can result in unpredictable behavior. @@ -41,6 +53,5 @@ Calling it from raw non-EThreads can result in unpredictable behavior. See Also ======== -:doc:`TSContSchedule.en` -:doc:`TSContScheduleEvery.en` :doc:`TSContScheduleOnPool.en` +:doc:`TSContScheduleEveryOnPool.en` diff --git a/doc/developer-guide/api/functions/TSContThreadAffinitySet.en.rst b/doc/developer-guide/api/functions/TSContThreadAffinitySet.en.rst index e78979c..64417de 100644 --- a/doc/developer-guide/api/functions/TSContThreadAffinitySet.en.rst +++ b/doc/developer-guide/api/functions/TSContThreadAffinitySet.en.rst @@ -34,10 +34,10 @@ Description =========== Set the thread affinity of continuation :arg:`contp` to :arg:`ethread`. Future calls to -:func:`TSContSchedule`, and :func:`TSContScheduleOnPool` that has the same type as :arg:`ethread` +:func:`TSContScheduleOnPool`, and :func:`TSContScheduleOnPool` that has the same type as :arg:`ethread` will schedule the continuation on :arg:`ethread`, rather than an arbitrary thread of that type. -:func:`TSContSchedule` and :func:``TSContScheduleEvery` will default the affinity to calling thread +:func:`TSContScheduleOnPool` and :func:`TSContScheduleEveryOnPool` will default the affinity to calling thread when invoked without explicitly setting the thread affinity. Return Values diff --git a/doc/developer-guide/plugins/continuations/activating-continuations.en.rst b/doc/developer-guide/plugins/continuations/activating-continuations.en.rst index 6b4135f..8ff2448 100644 --- a/doc/developer-guide/plugins/continuations/activating-continuations.en.rst +++ b/doc/developer-guide/plugins/continuations/activating-continuations.en.rst @@ -23,7 +23,7 @@ Activating Continuations ************************ Continuations are activated when they receive an event or by -``TSContSchedule`` (which schedules a continuation to receive an event). +``TSContScheduleOnPool`` (which schedules a continuation to receive an event). Continuations might receive an event because: - Your plugin calls ``TSContCall`` diff --git a/doc/developer-guide/plugins/continuations/index.en.rst b/doc/developer-guide/plugins/continuations/index.en.rst index 94bd132..41722b1 100644 --- a/doc/developer-guide/plugins/continuations/index.en.rst +++ b/doc/developer-guide/plugins/continuations/index.en.rst @@ -54,7 +54,7 @@ one of the following: transactions uses ``TSContDataSet/Get`` - uses ``TSCacheXXX``, ``TSNetXXX``, ``TSHostLookup``, or - ``TSContSchedule`` APIs + ``TSContScheduleOnPool`` APIs Before being activated, a caller must grab the continuation's mutex. This requirement makes it possible for a continuation's handler function diff --git a/doc/developer-guide/plugins/continuations/writing-handler-functions.en.rst b/doc/developer-guide/plugins/continuations/writing-handler-functions.en.rst index 7250f25..8fafbfd 100644 --- a/doc/developer-guide/plugins/continuations/writing-handler-functions.en.rst +++ b/doc/developer-guide/plugins/continuations/writing-handler-functions.en.rst @@ -95,7 +95,6 @@ Event Event Sender :data:`TS_EVENT_CACHE_LOOKUP_COMPLETE` :data:`TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK` :type:`TSHttpTxn` :data:`TS_EVENT_IMMEDIATE` :func:`TSVConnClose` :func:`TSVIOReenable` - :func:`TSContSchedule` :func:`TSContScheduleOnPool` :func:`TSContScheduleOnThread` :data:`TS_EVENT_IMMEDIATE` :data:`TS_HTTP_REQUEST_TRANSFORM_HOOK` @@ -113,8 +112,7 @@ Event Event Sender :func:`TSHttpTxnServerIntercept` :func:`TSHttpTxnIntercept` :data:`TS_EVENT_HOST_LOOKUP` :func:`TSHostLookup` :type:`TSHostLookupResult` -:data:`TS_EVENT_TIMEOUT` :func:`TSContSchedule` - :func:`TSContScheduleOnPool` +:data:`TS_EVENT_TIMEOUT` :func:`TSContScheduleOnPool` :func:`TSContScheduleOnThread` :data:`TS_EVENT_ERROR` :data:`TS_EVENT_VCONN_READ_READY` :func:`TSVConnRead` :type:`TSVIO` @@ -137,6 +135,5 @@ The continuation functions are listed below: - :func:`TSContDataSet` - :func:`TSContDestroy` - :func:`TSContMutexGet` -- :func:`TSContSchedule` - :func:`TSContScheduleOnPool` - :func:`TSContScheduleOnThread` diff --git a/doc/locale/ja/LC_MESSAGES/developer-guide/api/functions/TSContSchedule.en.po b/doc/locale/ja/LC_MESSAGES/developer-guide/api/functions/TSContScheduleOnPool.en.po similarity index 81% rename from doc/locale/ja/LC_MESSAGES/developer-guide/api/functions/TSContSchedule.en.po rename to doc/locale/ja/LC_MESSAGES/developer-guide/api/functions/TSContScheduleOnPool.en.po index e35760b..d41276f 100644 --- a/doc/locale/ja/LC_MESSAGES/developer-guide/api/functions/TSContSchedule.en.po +++ b/doc/locale/ja/LC_MESSAGES/developer-guide/api/functions/TSContScheduleOnPool.en.po @@ -29,18 +29,18 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.1.1\n" -#: ../../developer-guide/api/functions/TSContSchedule.en.rst:32 +#: ../../developer-guide/api/functions/TSContScheduleOnPool.en.rst:32 msgid "Description" msgstr "解説" -#: ../../developer-guide/api/functions/TSContSchedule.en.rst:25 +#: ../../developer-guide/api/functions/TSContScheduleOnPool.en.rst:25 msgid "Synopsis" msgstr "概要" -#: ../../developer-guide/api/functions/TSContSchedule.en.rst:22 -msgid "TSContSchedule" +#: ../../developer-guide/api/functions/TSContScheduleOnPool.en.rst:22 +msgid "TSContScheduleOnPool" msgstr "" -#: ../../developer-guide/api/functions/TSContSchedule.en.rst:27 +#: ../../developer-guide/api/functions/TSContScheduleOnPool.en.rst:27 msgid "`#include <ts/ts.h>`" msgstr "`#include <ts/ts.h>`" diff --git a/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/activating-continuations.en.po b/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/activating-continuations.en.po index 5e8bbaa..928db61 100644 --- a/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/activating-continuations.en.po +++ b/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/activating-continuations.en.po @@ -48,10 +48,10 @@ msgstr "" #: ../../developer-guide/plugins/continuations/activating-continuations.en.rst:25 msgid "" "Continuations are activated when they receive an event or by " -"``TSContSchedule`` (which schedules a continuation to receive an event). " +"``TSContScheduleOnPool`` (which schedules a continuation to receive an event). " "Continuations might receive an event because:" msgstr "" -"継続は、イベントを受け取った際か ``TSContSchedule`` (イベントを受け取るため" +"継続は、イベントを受け取った際か ``TSContScheduleOnPool`` (イベントを受け取るため" "継続をスケジュールする関数)によってアクティベートされます。下記の理由により" "継続がイベントを受け取る可能性があります。 :" diff --git a/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/index.en.po b/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/index.en.po index b2595d9..b51a939 100644 --- a/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/index.en.po +++ b/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/index.en.po @@ -220,8 +220,8 @@ msgstr "" #: ../../developer-guide/plugins/continuations/index.en.rst:56 msgid "" -"uses ``TSCacheXXX``, ``TSNetXXX``, ``TSHostLookup``, or ``TSContSchedule`` " +"uses ``TSCacheXXX``, ``TSNetXXX``, ``TSHostLookup``, or ``TSContScheduleOnPool`` " "APIs" msgstr "" -"``TSCacheXXX``, ``TSNetXXX``, ``TSHostLookup``, もしくは ``TSContSchedule`` " +"``TSCacheXXX``, ``TSNetXXX``, ``TSHostLookup``, もしくは ``TSContScheduleOnPool`` " "API を使用する。" diff --git a/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/writing-handler-functions.en.po b/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/writing-handler-functions.en.po index bdc58ce..df4b712 100644 --- a/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/writing-handler-functions.en.po +++ b/doc/locale/ja/LC_MESSAGES/developer-guide/plugins/continuations/writing-handler-functions.en.po @@ -229,8 +229,8 @@ msgid ":data:`TS_EVENT_IMMEDIATE`" msgstr ":data:`TS_EVENT_IMMEDIATE`" #: ../../../developer-guide/plugins/continuations/writing-handler-functions.en.rst:90 -msgid ":func:`TSVConnClose` :func:`TSVIOReenable` :func:`TSContSchedule`" -msgstr ":func:`TSVConnClose` :func:`TSVIOReenable` :func:`TSContSchedule`" +msgid ":func:`TSVConnClose` :func:`TSVIOReenable` :func:`TSContScheduleOnPool`" +msgstr ":func:`TSVConnClose` :func:`TSVIOReenable` :func:`TSContScheduleOnPool`" #: ../../../developer-guide/plugins/continuations/writing-handler-functions.en.rst:93 msgid ":data:`TS_HTTP_REQUEST_TRANSFORM_HOOK`" @@ -329,8 +329,8 @@ msgstr ":data:`TS_EVENT_TIMEOUT`" #: ../../../developer-guide/plugins/continuations/writing-handler-functions.en.rst:108 #: ../../../developer-guide/plugins/continuations/writing-handler-functions.en.rst:130 -msgid ":func:`TSContSchedule`" -msgstr ":func:`TSContSchedule`" +msgid ":func:`TSContScheduleOnPool`" +msgstr ":func:`TSContScheduleOnPool`" #: ../../../developer-guide/plugins/continuations/writing-handler-functions.en.rst:109 msgid ":data:`TS_EVENT_ERROR`" diff --git a/include/ts/ts.h b/include/ts/ts.h index 1e82590..0cfa624 100644 --- a/include/ts/ts.h +++ b/include/ts/ts.h @@ -1193,10 +1193,8 @@ tsapi TSCont TSContCreate(TSEventFunc funcp, TSMutex mutexp); tsapi void TSContDestroy(TSCont contp); tsapi void TSContDataSet(TSCont contp, void *data); tsapi void *TSContDataGet(TSCont contp); -tsapi TSAction TSContSchedule(TSCont contp, TSHRTime timeout); tsapi TSAction TSContScheduleOnPool(TSCont contp, TSHRTime timeout, TSThreadPool tp); tsapi TSAction TSContScheduleOnThread(TSCont contp, TSHRTime timeout, TSEventThread ethread); -tsapi TSAction TSContScheduleEvery(TSCont contp, TSHRTime every /* millisecs */); tsapi TSAction TSContScheduleEveryOnPool(TSCont contp, TSHRTime every /* millisecs */, TSThreadPool tp); tsapi TSAction TSContScheduleEveryOnThread(TSCont contp, TSHRTime every /* millisecs */, TSEventThread ethread); tsapi TSReturnCode TSContThreadAffinitySet(TSCont contp, TSEventThread ethread); diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc index 799df56..1efa887 100644 --- a/src/traffic_server/InkAPI.cc +++ b/src/traffic_server/InkAPI.cc @@ -4513,40 +4513,6 @@ TSContDataGet(TSCont contp) } TSAction -TSContSchedule(TSCont contp, TSHRTime timeout) -{ - sdk_assert(sdk_sanity_check_iocore_structure(contp) == TS_SUCCESS); - - /* ensure we are on a EThread */ - sdk_assert(sdk_sanity_check_null_ptr((void *)this_ethread()) == TS_SUCCESS); - - FORCE_PLUGIN_SCOPED_MUTEX(contp); - - INKContInternal *i = reinterpret_cast<INKContInternal *>(contp); - - if (ink_atomic_increment(static_cast<int *>(&i->m_event_count), 1) < 0) { - ink_assert(!"not reached"); - } - - EThread *eth = i->getThreadAffinity(); - if (eth == nullptr) { - eth = this_ethread(); - i->setThreadAffinity(eth); - } - - TSAction action; - if (timeout == 0) { - action = reinterpret_cast<TSAction>(eth->schedule_imm(i)); - } else { - action = reinterpret_cast<TSAction>(eth->schedule_in(i, HRTIME_MSECONDS(timeout))); - } - - /* This is a hack. Should be handled in ink_types */ - action = (TSAction)((uintptr_t)action | 0x1); - return action; -} - -TSAction TSContScheduleOnPool(TSCont contp, TSHRTime timeout, TSThreadPool tp) { sdk_assert(sdk_sanity_check_iocore_structure(contp) == TS_SUCCESS); @@ -4627,35 +4593,6 @@ TSContScheduleOnThread(TSCont contp, TSHRTime timeout, TSEventThread ethread) } TSAction -TSContScheduleEvery(TSCont contp, TSHRTime every /* millisecs */) -{ - sdk_assert(sdk_sanity_check_iocore_structure(contp) == TS_SUCCESS); - - /* ensure we are on a EThread */ - sdk_assert(sdk_sanity_check_null_ptr((void *)this_ethread()) == TS_SUCCESS); - - FORCE_PLUGIN_SCOPED_MUTEX(contp); - - INKContInternal *i = reinterpret_cast<INKContInternal *>(contp); - - if (ink_atomic_increment(static_cast<int *>(&i->m_event_count), 1) < 0) { - ink_assert(!"not reached"); - } - - EThread *eth = i->getThreadAffinity(); - if (eth == nullptr) { - eth = this_ethread(); - i->setThreadAffinity(eth); - } - - TSAction action = reinterpret_cast<TSAction>(eth->schedule_every(i, HRTIME_MSECONDS(every))); - - /* This is a hack. Should be handled in ink_types */ - action = (TSAction)((uintptr_t)action | 0x1); - return action; -} - -TSAction TSContScheduleEveryOnPool(TSCont contp, TSHRTime every, TSThreadPool tp) { sdk_assert(sdk_sanity_check_iocore_structure(contp) == TS_SUCCESS); diff --git a/tests/gold_tests/cont_schedule/gold/schedule.gold b/tests/gold_tests/cont_schedule/gold/schedule.gold deleted file mode 100644 index 7b5d1f6..0000000 --- a/tests/gold_tests/cont_schedule/gold/schedule.gold +++ /dev/null @@ -1,4 +0,0 @@ -`` -``(TSContSchedule_test.check) pass [should be the same thread] -``(TSContSchedule_test.check) pass [should not be the same thread] -`` diff --git a/tests/gold_tests/cont_schedule/schedule.test.py b/tests/gold_tests/cont_schedule/schedule.test.py deleted file mode 100644 index c82db17..0000000 --- a/tests/gold_tests/cont_schedule/schedule.test.py +++ /dev/null @@ -1,49 +0,0 @@ -''' -''' -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import os - -Test.Summary = 'Test TSContSchedule API' -Test.ContinueOnFail = True - -# Define default ATS -ts = Test.MakeATSProcess('ts') - -Test.testName = 'Test TSContSchedule API' - -ts.Disk.records_config.update({ - 'proxy.config.exec_thread.autoconfig': 0, - 'proxy.config.exec_thread.autoconfig.scale': 1.5, - 'proxy.config.exec_thread.limit': 32, - 'proxy.config.accept_threads': 1, - 'proxy.config.task_threads': 2, - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'TSContSchedule_test' -}) - -# Load plugin -Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 'cont_schedule.cc'), ts) - -# www.example.com Host -tr = Test.AddTestRun() -tr.Processes.Default.Command = 'printf "Test TSContSchedule API"' -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.StartBefore(ts) -ts.Streams.All = "gold/schedule.gold" -ts.Streams.All += Testers.ExcludesExpression('fail', 'should not contain "fail"') diff --git a/tests/tools/plugins/cont_schedule.cc b/tests/tools/plugins/cont_schedule.cc index cab71f1..493c68d 100644 --- a/tests/tools/plugins/cont_schedule.cc +++ b/tests/tools/plugins/cont_schedule.cc @@ -42,8 +42,6 @@ static TSEventThread thread_2 = nullptr; static TSCont contp_1 = nullptr; static TSCont contp_2 = nullptr; -static int TSContSchedule_handler_1(TSCont contp, TSEvent event, void *edata); -static int TSContSchedule_handler_2(TSCont contp, TSEvent event, void *edata); static int TSContScheduleOnPool_handler_1(TSCont contp, TSEvent event, void *edata); static int TSContScheduleOnPool_handler_2(TSCont contp, TSEvent event, void *edata); static int TSContScheduleOnThread_handler_1(TSCont contp, TSEvent event, void *edata); @@ -51,71 +49,6 @@ static int TSContScheduleOnThread_handler_2(TSCont contp, TSEvent event, void *e static int TSContThreadAffinity_handler(TSCont contp, TSEvent event, void *edata); static int -TSContSchedule_handler_1(TSCont contp, TSEvent event, void *edata) -{ - TSDebug(DEBUG_TAG_HDL, "TSContSchedule handler 1 thread [%p]", TSThreadSelf()); - if (thread_1 == nullptr) { - // First time entering this handler, before everything else starts. - thread_1 = TSEventThreadSelf(); - - // Set the affinity of contp_2 to thread_1, and schedule it twice. - // Since it's on the same thread, we don't need a delay. - TSDebug(DEBUG_TAG_HDL, "[%s] scheduling continuation", plugin_name); - TSContThreadAffinitySet(contp_2, thread_1); - TSContSchedule(contp_2, 0); - TSContSchedule(contp_2, 0); - } else if (thread_2 == nullptr) { - TSDebug(DEBUG_TAG_CHK, "fail [schedule delay not applied]"); - } else { - // Second time in here, should be after the two scheduled handler_2 runs. - // Since handler_1 has no affinity set, we should be on a different thread now. - // Also, thread_2 should be the same as thread_1, since thread_1 was set as - // affinity for handler_2. - if (thread_2 != TSEventThreadSelf() && thread_2 == thread_1) { - TSDebug(DEBUG_TAG_CHK, "pass [should not be the same thread]"); - } else { - TSDebug(DEBUG_TAG_CHK, "fail [on the same thread]"); - } - } - return 0; -} - -static int -TSContSchedule_handler_2(TSCont contp, TSEvent event, void *edata) -{ - TSDebug(DEBUG_TAG_HDL, "TSContSchedule handler 2 thread [%p]", TSThreadSelf()); - if (thread_2 == nullptr) { - // First time in this handler, should get here after handler_1, - // and also record the thread id. - thread_2 = TSEventThreadSelf(); - } else if (thread_2 == TSEventThreadSelf()) { - // Second time in here, since the affinity is set to thread_1, we should be - // on the same thread as last time. - TSDebug(DEBUG_TAG_CHK, "pass [should be the same thread]"); - } else { - TSDebug(DEBUG_TAG_CHK, "fail [not the same thread]"); - } - return 0; -} - -void -TSContSchedule_test() -{ - contp_1 = TSContCreate(TSContSchedule_handler_1, TSMutexCreate()); - contp_2 = TSContCreate(TSContSchedule_handler_2, TSMutexCreate()); - - if (contp_1 == nullptr || contp_2 == nullptr) { - TSDebug(DEBUG_TAG_SCHD, "[%s] could not create continuation", plugin_name); - abort(); - } else { - TSDebug(DEBUG_TAG_SCHD, "[%s] scheduling continuation", plugin_name); - TSContScheduleOnPool(contp_1, 0, TS_THREAD_POOL_NET); - TSContThreadAffinityClear(contp_1); - TSContScheduleOnPool(contp_1, 200, TS_THREAD_POOL_NET); - } -} - -static int TSContScheduleOnPool_handler_1(TSCont contp, TSEvent event, void *edata) { // This runs on ET_NET threads. @@ -180,7 +113,7 @@ TSContScheduleOnPool_test() static int TSContScheduleOnThread_handler_1(TSCont contp, TSEvent event, void *edata) { - // Mostly same as TSContSchedule_handler_1, no need to set affinity + // Mostly same as TSContScheduleOnPool_handler_1, no need to set affinity // since we are scheduling directly on to a thread. TSDebug(DEBUG_TAG_HDL, "TSContScheduleOnThread handler 1 thread [%p]", TSThreadSelf()); if (thread_1 == nullptr) { @@ -280,15 +213,12 @@ LifecycleHookTracer(TSCont contp, TSEvent event, void *edata) if (event == TS_EVENT_LIFECYCLE_TASK_THREADS_READY) { switch (test_flag) { case 1: - TSContSchedule_test(); - break; - case 2: TSContScheduleOnPool_test(); break; - case 3: + case 2: TSContScheduleOnThread_test(); break; - case 4: + case 3: TSContThreadAffinity_test(); break; default: @@ -301,20 +231,17 @@ LifecycleHookTracer(TSCont contp, TSEvent event, void *edata) void TSPluginInit(int argc, const char *argv[]) { - if (argc == 1) { - TSDebug(DEBUG_TAG_INIT, "initializing plugin for testing TSContSchedule"); - test_flag = 1; - } else if (argc == 2) { + if (argc == 2) { int len = strlen(argv[1]); if (len == 4 && strncmp(argv[1], "pool", 4) == 0) { TSDebug(DEBUG_TAG_INIT, "initializing plugin for testing TSContScheduleOnPool"); - test_flag = 2; + test_flag = 1; } else if (len == 6 && strncmp(argv[1], "thread", 6) == 0) { TSDebug(DEBUG_TAG_INIT, "initializing plugin for testing TSContScheduleOnThread"); - test_flag = 3; + test_flag = 2; } else if (len == 8 && strncmp(argv[1], "affinity", 8) == 0) { TSDebug(DEBUG_TAG_INIT, "initializing plugin for testing TSContThreadAffinity"); - test_flag = 4; + test_flag = 3; } else { goto Lerror; }