]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix pythonmod for cb changes.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 6 Apr 2017 14:17:37 +0000 (14:17 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 6 Apr 2017 14:17:37 +0000 (14:17 +0000)
git-svn-id: file:///svn/unbound/trunk@4097 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
pythonmod/interface.i
pythonmod/pythonmod.h

index b376c5353b30427c6d299493ab1f55b71fd17012..2cd7b92d2a809b7d87eec704ae8367dba7da70ad 100644 (file)
@@ -14,6 +14,7 @@
        - Small fixup for documentation.
        - iana portlist update
        - Fix respip for braces when locks arent used.
+       - Fix pythonmod for cb changes.
 
 4 April 2017: Wouter
        - Fix #1244: document that use of chroot requires trust anchor file to
index 89dd73d996b589fae867ebce1bc120df34123d3c..d909e380f631b3af2ac903862635d28be5a8273b 100644 (file)
@@ -1346,7 +1346,7 @@ int edns_opt_list_append(struct edns_option** list, uint16_t code, size_t len,
     int python_inplace_cb_reply_generic(struct query_info* qinfo,
         struct module_qstate* qstate, struct reply_info* rep, int rcode,
         struct edns_data* edns, struct edns_option** opt_list_out,
-        struct regional* region, void* python_callback)
+        struct regional* region, int id, void* python_callback)
     {
         PyObject *func, *py_edns, *py_qstate, *py_opt_list_out, *py_qinfo;
         PyObject *py_rep, *py_region;
@@ -1379,49 +1379,51 @@ int edns_opt_list_append(struct edns_option** list, uint16_t code, size_t len,
         return res;
     }
 
+    /* register a callback */
+    static int python_inplace_cb_register(enum inplace_cb_list_type type,
+        PyObject* py_cb, struct module_env* env)
+    {
+        int id = modstack_find(&env->mesh->mods, "python");
+        int ret = inplace_cb_register(python_inplace_cb_reply_generic,
+                type, (void*) py_cb, env, id);
+        if (ret) Py_INCREF(py_cb);
+        return ret;
+    }
+
     /* Swig implementations for Python */
     static int register_inplace_cb_reply(PyObject* py_cb,
         struct module_env* env)
     {
-        int ret = inplace_cb_reply_register(
-            python_inplace_cb_reply_generic, (void*) py_cb, env);
-        if (ret) Py_INCREF(py_cb);
-        return ret;
+        return python_inplace_cb_register(inplace_cb_reply, py_cb, env);
     }
     static int register_inplace_cb_reply_cache(PyObject* py_cb,
         struct module_env* env)
     {
-        int ret = inplace_cb_reply_cache_register(
-            python_inplace_cb_reply_generic, (void*) py_cb, env);
-        if (ret) Py_INCREF(py_cb);
-        return ret;
+        return python_inplace_cb_register(inplace_cb_reply_cache, py_cb, env);
     }
     static int register_inplace_cb_reply_local(PyObject* py_cb,
         struct module_env* env)
     {
-        int ret = inplace_cb_reply_local_register(
-            python_inplace_cb_reply_generic, (void*) py_cb, env);
-        if (ret) Py_INCREF(py_cb);
-        return ret;
+        return python_inplace_cb_register(inplace_cb_reply_local, py_cb, env);
     }
     static int register_inplace_cb_reply_servfail(PyObject* py_cb,
         struct module_env* env)
     {
-        int ret = inplace_cb_reply_servfail_register(
-            python_inplace_cb_reply_generic, (void*) py_cb, env);
-        if (ret) Py_INCREF(py_cb);
-        return ret;
+        return python_inplace_cb_register(inplace_cb_reply_servfail,
+                py_cb, env);
+    }
+    static int register_inplace_cb_query(PyObject* py_cb,
+        struct module_env* env)
+    {
+        return python_inplace_cb_register(inplace_cb_query, py_cb, env);
+    }
+    static int register_inplace_cb_edns_back_parsed(PyObject* py_cb,
+        struct module_env* env)
+    {
+        return python_inplace_cb_register(inplace_cb_edns_back_parsed,
+                py_cb, env);
     }
 %}
-/* C declarations */
-int inplace_cb_reply_register(
-    inplace_cb_reply_func_type* cb, void* cb_arg, struct module_env* env);
-int inplace_cb_reply_cache_register(
-    inplace_cb_reply_func_type* cb, void* cb_arg, struct module_env* env);
-int inplace_cb_reply_local_register(
-    inplace_cb_reply_func_type* cb, void* cb_arg, struct module_env* env);
-int inplace_cb_reply_servfail_register(
-    inplace_cb_reply_func_type* cb, void* cb_arg, struct module_env* env);
 
 /* Swig declarations */
 static int register_inplace_cb_reply(PyObject* py_cb,
@@ -1432,3 +1434,7 @@ static int register_inplace_cb_reply_local(PyObject* py_cb,
     struct module_env* env);
 static int register_inplace_cb_reply_servfail(PyObject* py_cb,
     struct module_env* env);
+static int register_inplace_cb_query(PyObject* py_cb,
+    struct module_env* env);
+static int register_inplace_cb_edns_back_parsed(PyObject* py_cb,
+    struct module_env* env);
index 2386882de9c24a5f4d5844f4ee53f40ad8a21bc5..7c7c0e751c30cc438063eeec68c17521a09be4ec 100644 (file)
@@ -72,5 +72,5 @@ size_t pythonmod_get_mem(struct module_env* env, int id);
 int python_inplace_cb_reply_generic(struct query_info* qinfo,
        struct module_qstate* qstate, struct reply_info* rep, int rcode,
        struct edns_data* edns, struct edns_option** opt_list_out,
-       struct regional* region, void* python_callback);
+       struct regional* region, int id, void* python_callback);
 #endif /* PYTHONMOD_H */