MCPcopy Create free account
hub / github.com/apache/trafficserver / handle_transform

Function handle_transform

tests/tools/plugins/tunnel_transform.cc:69–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69static void
70handle_transform(TSCont contp, bool forward)
71{
72 TSVConn output_conn;
73 TSIOBuffer buf_test;
74 TSVIO input_vio;
75 MyData *data;
76 int64_t towrite;
77
78 Dbg(plugin_ctl, "Entering handle_transform()");
79 /* Get the output (downstream) vconnection where we'll write data to. */
80
81 output_conn = TSTransformOutputVConnGet(contp);
82
83 /* Get the write VIO for the write operation that was performed on
84 * ourself. This VIO contains the buffer that we are to read from
85 * as well as the continuation we are to call when the buffer is
86 * empty. This is the input VIO (the write VIO for the upstream
87 * vconnection).
88 */
89 input_vio = TSVConnWriteVIOGet(contp);
90
91 /* Get our data structure for this operation. The private data
92 * structure contains the output VIO and output buffer. If the
93 * private data structure pointer is null, then we'll create it
94 * and initialize its internals.
95 */
96 data = static_cast<decltype(data)>(TSContDataGet(contp));
97 if (!data) {
98 data = my_data_alloc();
99 data->output_buffer = TSIOBufferCreate();
100 data->output_reader = TSIOBufferReaderAlloc(data->output_buffer);
101 Dbg(plugin_ctl, "\tWriting %" PRId64 " bytes on VConn", TSVIONBytesGet(input_vio));
102 data->output_vio = TSVConnWrite(output_conn, contp, data->output_reader, INT64_MAX);
103 TSContDataSet(contp, data);
104 }
105
106 /* We also check to see if the input VIO's buffer is non-null. A
107 * null buffer indicates that the write operation has been
108 * shutdown and that the upstream continuation does not want us to send any
109 * more WRITE_READY or WRITE_COMPLETE events. For this simplistic
110 * transformation that means we're done. In a more complex
111 * transformation we might have to finish writing the transformed
112 * data to our output connection.
113 */
114 buf_test = TSVIOBufferGet(input_vio);
115
116 if (!buf_test) {
117 TSVIONBytesSet(data->output_vio, TSVIONDoneGet(input_vio));
118 TSVIOReenable(data->output_vio);
119 return;
120 }
121
122 /* Determine how much data we have left to read. For this null
123 * transform plugin this is also the amount of data we have left
124 * to write to the output connection.
125 */
126 towrite = TSVIONTodoGet(input_vio);

Callers 1

null_transformFunction · 0.70

Calls 15

TSVConnWriteVIOGetFunction · 0.85
TSContDataGetFunction · 0.85
TSIOBufferCreateFunction · 0.85
TSIOBufferReaderAllocFunction · 0.85
TSVIONBytesGetFunction · 0.85
TSVConnWriteFunction · 0.85
TSContDataSetFunction · 0.85
TSVIOBufferGetFunction · 0.85
TSVIONBytesSetFunction · 0.85
TSVIONDoneGetFunction · 0.85
TSVIOReenableFunction · 0.85

Tested by

no test coverage detected