imbajin commented on code in PR #3105:
URL: https://github.com/apache/hugegraph/pull/3105#discussion_r3645160690
##########
hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh:
##########
@@ -79,15 +79,65 @@ function process_id() {
return "$pid"
}
-# check the port of rest server is occupied
+# check whether the REST server port is occupied
function check_port() {
- local port=$(echo "$1" | sed 's|.*:||' | sed 's|/.*||')
- if ! command_available "lsof"; then
- echo "Required lsof but it is unavailable"
- exit 1
+ local url="$1"
+ local host
+ local port
+
+ # Extract port: last colon-delimited segment, strip trailing path
+ port=$(echo "$url" | sed 's|.*:||' | sed 's|/.*||')
+ if [[ -z "$port" ]]; then
+ return 0
fi
- lsof -i :"$port" >/dev/null
- if [ $? -eq 0 ]; then
+
+ if ! [[ "$port" =~ ^[0-9]+$ ]] || (( port < 1 || port > 65535 )); then
+ return 0
+ fi
+
+ local in_use=0
+ if command_available "ss"; then
+ if ss -ltn 2>/dev/null | grep -qE "(:${port}\b|:${port}$)"; then
Review Comment:
⚠️ The primary probes do not identify the configured local endpoint: they
match every listener by port, and the `ss` expression can even match the target
digits inside an IPv6 address (for example, `[2001:db8:8080::1]:9090` matches a
check for port 8080). A listener on another specific interface can therefore
reject a valid bind, while an IPv6 hextet can produce the same false positive.
Please parse the local-address field and compare the configured host/port with
wildcard and dual-stack conflict semantics, then add distinct-address and
IPv6-hextet regressions.
##########
hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh:
##########
@@ -79,15 +79,65 @@ function process_id() {
return "$pid"
}
-# check the port of rest server is occupied
+# check whether the REST server port is occupied
function check_port() {
- local port=$(echo "$1" | sed 's|.*:||' | sed 's|/.*||')
- if ! command_available "lsof"; then
- echo "Required lsof but it is unavailable"
- exit 1
+ local url="$1"
+ local host
+ local port
+
+ # Extract port: last colon-delimited segment, strip trailing path
+ port=$(echo "$url" | sed 's|.*:||' | sed 's|/.*||')
+ if [[ -z "$port" ]]; then
+ return 0
fi
- lsof -i :"$port" >/dev/null
- if [ $? -eq 0 ]; then
+
+ if ! [[ "$port" =~ ^[0-9]+$ ]] || (( port < 1 || port > 65535 )); then
+ return 0
+ fi
+
+ local in_use=0
+ if command_available "ss"; then
Review Comment:
⚠️ Tool presence is treated as a successful probe. If an installed `ss`
exits nonzero, this branch neither distinguishes that failure from an empty
listener table nor tries `netstat` or `/dev/tcp`; the same silent-free result
occurs when both `netstat` invocations fail. Please capture each probe's
execution status, advance to the next layer on failure, and add cases where a
present tool returns nonzero.
##########
hugegraph-server/hugegraph-dist/src/assembly/travis/test-start-hugegraph-pd.sh:
##########
@@ -72,9 +72,9 @@ cleanup() {
fi
rm -f "$PID_FILE"
rm -rf "$PD_ROOT/logs/"
- # kill anything still holding the PD port
- lsof -ti :8620 | xargs kill -9 2>/dev/null || true
- lsof -ti :8686 | xargs kill -9 2>/dev/null || true
+ # kill anything still holding the PD port (fuser avoids lsof dependency)
+ fuser -k 8620/tcp 2>/dev/null || true
Review Comment:
⚠️ This cleanup now depends on `fuser`, but the PD workflow preflight still
requires `lsof curl java` and never checks `fuser`. An lsof-free environment
therefore skips the revised suite, while a runner without `fuser` executes it
with silently ineffective port cleanup. Please remove the obsolete `lsof` gate,
require `fuser` (or make cleanup dependency-free), and fail explicitly when
cleanup cannot release the test ports.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]