summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2008-07-19 12:49:21 +0000
committerjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2008-07-19 12:49:21 +0000
commit5d2c0d72dae5e6697cb6f5bd9143ce4086a1d04c (patch)
tree50831f14af9190bc21aa738686e2618dc9e435e1
parent63711afdee0e3fb277a0e876b660b9077c59a1d5 (diff)
downloadneon-5d2c0d72dae5e6697cb6f5bd9143ce4086a1d04c.tar.gz
Merge r1497 from trunk:
* src/ne_session.h (ne_set_notifier, ne_set_progress): Document existing and previous (respectively) API guarantee that a NULL callback deregisters an existing callback. * src/ne_session.c (ne_set_progress): Fix regression in 0.27, support NULL progress callback correctly. * test/request.c (dereg_progress): Add regression test. git-svn-id: http://svn.webdav.org/repos/projects/neon/branches/0.28.x@1499 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
-rw-r--r--src/ne_session.c11
-rw-r--r--src/ne_session.h5
-rw-r--r--test/request.c21
3 files changed, 33 insertions, 4 deletions
diff --git a/src/ne_session.c b/src/ne_session.c
index 9914273..f286606 100644
--- a/src/ne_session.c
+++ b/src/ne_session.c
@@ -220,9 +220,14 @@ static void progress_notifier(void *userdata, ne_session_status status,
void ne_set_progress(ne_session *sess, ne_progress progress, void *userdata)
{
- sess->progress_cb = progress;
- sess->progress_ud = userdata;
- ne_set_notifier(sess, progress_notifier, sess);
+ if (progress) {
+ sess->progress_cb = progress;
+ sess->progress_ud = userdata;
+ ne_set_notifier(sess, progress_notifier, sess);
+ }
+ else {
+ ne_set_notifier(sess, NULL, NULL);
+ }
}
void ne_set_notifier(ne_session *sess,
diff --git a/src/ne_session.h b/src/ne_session.h
index 72262c7..fbf3f4b 100644
--- a/src/ne_session.h
+++ b/src/ne_session.h
@@ -104,6 +104,8 @@ typedef void (*ne_progress)(void *userdata, ne_off_t progress, ne_off_t total);
* is invoked for after each block of the request and response body to
* indicate request and response progress (there is no way to
* distinguish between the two using this interface alone).
+ * If progress is NULL, any existing callback is deregistered and will
+ * no longer be invoked.
*
* NOTE: Use of this interface is mutually exclusive with the use of
* ne_set_notifier(). A call to ne_set_progress() removes the
@@ -164,7 +166,8 @@ typedef void (*ne_notify_status)(void *userdata, ne_session_status status,
/* Set a status notification callback for the session, to report
* session status events. Only one notification callback per session
* can be registered; the most recent of successive calls to this
- * function takes effect.
+ * function takes effect. If status is NULL, any existing callback
+ * is deregistered and will no longer be invoked.
*
* NOTE: Use of this interface is mutually exclusive with the use of
* ne_set_progress(). A call to ne_set_notifier() removes the
diff --git a/test/request.c b/test/request.c
index 7543a37..49369da 100644
--- a/test/request.c
+++ b/test/request.c
@@ -2117,6 +2117,26 @@ static int local_addr(void)
return reap_server();
}
+/* Regression in 0.27.0, ne_set_progress(sess, NULL, NULL) should
+ * register the progress callback. */
+static int dereg_progress(void)
+{
+ ne_session *sess;
+
+ CALL(make_session(&sess, single_serve_string,
+ RESP200 TE_CHUNKED "\r\n" ABCDE_CHUNKS));
+
+ ne_set_progress(sess, NULL, NULL);
+
+ ONREQ(any_request(sess, "/foo"));
+
+ ne_session_destroy(sess);
+
+ return await_server();
+}
+
+/* TODO: test that ne_set_notifier(, NULL, NULL) DTRT too. */
+
ne_test tests[] = {
T(lookup_localhost),
T(single_get_clength),
@@ -2204,5 +2224,6 @@ ne_test tests[] = {
T(status),
T(status_chunked),
T(local_addr),
+ T(dereg_progress),
T(NULL)
};