Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/14211


Change subject: gtp: Take queue_resp into account to schedule retrans timer
......................................................................

gtp: Take queue_resp into account to schedule retrans timer

Before this patch they were not taken into account, which means some
resp messages could stay more time than required enqueued.

Change-Id: Iebf405b2310a34785f3b363cc2a9f415281f6030
---
M gtp/gtp.c
1 file changed, 15 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/11/14211/1

diff --git a/gtp/gtp.c b/gtp/gtp.c
index b98fba0..b50b592 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -590,22 +590,34 @@

 int gtp_retranstimeout(struct gsn_t *gsn, struct timeval *timeout)
 {
-       time_t now, later;
+       time_t now, later, diff;
        struct qmsg_t *qmsg;
+       timeout->tv_usec = 0;

        if (queue_getfirst(gsn->queue_req, &qmsg)) {
                timeout->tv_sec = 10;
-               timeout->tv_usec = 0;
        } else {
                now = time(NULL);
                later = qmsg->timeout;
                timeout->tv_sec = later - now;
-               timeout->tv_usec = 0;
                if (timeout->tv_sec < 0)
                        timeout->tv_sec = 0;    /* No negative allowed */
                if (timeout->tv_sec > 10)
                        timeout->tv_sec = 10;   /* Max sleep for 10 sec */
        }
+
+       if (queue_getfirst(gsn->queue_resp, &qmsg)) {
+               /* already set by queue_req, do nothing */
+       } else { /* trigger faster if earlier timeout exists in queue_resp */
+               now = time(NULL);
+               later = qmsg->timeout;
+               diff = later - now;
+               if (diff < 0)
+                       diff = 0;
+               if (diff < timeout->tv_sec)
+                       timeout->tv_sec = diff;
+       }
+
        return 0;
 }


--
To view, visit https://gerrit.osmocom.org/14211
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iebf405b2310a34785f3b363cc2a9f415281f6030
Gerrit-Change-Number: 14211
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <[email protected]>

Reply via email to