diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-05-18 18:24:53 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-05-18 18:24:53 +0200 |
commit | b4a3129993b009d5e7a3b67337c65d3ec913ee37 (patch) | |
tree | 2587be7594566164702d10a1363ea76f082f1c2b /openbsc/src/gprs | |
parent | cd4dd4d7ff9b3eae4258febdae2afa440e183aeb (diff) |
[GPRS] SGSN: No need to calculate difference for libgtp timer
The libgtp return value is already a timespan value, not a
wallclock time.
Diffstat (limited to 'openbsc/src/gprs')
-rw-r--r-- | openbsc/src/gprs/sgsn_libgtp.c | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c index 300a669c2..862dd40ab 100644 --- a/openbsc/src/gprs/sgsn_libgtp.c +++ b/openbsc/src/gprs/sgsn_libgtp.c @@ -381,52 +381,15 @@ static int sgsn_gtp_fd_cb(struct bsc_fd *fd, unsigned int what) return rc; } -static void timeval_normalize(struct timeval *tv) -{ - unsigned int sec = tv->tv_usec / 1000000; - tv->tv_sec += sec; - tv->tv_usec -= sec * 1000000; -} - -/* diff = a - b */ -static int timeval_diff(struct timeval *diff, - struct timeval *a, - struct timeval *b) -{ - /* Step 1: normalize input values */ - timeval_normalize(a); - timeval_normalize(b); - - if (b->tv_sec > a->tv_sec || - (b->tv_sec == a->tv_sec && b->tv_usec > a->tv_usec)) { - b->tv_sec = b->tv_usec = 0; - return -ERANGE; - } - - if (b->tv_usec > a->tv_usec) { - a->tv_sec -= 1; - a->tv_usec += 1000000; - } - - diff->tv_usec = a->tv_usec - b->tv_usec; - diff->tv_sec = a->tv_sec - b->tv_sec; - - return 0; -} - static void sgsn_gtp_tmr_start(struct sgsn_instance *sgi) { - struct timeval now, next, diff = { 0, 0 }; + struct timeval next; /* Retrieve next retransmission as struct timeval */ gtp_retranstimeout(sgi->gsn, &next); - /* Calculate the difference to now */ - gettimeofday(&now, NULL); - timeval_diff(&diff, &next, &now); - /* re-schedule the timer */ - bsc_schedule_timer(&sgi->gtp_timer, diff.tv_sec, diff.tv_usec/1000); + bsc_schedule_timer(&sgi->gtp_timer, next.tv_sec, next.tv_usec/1000); } /* timer callback for libgtp retransmissions and ping */ |