bryancall commented on code in PR #14084:
URL: https://github.com/apache/trafficserver/pull/14084#discussion_r4606222063


##########
src/tscore/unit_tests/test_ink_file.cc:
##########
@@ -0,0 +1,71 @@
+/** @file
+
+    test ink_file.h - file helpers
+
+    @section license License
+
+    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 "tscore/ink_file.h"
+#include <catch2/catch_test_macros.hpp>
+
+#include <cstring>
+#include <fcntl.h>
+#include <unistd.h>
+
+TEST_CASE("ink_file_fd_writestring returns the number of bytes written", 
"[ink_file]")

Review Comment:
   Good point, the name only covered half of what it checked. I split it in 
[2042f4048a](https://github.com/apache/trafficserver/pull/14084/commits/2042f4048ac23b46539e760d09fb599f65d7398d):
 one test checks the return value and a second checks that the whole string 
reaches the pipe.



##########
plugins/lua/ts_lua_transform.cc:
##########
@@ -189,12 +189,6 @@ ts_lua_client_handler(TSCont contp, 
ts_lua_http_transform_ctx *transform_ctx, TS
       } else {
         lua_pushinteger(L, 0); /* second param, data not finish */
       }
-    } else {
-      lua_pushlightuserdata(L, transform_ctx);
-      lua_rawget(L, LUA_GLOBALSINDEX); /* push function */
-
-      lua_pushlstring(L, "", 0);
-      lua_pushinteger(L, 1); /* second param, data finished */
     }

Review Comment:
   You're right that the check inside the loop could only be true there, so I 
hoisted that block in 
[4d5132933b](https://github.com/apache/trafficserver/pull/14084/commits/4d5132933bcce1d130877d4b4374c275dc43ceec)
 and dropped the earlier break it made redundant. I put the assert right after 
the `towrite == 0` break rather than where `empty_input` is computed, because 
`empty_input` can still be 1: a null input buffer means the write side was shut 
down (the null_transform example handles the same case). In that case `towrite` 
is 0, so the loop exits before the assert and the client hook is not called, 
the same as before this PR.



##########
src/iocore/net/UnixNetProcessor.cc:
##########
@@ -295,9 +295,6 @@ UnixNetProcessor::init_socks()
       Warning("We can not have accept_enabled and socks_needed turned off"
               " disabling Socks accept\n");
       socks_conf_stuff->accept_enabled = 0;
-    } else {
-      // this is sslNetprocessor
-      socks_conf_stuff = netProcessor.socks_conf_stuff;

Review Comment:
   Good question, I dug into the history. The inheritance in that comment is 
class inheritance: `SSLNetProcessor` derives from `UnixNetProcessor`. This 
block came in with the initial import in 2009, when it sat in 
`UnixNetProcessor::start()`, which `SSLNetProcessor::start()` also called. My 
best guess is the `else` was meant for the outer `if`, so the SSL processor 
would reuse the config the plain one loaded, from a time before the member was 
shared.
   
   It has been shared since at least that import: `socks_conf_stuff` is a 
static member of `NetProcessor` 
([NetProcessor.h#L153](https://github.com/apache/trafficserver/blob/bdc3c5073507988dd14fd270f804c967cc84bcb9/include/iocore/net/NetProcessor.h#L153),
 "shared by regular netprocessor and ssl netprocessor"), so `socks_conf_stuff` 
and `netProcessor.socks_conf_stuff` are the same variable and the line assigned 
the pointer to itself. The SSL processor sees the same config with or without 
it. Since [#5398](https://github.com/apache/trafficserver/pull/5398) (2019), 
`init_socks()` is also only called once, on `netProcessor` 
([traffic_server.cc#L2439](https://github.com/apache/trafficserver/blob/bdc3c5073507988dd14fd270f804c967cc84bcb9/src/traffic_server/traffic_server.cc#L2439)).
   
   To be sure, I compiled `UnixNetProcessor.cc` with and without the `else` at 
-O2, and the generated `init_socks()` is identical, so removing it doesn't 
bring anything back.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to