summaryrefslogtreecommitdiff
path: root/test/request.c
diff options
context:
space:
mode:
authorjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2006-02-25 14:45:09 +0000
committerjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2006-02-25 14:45:09 +0000
commit8f81dc406c1fca4bdfa88f3d3f60016d6cbaaac2 (patch)
tree627f6b2e52ce0707f8f69d5a946b0ba0a0a4378e /test/request.c
parent5276b0fe325266298118fdc2be746ddc9719a68f (diff)
downloadneon-8f81dc406c1fca4bdfa88f3d3f60016d6cbaaac2.tar.gz
* src/ne_request.h: Make behaviour undefined when unregistering hooks
from a corresponding hook implementation, except for the destroy_request hook. * src/ne_request.c (ne_request_destroy): Make safe against the hook list changing under foot. * test/request.c (hook_self_destroy): New test. git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@940 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
Diffstat (limited to 'test/request.c')
-rw-r--r--test/request.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/request.c b/test/request.c
index f129ab5..347dfbb 100644
--- a/test/request.c
+++ b/test/request.c
@@ -1901,6 +1901,27 @@ static int hooks(void)
return OK;
}
+static void hook_self_destroy_req(ne_request *req, void *userdata)
+{
+ ne_unhook_destroy_request(ne_get_session(req),
+ hook_self_destroy_req, userdata);
+}
+
+/* Test that it's safe to call ne_unhook_destroy_request from a
+ * destroy_request hook. */
+static int hook_self_destroy(void)
+{
+ ne_session *sess = ne_session_create("http", "localhost", 1234);
+
+ ne_hook_destroy_request(sess, hook_self_destroy_req, NULL);
+
+ ne_request_destroy(ne_request_create(sess, "GET", "/"));
+
+ ne_session_destroy(sess);
+
+ return OK;
+}
+
ne_test tests[] = {
T(lookup_localhost),
T(single_get_clength),
@@ -1982,5 +2003,6 @@ ne_test tests[] = {
T(abort_reader),
T(send_bad_offset),
T(hooks),
+ T(hook_self_destroy),
T(NULL)
};