Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 444402

Summary: net-misc/memcached - Malformed pid filename when running multiple instances
Product: Gentoo Linux Reporter: Sorin Panca <sorin.panca>
Component: [OLD] ServerAssignee: Robin Johnson <robbat2>
Status: CONFIRMED ---    
Severity: minor CC: tomwij
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: proposed.patch

Description Sorin Panca 2012-11-23 08:39:34 UTC
When running multiple instances of memcached, the pid filename is as a ${PORT} component that is undefined when its name is created.

Reproducible: Always

Steps to Reproduce:
1. ln -s /etc/init.d/memcached /etc/init.d/i1
2. cp /etc/conf.d/memcached /etc/conf.d/memcached.i1
3. /etc/init.d/i1 start
4. ps axo command | grep memcached


Actual Results:  
/usr/bin/memcached -d -p 11211 -U 11211 -m 5120 -c 1024 -u memcached -P /var/run/memcached/memcached-.i1.pid

Expected Results:  
/usr/bin/memcached -d -p 11211 -U 11211 -m 5120 -c 1024 -u memcached -P /var/run/memcached/memcached-11211.i1.pid

Proposed patch:

--- /etc/init.d/memcached       2012-11-23 03:31:01.000000000 -0500
+++ /etc/init.d/memcached-new   2012-11-23 03:30:22.000000000 -0500
@@ -8,16 +8,16 @@
 [ "${CONF}" == "memcached" ] && CONF=''
 
 if [ -n "${CONF}" ]; then
-        PIDFILE="${PIDBASE}-${PORT}.${CONF}.pid"
         CONFSRC="${CONFBASE}.${CONF}"
         if [ -f "${CONFSRC}" ]; then
          source "${CONFSRC}"
+         PIDFILE="${PIDBASE}-${PORT}.${CONF}.pid"
         else
          eerror "The configuration file $CONFSRC was not found!"
         fi
 else
-        PIDFILE="${PIDBASE}-${PORT}.pid"
         CONFSRC="${CONFBASE}"
+        PIDFILE="${PIDBASE}-${PORT}.pid"
 fi
 
 depend() {
Comment 1 Tom Wijsman (TomWij) (RETIRED) gentoo-dev 2012-11-23 09:39:12 UTC
Created attachment 330306 [details]
proposed.patch

Attached proposed patch.
Comment 2 Matthew Thode ( prometheanfire ) archtester Gentoo Infrastructure gentoo-dev Security 2016-02-23 20:02:02 UTC
I'm fine with this in general, but how does it handle if port is undefined?

robbat2, what do you think?