Skip to content

Apache Lucene open-source search software

SOLR-7635: Limit lsof port check in bin/solr to just listening ports

Ramkumar Aiyengar859415c7e13c
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 8d6bc80506a..06fa8d47077 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -129,6 +129,9 @@ Bug Fixes
* SOLR-7667: Add missing _root_ field to managed-schema template so that the default data driven
config set can index nested documents by default. (yonik)
+* SOLR-7635: Limit lsof port check in bin/solr to just listening ports
+ (Upayavira, Ramkumar Aiyengar)
+
Optimizations
----------------------
* SOLR-7660: Avoid redundant 'exists' calls made to ZK while fetching cluster state updates. (shalin)
diff --git a/solr/bin/solr b/solr/bin/solr
index b4d9e858e45..64d37951f07 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -1011,7 +1011,7 @@ if [ "$EXAMPLE" != "" ]; then
# check to see if something is already bound to that port
if hash lsof 2>/dev/null ; then # hash returns true if lsof is on the path
- PORT_IN_USE=`lsof -Pni:$CLOUD_PORT`
+ PORT_IN_USE=`lsof -PniTCP:$CLOUD_PORT -sTCP:LISTEN`
if [ "$PORT_IN_USE" != "" ]; then
read -e -p "Oops! Looks like port $CLOUD_PORT is already being used by another process. Please choose a different port. " USER_INPUT
else
@@ -1408,7 +1408,7 @@ function launch_solr() {
(loops=0
while true
do
- running=`lsof -Pni:$SOLR_PORT`
+ running=`lsof -PniTCP:$SOLR_PORT -sTCP:LISTEN`
if [ -z "$running" ]; then
if [ $loops -lt 6 ]; then
sleep 5