stderr flushing fix

Brad Fitzpatrick brad at danga.com
Wed May 25 11:36:28 PDT 2005


Thanks, will put into the next release!


On Wed, 25 May 2005, Peter van Dijk wrote:

> Hi,
>
> I'm running memcached from daemontools (http://cr.yp.to/daemontools.html),
> with logging via multilog (http://cr.yp.to/daemontools/multilog.html).
> memcached is started with -vv (will switch to -v for production use
> eventually). However, nothing appears in the logfile.
>
> The problem is that memcached logs to stderr but doesn't flush. As long
> as stderr is a tty, this is fine. However, in the multilog case stderr
> is a pipe, which means that stdio will default to buffering output.
>
> The fix is simple:
>
>
> --- memcached-1.1.11/memcached.c        Mon Apr 26 23:26:48 2004
> +++ /tmp/memcached-patched/memcached.c  Wed May 25 14:00:52 2005
> @@ -1277,6 +1277,9 @@
>      /* init settings */
>      settings_init();
>
> +    /* set stderr non-buffering */
> +    setbuf(stderr, NULL);
> +
>      /* process arguments */
>      while ((c = getopt(argc, argv, "p:m:Mc:khirvdl:u:")) != -1) {
>          switch (c) {
>
>
> With this addition, memcached logs line by line to my multilog output
> directory. Could this patch be merged into the source tree, possibly
> as an option? Thank you.
>
> Cheers,
> Peter van Dijk
>
>


More information about the memcached mailing list