plaisthos has uploaded a new patch set (#6). ( 
http://gerrit.openvpn.net/c/openvpn/+/1854?usp=email )


Change subject: Factor out lookup_session_by_mda_key_id into its own method
......................................................................

Factor out lookup_session_by_mda_key_id into its own method

This makes the code a bit easier to read and also allows reusing
the function later.

Change-Id: Ib7d9aa61fd878d7e025e9d1050c563dd114eb438
Signed-off-by: Arne Schwabe <[email protected]>
---
M src/openvpn/multi.c
1 file changed, 20 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/54/1854/6

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 60a5148..b28cf80 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -4014,6 +4014,24 @@
     }
 }

+static struct tls_session *
+lookup_session_by_mda_key_id(struct tls_multi *multi,
+                             const unsigned int mda_key_id)
+{
+    if (multi->session[TM_INITIAL].key[KS_PRIMARY].mda_key_id == mda_key_id)
+    {
+        return &multi->session[TM_INITIAL];
+    }
+    else if (multi->session[TM_ACTIVE].key[KS_PRIMARY].mda_key_id == 
mda_key_id)
+    {
+        return &multi->session[TM_ACTIVE];
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
 static bool
 management_client_pending_auth(void *arg, const unsigned long cid, const 
unsigned int mda_key_id,
                                const char *extra, unsigned int timeout)
@@ -4024,17 +4042,9 @@
     if (mi)
     {
         struct tls_multi *multi = mi->context.c2.tls_multi;
-        struct tls_session *session;
+        struct tls_session *session = lookup_session_by_mda_key_id(multi, 
mda_key_id);

-        if (multi->session[TM_INITIAL].key[KS_PRIMARY].mda_key_id == 
mda_key_id)
-        {
-            session = &multi->session[TM_INITIAL];
-        }
-        else if (multi->session[TM_ACTIVE].key[KS_PRIMARY].mda_key_id == 
mda_key_id)
-        {
-            session = &multi->session[TM_ACTIVE];
-        }
-        else
+        if (!session)
         {
             return false;
         }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1854?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib7d9aa61fd878d7e025e9d1050c563dd114eb438
Gerrit-Change-Number: 1854
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to