diff options
Diffstat (limited to 'src/snmp-engine.c')
-rw-r--r-- | src/snmp-engine.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/snmp-engine.c b/src/snmp-engine.c index fef7ad4..8d39991 100644 --- a/src/snmp-engine.c +++ b/src/snmp-engine.c @@ -67,7 +67,7 @@ typedef struct _rb_request uint32_t id; uint64_t next_retry; /* Time of the next retry */ - uint32_t interval; /* How long between retries */ + uint64_t interval; /* How long between retries */ uint64_t timeout; /* When this request times out */ uint32_t sent; /* How many times we've sent */ @@ -129,7 +129,6 @@ new_req() /* Reallocate the request block */ /* TODO: Once we use less memory this can be higher */ num = nrequests ? nrequests * 2 : 32; - fprintf(stderr, "REALLOCATING: %d!!!\n", nrequests); requests = (rb_request*)realloc(requests, sizeof(rb_request) * num); if(!requests) { @@ -139,12 +138,17 @@ new_req() } /* Clear out the new ones */ - fprintf(stderr, "clearing: %d %d\n", sizeof(rb_request), num - nrequests); memset(requests + nrequests, 0, sizeof(rb_request) * (num - nrequests)); /* We return the next one */ req = requests + nrequests; + nrequests = num; + + if(reqhigh == -1) + reqhigh = 0; + if(reqlow == -1) + reqlow = nrequests - 1; } /* A incrementing counter for each request */ @@ -216,7 +220,7 @@ finish_poll(rb_poller* poll, uint64_t when) rb_messagex(LOG_DEBUG, "collected poll values. sending them to rrd"); /* And send off our collection of values */ - // rb_rrd_update(poll); + rb_rrd_update(poll); } static void @@ -274,6 +278,8 @@ timeout_req(rb_request* req, uint64_t when) incomplete = 1; } + free_req(req); + if(!incomplete) finish_poll(poll, when); } @@ -284,8 +290,11 @@ check_req(rb_request* req, uint64_t when) ASSERT(req->id); /* See if it's timed out */ - if(when <= req->timeout) + if(when >= req->timeout) + { +fprintf(stderr, "check_req timeout_req %lld %lld\n", when, req->timeout); timeout_req(req, when); + } if(!req->next_retry) return; @@ -359,6 +368,9 @@ respond_req(rb_request* req, struct snmp_pdu* pdu, uint64_t when) } } + /* We're done with this request */ + free_req(req); + /* Now see if the entire request is done */ for(item = poll->items; item; item = item->next) { @@ -366,6 +378,7 @@ respond_req(rb_request* req, struct snmp_pdu* pdu, uint64_t when) return; } + /* And if so then hand off */ finish_poll(poll, when); } @@ -436,10 +449,12 @@ poller_timer(uint64_t when, void* arg) req->pdu.nbindings = 0; /* Send interval is 200 ms when poll interval is below 2 seconds */ - req->interval = (poll->interval < 3) ? 200 : 600; + req->interval = (poll->interval <= 2000) ? 200L : 600L; /* Timeout is for the last packet sent, not first */ - req->timeout = when + (req->interval * g_state.retries) + poll->timeout; +fprintf(stderr, "timeout info: %lld %lld %d\n", when, req->interval, g_state.retries); + req->timeout = when + ((uint64_t)req->interval * (uint64_t)g_state.retries) + poll->timeout; +fprintf(stderr, "new request with timeout: %lld %lld %lld\n", poll->timeout, req->timeout, req->interval); req->sent = 0; last_host = it->host; |