Changeset aad9993ad8fc88eea427cd95276e6a9bd02013a2

Show
Ignore:
Timestamp:
05/14/11 21:46:56 (8 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1305409616 -0400
git-parent:

[29fae1d96b5afb603790249d4abcf226b7b16d45]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1305409616 -0400
Message:

Fix a long standing bug that will leak threads and sockets on a
noitd that is *completely* idle.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_jlog_listener.c

    rdf42e89 raad9993  
    11/* 
    2  * Copyright (c) 2007, OmniTI Computer Consulting, Inc. 
     2 * Copyright (c) 2007-2011, OmniTI Computer Consulting, Inc. 
    33 * All rights reserved. 
    44 * 
     
    4141 
    4242#include <unistd.h> 
     43#include <poll.h> 
    4344#define MAX_ROWS_AT_ONCE 1000 
    4445#define DEFAULT_SECONDS_BETWEEN_BATCHES 10 
     
    214215      jlog_ctx_read_checkpoint(jcl->jlog, &jcl->chkpt); 
    215216    } 
     217    else { 
     218      /* we have nothing to write -- maybe we have no checks configured... 
     219       * If this is the case "forever", the remote might disconnect and 
     220       * we would never know. Do the painful work of detecting a 
     221       * disconnected client. 
     222       */ 
     223      struct pollfd pfd; 
     224      pfd.fd = e->fd; 
     225      pfd.events = POLLIN | POLLHUP | POLLRDNORM; 
     226      pfd.revents = 0; 
     227      if(poll(&pfd, 1, 0) != 0) { 
     228        /* normally, we'd recv PEEK|DONTWAIT.  However, the client should 
     229         * not be writing to us.  So, we know we can't have any legitimate 
     230         * data on this socket (true even though this is SSL). So, if we're 
     231         * here then "shit went wrong" 
     232         */ 
     233        noitL(noit_error, "jlog client %s disconnected while idle\n", 
     234              ac->remote_cn); 
     235        goto alldone; 
     236      } 
     237    } 
    216238    if(sleeptime) sleep(sleeptime); 
    217239  }