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

Bug 374223

Summary: net-misc/memcached: support listening on socket
Product: Gentoo Linux Reporter: Johan Bergström <bugs>
Component: [OLD] ServerAssignee: Robin Johnson <robbat2>
Status: CONFIRMED ---    
Severity: enhancement CC: kfm, me
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=525412
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: init
conf
PORT=unix

Description Johan Bergström 2011-07-06 12:27:23 UTC
Created attachment 279221 [details]
init

If you're using memcached locally there isn't much reason to use TCP. memcached -s will do this for you.

Attaching my futile (yes, its really futile) attempt at toggling socket/tcp through conf.d/init.d.

Here's the diff :
--- /usr/portage/net-misc/memcached/files/1.3.3/init    2009-05-26 02:03:09.000000000 +0200
+++ /etc/init.d/memcached       2011-04-20 09:36:53.000000000 +0200
@@ -32,7 +32,6 @@
           ewarn "You should edit $CONFSRC and specify an address to listen on."
           ewarn "Listening on any address (check your firewall!)"
         fi
-
 }
 
 start() {
@@ -54,15 +53,17 @@
         fi
 
         if [ -z "${LISTENON}" ]; then
-          c_LISTENON=""
+          c_LISTENON="-p ${PORT}"
+        elif [ "${LISTENON:0:1}" ==  "/" ]; then
+          c_LISTENON="-s ${LISTENON}"
         else
-          c_LISTENON="-l ${LISTENON}"
+          c_LISTENON="-l ${LISTENON} -U ${UDPPORT} -p ${PORT}"
         fi
 
         /sbin/start-stop-daemon --start --pidfile "${PIDFILE}" \
                 --exec "${MEMCACHED_BINARY}" \
                                --startas "${MEMCACHED_BINARY}" -- \
-                -d -p ${PORT} -U ${UDPPORT} ${c_LISTENON} -m ${MEMUSAGE} \
+                -d ${c_LISTENON} -m ${MEMUSAGE} \
                 -c ${MAXCONN} -u ${MEMCACHED_RUNAS} -P "${PIDFILE}" \
                                ${MISC_OPTS}
         eend $?

--- /usr/portage/net-misc/memcached/files/1.3.3/conf    2009-05-26 02:03:09.000000000 +0200
+++ /etc/conf.d/memcached       2011-05-09 07:58:01.000000000 +0200
@@ -4,9 +4,14 @@
 
 MEMCACHED_BINARY="/usr/bin/memcached"
 
+#PID file location
+# '-${PORT}.${CONF}.pid' will be appended to this!
+# You do not normally need to change this.
+PIDBASE="/var/run/memcached/memcached"
+
 #Specify memory usage in megabytes (do not use letters)
 #64MB is default
 MEMUSAGE="64"
@@ -15,10 +20,13 @@
 #1024 is default
 MAXCONN="1024"
 
-#Listen for connections on what address?
+# Listen for connections on what address?
 # If this is empty, memcached will listen on 0.0.0.0
 # be sure you have a firewall in place!
-LISTENON=""
+# Should you enter a path, memcached will listen on socket instead.
+# The recommended directory for sockets is the same as ${PIDBASE}
+# Note: This disables TCP/UDP altogether
+LISTENON="${PIDBASE}.sock"
 
 #Listen for connections on what port?
 PORT="11211"
@@ -26,10 +34,5 @@
 # Listen for UDP connecitons on what port? 0 means turn off UDP
 UDPPORT="${PORT}"
 
-#PID file location
-# '-${PORT}.${CONF}.pid' will be appended to this!
-# You do not normally need to change this.
-PIDBASE="/var/run/memcached/memcached"
-
 #Other Options
 MISC_OPTS=""
Comment 1 Johan Bergström 2011-07-06 12:28:20 UTC
Created attachment 279223 [details]
conf
Comment 2 Johan Bergström 2011-07-06 12:29:32 UTC
Possible caveats: 
 - socket path uses ${PORT}
 - no reason to let users define socket path? a possible reason would be to leave LISTENON blank, and thereby "enabling" socket?
Comment 3 crucify 2012-09-03 08:43:53 UTC
Created attachment 322810 [details, diff]
PORT=unix

conf PORT=unix patch
Comment 4 Jeroen Roovers (RETIRED) gentoo-dev 2013-07-19 15:02:38 UTC
*** Bug 477398 has been marked as a duplicate of this bug. ***
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-08-12 17:13:24 UTC
Currently you can pass socket path as misc option. The script will incorrectly complain that memcached would listen on 0.0.0.0 though.
Comment 6 Nilesh Govindrajan 2013-09-09 05:43:53 UTC
(In reply to Michał Górny from comment #5)
> Currently you can pass socket path as misc option. The script will
> incorrectly complain that memcached would listen on 0.0.0.0 though.

Figured out today that setting LISTENON and PORT both to 0, the complaint would go away.
Comment 7 Matthew Thode ( prometheanfire ) archtester Gentoo Infrastructure gentoo-dev Security 2016-02-23 20:02:37 UTC
mind trying 1.4.24/25?