From 5f6f260a938542deb6ca5632a80b5315231afad8 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Mon, 28 Sep 2009 16:53:30 +0100
Subject: [PATCH] confd/client: pass self to upcalls

It may be handy for upcalls to know which client called them, and call
it back. So we create a new "client" field in the upcall target,
containing the current client instance

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/confd/client.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/confd/client.py b/lib/confd/client.py
index ee5b41aee..b12a730f8 100644
--- a/lib/confd/client.py
+++ b/lib/confd/client.py
@@ -151,7 +151,9 @@ class ConfdClient:
         client_reply = ConfdUpcallPayload(salt=rsalt,
                                           type=UPCALL_EXPIRE,
                                           orig_request=request,
-                                          extra_args=args)
+                                          extra_args=args,
+                                          client=self,
+                                          )
         self._callback(client_reply)
       else:
         break
@@ -227,7 +229,9 @@ class ConfdClient:
                                         orig_request=request,
                                         server_ip=ip,
                                         server_port=port,
-                                        extra_args=args)
+                                        extra_args=args,
+                                        client=self,
+                                       )
       self._callback(client_reply)
 
     finally:
@@ -263,6 +267,8 @@ class ConfdUpcallPayload(objects.ConfigObject):
   @ivar server_port: answering server port
   @type extra_args: any
   @ivar extra_args: 'args' argument of the SendRequest function
+  @type client: L{ConfdClient}
+  @ivar client: current confd client instance
 
   """
   __slots__ = [
@@ -273,6 +279,7 @@ class ConfdUpcallPayload(objects.ConfigObject):
     "server_ip",
     "server_port",
     "extra_args",
+    "client",
     ]
 
 
-- 
GitLab