Changeset fd01712f1a1ee5b1313098087a6614adff90574d

Show
Ignore:
Timestamp:
09/27/09 03:06:11 (5 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1254020771 +0000
git-parent:

[652d766e888968c4809a0101e9cca758fc88f521]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1254020771 +0000
Message:

fixes #190

Files:

Legend:

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

    rb9a4230 rfd01712  
    9090  int ipv4_fd; 
    9191  int ipv6_fd; 
     92  noit_hash_table *in_flight; 
    9293} ping_icmp_data_t; 
    9394 
     
    167168  struct ping_closure *pcl = (struct ping_closure *)closure; 
    168169  struct check_info *data; 
     170  ping_icmp_data_t *ping_data; 
     171 
    169172  if(!NOIT_CHECK_KILLED(pcl->check) && !NOIT_CHECK_DISABLED(pcl->check)) { 
    170173    ping_icmp_log_results(pcl->self, pcl->check); 
     
    173176  } 
    174177  pcl->check->flags &= ~NP_RUNNING; 
     178  ping_data = noit_module_get_userdata(pcl->self); 
     179  noit_hash_delete(ping_data->in_flight, (const char *)pcl->check->checkid, 
     180                   sizeof(pcl->check->checkid), NULL, NULL); 
    175181  free(pcl); 
    176182  return 0; 
     
    179185                             void *closure, struct timeval *now) { 
    180186  noit_module_t *self = (noit_module_t *)closure; 
     187  ping_icmp_data_t *ping_data; 
    181188  struct check_info *data; 
    182189  char packet[1500]; 
     
    191198  struct ping_payload *payload; 
    192199 
     200  ping_data = noit_module_get_userdata(self); 
    193201  while(1) { 
    194202    int inlen, iphlen; 
     203    void *vcheck; 
    195204    noit_check_t *check; 
    196205    struct timeval tt; 
     
    225234      continue; 
    226235    } 
    227     check = noit_poller_lookup(payload->checkid); 
     236    check = NULL; 
     237    if(noit_hash_retrieve(ping_data->in_flight, 
     238                          (const char *)payload->checkid, 
     239                          sizeof(payload->checkid), &vcheck)) 
     240      check = vcheck; 
     241 
    228242    /* make sure this check is from this generation! */ 
    229243    if(!check) { 
     
    261275      data->timeout_event = NULL; 
    262276      check->flags &= ~NP_RUNNING; 
     277      noit_hash_delete(ping_data->in_flight, (const char *)check->checkid, 
     278                       sizeof(check->checkid), NULL, NULL); 
    263279    } 
    264280  } 
     
    272288 
    273289  data = malloc(sizeof(*data)); 
     290  data->in_flight = calloc(1, sizeof(*data->in_flight)); 
    274291  data->ipv4_fd = data->ipv6_fd = -1; 
    275292 
     
    352369  struct ping_payload *payload; 
    353370  ping_icmp_data_t *data; 
     371  void *vcheck; 
    354372  int i; 
    355373 
    356   noitLT(nldeb, now, "ping_icmp_real_send(%s)\n", pcl->check->target); 
    357374  data = noit_module_get_userdata(pcl->self); 
    358375  icp = (struct icmp *)pcl->payload; 
    359376  payload = (struct ping_payload *)(icp + 1); 
     377  if(!noit_hash_retrieve(data->in_flight, (const char *)payload->checkid, 
     378                         sizeof(payload->checkid), &vcheck)) { 
     379    noitLT(nldeb, now, "ping check no longer active, bailing\n"); 
     380    goto cleanup; 
     381  } 
     382 
     383  noitLT(nldeb, now, "ping_icmp_real_send(%s)\n", pcl->check->target); 
    360384  gettimeofday(&payload->whence, NULL); /* now isn't accurate enough */ 
    361385  icp->icmp_cksum = in_cksum(pcl->payload, pcl->payload_len); 
     
    384408             pcl->check->target, strerror(errno)); 
    385409  } 
     410 cleanup: 
    386411  free(pcl->payload); 
    387412  free(pcl); 
     
    409434  eventer_t newe; 
    410435  const char *config_val; 
     436  ping_icmp_data_t *ping_data; 
    411437 
    412438  int interval = PING_INTERVAL; 
    413439  int count = PING_COUNT; 
     440 
    414441  if(noit_hash_retr_str(check->config, "interval", strlen("interval"), 
    415442                        &config_val)) 
     
    420447 
    421448  check->flags |= NP_RUNNING; 
     449  ping_data = noit_module_get_userdata(self); 
     450  noit_hash_store(ping_data->in_flight, (const char *)check->checkid, 
     451                  sizeof(check->checkid), check); 
    422452  noitL(nldeb, "ping_icmp_send(%p,%s,%d,%d)\n", 
    423453        self, check->target, interval, count);