From 3c5f8d2949715f5d52b0dffaff971125409a2f4a Mon Sep 17 00:00:00 2001
From: David Stainton <dstainton415@gmail.com>
Date: Thu, 28 Jan 2016 17:43:01 +0000
Subject: [PATCH] Daira's fix to the hook mixin

---
 src/allmydata/util/deferredutil.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/allmydata/util/deferredutil.py b/src/allmydata/util/deferredutil.py
index 34aa3777..9a212378 100644
--- a/src/allmydata/util/deferredutil.py
+++ b/src/allmydata/util/deferredutil.py
@@ -101,7 +101,7 @@ class HookMixin:
         self._hooks[name] = (d, ignore_count)
         return d
 
-    def _call_hook(self, res, name):
+    def _call_hook(self, res, name, async=False):
         """
         Called to trigger the hook, with argument 'res'. This is a no-op if
         the hook is unset. If the hook's ignore_count is positive, it will be
@@ -124,7 +124,10 @@ class HookMixin:
             self._hooks[name] = (d, ignore_count - 1)
         else:
             self._hooks[name] = None
-            _with_log(eventually_callback(d), res)
+            if async:
+                _with_log(eventually_callback(d), res)
+            else:
+                _with_log(d.callback, res)
         return res
 
     def _log(self, msg):
-- 
2.45.2