Changeset e1dc8cfb2340b39aae179bec7cf59498cffc0da7

Show
Ignore:
Timestamp:
04/22/12 20:57:17 (2 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1335128237 -0400
git-parent:

[60aa58b81f5826158d1b04067717cc454dc1742b]

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

fix memory leak of an eventer_t in the case of a timeout

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/snmp.c

    rde52002 re1dc8cf  
    330330} 
    331331 
    332 static int noit_snmp_session_cleanse(struct target_session *ts) { 
     332static int noit_snmp_session_cleanse(struct target_session *ts, 
     333                                     int needs_free) { 
    333334  if(ts->refcnt == 0 && ts->sess_handle) { 
    334     eventer_remove_fd(ts->fd); 
     335    eventer_t e = eventer_remove_fd(ts->fd); 
     336    if(needs_free) eventer_free(e); 
    335337    ts->fd = -1; 
    336338    if(ts->timeoutevent) { 
     
    352354  struct target_session *ts = closure; 
    353355  snmp_sess_timeout(ts->sess_handle); 
    354   noit_snmp_session_cleanse(ts); 
     356  noit_snmp_session_cleanse(ts, 1); 
    355357  if(ts->timeoutevent == e) 
    356358    ts->timeoutevent = NULL; /* this will be freed on return */ 
     
    364366  if(info->ts) { 
    365367    info->ts->refcnt--; 
    366     noit_snmp_session_cleanse(info->ts); 
     368    noit_snmp_session_cleanse(info->ts, 1); 
    367369    info->ts = NULL; 
    368370  } 
     
    403405  fds = e->fd + 1; 
    404406  snmp_sess_read(ts->sess_handle, &fdset); 
    405   if(noit_snmp_session_cleanse(ts)) 
     407  if(noit_snmp_session_cleanse(ts, 0)) 
    406408    return 0; 
    407409  snmp_sess_select_info(ts->sess_handle, &fds, &fdset, &timeout, &block); 
     
    10071009    ts->refcnt--; 
    10081010    noitL(nlerr, "Error sending snmp get request.\n"); 
    1009     noit_snmp_session_cleanse(ts); 
     1011    noit_snmp_session_cleanse(ts, 1); 
    10101012    /* Error */ 
    10111013    if(req) snmp_free_pdu(req);