diff options
-rw-r--r-- | src/rrdbotd.h | 12 | ||||
-rw-r--r-- | src/snmp-engine.c | 28 |
2 files changed, 20 insertions, 20 deletions
diff --git a/src/rrdbotd.h b/src/rrdbotd.h index 8c826e1..74f8fd5 100644 --- a/src/rrdbotd.h +++ b/src/rrdbotd.h @@ -40,6 +40,7 @@ #define __RRDBOTD_H__ #include <values.h> +#include <stdint.h> #include "asn1.h" #include "snmp.h" @@ -50,6 +51,7 @@ * DATA */ +typedef uint64_t mstime; #define RB_UNKNOWN -DBL_MAX struct _rb_item; @@ -90,8 +92,8 @@ typedef struct _rb_host /* Host resolving and book keeping */ struct sockaddr_any address; - uint64_t interval; - uint64_t last_resolved; + mstime interval; + mstime last_resolved; /* Next in list of hosts */ struct _rb_host* next; @@ -106,14 +108,14 @@ typedef struct _rb_poller /* This points into the memory above */ const char* rrdname; - uint64_t interval; - uint64_t timeout; + mstime interval; + mstime timeout; /* The things to poll. rb_poller owns this list */ rb_item* items; /* Book keeping */ - uint64_t last_polled; + mstime last_polled; /* Next in list of pollers */ struct _rb_poller* next; diff --git a/src/snmp-engine.c b/src/snmp-engine.c index 8d39991..896e8e4 100644 --- a/src/snmp-engine.c +++ b/src/snmp-engine.c @@ -66,10 +66,10 @@ typedef struct _rb_request /* The SNMP request identifier */ uint32_t id; - uint64_t next_retry; /* Time of the next retry */ - uint64_t interval; /* How long between retries */ - uint64_t timeout; /* When this request times out */ - uint32_t sent; /* How many times we've sent */ + mstime next_retry; /* Time of the next retry */ + mstime interval; /* How long between retries */ + mstime timeout; /* When this request times out */ + uint sent; /* How many times we've sent */ /* The poller and host associated with this request */ rb_poller* poll; @@ -204,7 +204,7 @@ free_req(rb_request* req) */ static void -finish_poll(rb_poller* poll, uint64_t when) +finish_poll(rb_poller* poll, mstime when) { #ifdef _DEBUG { @@ -224,7 +224,7 @@ finish_poll(rb_poller* poll, uint64_t when) } static void -send_req(rb_request* req, uint64_t when) +send_req(rb_request* req, mstime when) { struct asn_buf b; ssize_t ret; @@ -251,7 +251,7 @@ send_req(rb_request* req, uint64_t when) } static void -timeout_req(rb_request* req, uint64_t when) +timeout_req(rb_request* req, mstime when) { rb_poller* poll = req->poll; int incomplete = 0; @@ -285,7 +285,7 @@ timeout_req(rb_request* req, uint64_t when) } static void -check_req(rb_request* req, uint64_t when) +check_req(rb_request* req, mstime when) { ASSERT(req->id); @@ -305,7 +305,7 @@ fprintf(stderr, "check_req timeout_req %lld %lld\n", when, req->timeout); } static void -respond_req(rb_request* req, struct snmp_pdu* pdu, uint64_t when) +respond_req(rb_request* req, struct snmp_pdu* pdu, mstime when) { struct snmp_value* value; rb_poller* poll = req->poll; @@ -384,7 +384,7 @@ respond_req(rb_request* req, struct snmp_pdu* pdu, uint64_t when) } static int -poller_timer(uint64_t when, void* arg) +poller_timer(mstime when, void* arg) { rb_poller* poll = (rb_poller*)arg; const rb_host* last_host = NULL; @@ -452,9 +452,7 @@ poller_timer(uint64_t when, void* arg) req->interval = (poll->interval <= 2000) ? 200L : 600L; /* Timeout is for the last packet sent, not first */ -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->timeout = when + (req->interval * ((mstime)g_state.retries)) + poll->timeout; req->sent = 0; last_host = it->host; @@ -541,7 +539,7 @@ receive_resp(int fd, int type, void* arg) } static int -resend_timer(uint64_t when, void* arg) +resend_timer(mstime when, void* arg) { int i; @@ -557,7 +555,7 @@ resend_timer(uint64_t when, void* arg) } static int -prep_timer(uint64_t when, void* arg) +prep_timer(mstime when, void* arg) { /* * We don't prepare all timers at exactly the same time |