Skip to content

Commit 80cee4b

Browse files
committed
Au test spawning a blocking thread in a transaction hook continuation.
Getting a result from it, without blocking event task.
1 parent 66412f0 commit 80cee4b

File tree

13 files changed

+391
-14
lines changed

13 files changed

+391
-14
lines changed

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Copyright (C) 2013 GoDaddy Operating Company, LLC
3535

3636
~~~
3737

38-
lib/cppapi developed by LinkedIn
38+
include/tscpp/api developed by LinkedIn
3939
Copyright (c) 2013 LinkedIn
4040

4141
~~~

build/plugins.mk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ TS_PLUGIN_LD_FLAGS = \
2525
-export-symbols-regex '^(TSRemapInit|TSRemapDone|TSRemapDoRemap|TSRemapNewInstance|TSRemapDeleteInstance|TSRemapOSResponse|TSPluginInit|TSRemapPreConfigReload|TSRemapPostConfigReload)$$'
2626

2727
TS_PLUGIN_CPPFLAGS = \
28-
-I$(abs_top_builddir)/proxy/api \
29-
-I$(abs_top_srcdir)/proxy/api \
30-
-I$(abs_top_srcdir)/include/cppapi/include \
31-
-I$(abs_top_builddir)/lib/cppapi/include \
3228
-I$(abs_top_srcdir)/include \
3329
-I$(abs_top_srcdir)/lib
3430

doc/developer-guide/api/functions/TSHttpHookAdd.en.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,34 @@ function for callback amounts to adding the function to a hook. You
4444
can register your plugin to be called back for every single
4545
transaction, or for specific transactions only.
4646

47-
HTTP :term:`transaction` hooks are set on a global basis using the function
48-
:func:`TSHttpHookAdd`. This means that the continuation specified
49-
as the parameter to :func:`TSHttpHookAdd` is called for every
50-
transaction. :func:`TSHttpHookAdd` must only be called from
51-
:func:`TSPluginInit` or :func:`TSRemapInit`.
47+
HTTP :term:`transaction` and :term:`session` hooks are set on a
48+
global basis using the function :func:`TSHttpHookAdd`. This means
49+
that the continuation specified as the parameter to :func:`TSHttpHookAdd`
50+
is called for every transaction. :func:`TSHttpHookAdd` must only be called from
51+
:func:`TSPluginInit` or :func:`TSRemapInit`. Continuations set on a
52+
global hook will run before any continuations set on the session/transaction
53+
hook with the same hook ID.
5254

5355
:func:`TSHttpSsnHookAdd` adds :arg:`contp` to
5456
the end of the list of HTTP :term:`session` hooks specified by :arg:`id`.
5557
This means that :arg:`contp` is called back for every transaction
5658
within the session, at the point specified by the hook ID. Since
5759
:arg:`contp` is added to a session, it is not possible to call
5860
:func:`TSHttpSsnHookAdd` from the plugin initialization routine;
59-
the plugin needs a handle to an HTTP session.
61+
the plugin needs a handle to an HTTP session. Continuations set on a
62+
session hook will run before any continuations set on the transaction
63+
hook with the same hook ID. This fucnction can be called from handler
64+
functions of continuations on a global per-session hook, including for
65+
the session hook with the same ID.
6066

6167
:func:`TSHttpTxnHookAdd` adds :arg:`contp`
6268
to the end of the list of HTTP transaction hooks specified by
6369
:arg:`id`. Since :arg:`contp` is added to a transaction, it is
6470
not possible to call :func:`TSHttpTxnHookAdd` from the plugin
6571
initialization routine but only when the plugin has a handle to an
66-
HTTP transaction.
72+
HTTP transaction. This fucnction can be called from handler
73+
functions of continuations on a global or session per-transaction
74+
hook, including the for transaction hook with the same ID.
6775

6876
A single continuation can be attached to multiple hooks at the same time.
6977
It is good practice to conserve resources by reusing hooks in this way

doc/developer-guide/plugins/continuations/writing-handler-functions.en.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,10 @@ The continuation functions are listed below:
140140
- :func:`TSContSchedule`
141141
- :func:`TSContScheduleOnPool`
142142
- :func:`TSContScheduleOnThread`
143+
144+
When a handler function blocks, it blocks the event thread running it. This blocks all the continuations (internal ones
145+
along with those of plugins) in the event thread's queue. This may increase the worst-case latency for HTTP request
146+
processing. If there is enough blocking, this could increase CPU idle time, which may reduce proxy throughput. The
147+
Au test **polite_hook_wait** illustrates a method for using dynamic threading to do a blocking call without blocking
148+
any handler function. But the overhead of this method may cancel out the performance improvement, if blocking times
149+
are short.

include/tscpp/api/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ library_include_HEADERS = \
2222
AsyncHttpFetch.h \
2323
AsyncTimer.h \
2424
CaseInsensitiveStringComparator.h \
25+
Cleanup.h \
2526
ClientRequest.h \
2627
Continuation.h \
2728
GlobalPlugin.h \

plugins/experimental/fastcgi/src/Readme

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ tsxs -o ats_fastcgi.so \
3232
-c ats_fastcgi.cc \
3333
-L "${ats_dir}lib/" \
3434
-I "${ats_dir}lib" \
35-
-I "${ats_dir}lib/cppapi/include/" \
3635
-c ats_fcgi_client.cc \
3736
-latscppapi
3837

plugins/xdebug/xdebug.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "tscore/ink_defs.h"
3636
#include "tscpp/util/PostScript.h"
3737
#include "tscpp/util/TextView.h"
38-
#include "Cleanup.h"
38+
#include "tscpp/api/Cleanup.h"
3939

4040
namespace
4141
{

tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ AM_LDFLAGS += -rpath $(abs_builddir)
3333
include gold_tests/bigobj/Makefile.inc
3434
include gold_tests/continuations/plugins/Makefile.inc
3535
include gold_tests/chunked_encoding/Makefile.inc
36+
include gold_tests/pluginTest/polite_hook_wait/Makefile.inc
3637
include gold_tests/pluginTest/tsapi/Makefile.inc
3738
include gold_tests/timeout/Makefile.inc
3839
include gold_tests/tls/Makefile.inc
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
noinst_LTLIBRARIES += gold_tests/pluginTest/polite_hook_wait/polite_hook_wait.la
18+
gold_tests_pluginTest_polite_hook_wait_polite_hook_wait_la_SOURCES = gold_tests/pluginTest/polite_hook_wait/polite_hook_wait.cc

0 commit comments

Comments
 (0)