Hi

A bug was discovered by mchubby on github where stage_40 isn't invoked
when requests are ended outside mkp_stage_* callbacks.
The consequence of this is that no requests are logged when handled by
the fastcgi plugin.

This patch introduces a bit of overhead to the http_request_end() plugin
function as mk_session_get() is used to find the client session.

Another solution to this bug would be to remove http_request_end() and
force all requests to end in stage_* callbacks.
I feel that this would be a step in the wrong direction.

The github issue can be found at:
github.com/ksonny/fastcgi-monkey-plugin/issues/1

-- 
Sonny Karlsson
>From bd91cc843cd1234055311ea45dfea11ed9eef0f0 Mon Sep 17 00:00:00 2001
From: Sonny Karlsson <[email protected]>
Date: Sun, 7 Apr 2013 20:07:41 +0200
Subject: [PATCH] plugin: Invoke stage_40 in http_request_end().

Fix a bug where stage_40 is never invoked if plugin ends request outside
of stage_* callbacks.

Bug first discovered by mchubby
(github.com/ksonny/fastcgi-monkey-plugin/issues/1).

Signed-off-by: Sonny Karlsson <[email protected]>
---
 src/mk_plugin.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/mk_plugin.c b/src/mk_plugin.c
index d477f17..c7105d0 100644
--- a/src/mk_plugin.c
+++ b/src/mk_plugin.c
@@ -872,9 +872,19 @@ int mk_plugin_http_request_end(int socket)
 {
     int ret;
     int con;
+    struct client_session *cs;
+    struct session_request *sr;
 
     MK_TRACE("[FD %i] PLUGIN HTTP REQUEST END", socket);
 
+    cs = mk_session_get(socket);
+    if (!mk_list_is_empty(&cs->request_list)) {
+        mk_err("[FD %i] Tried to end non-existing request.", socket);
+        return -1;
+    }
+    sr = mk_list_entry_last(&cs->request_list, struct session_request, _head);
+    mk_plugin_stage_run(MK_PLUGIN_STAGE_40, socket, NULL, cs, sr);
+
     ret = mk_http_request_end(socket);
     MK_TRACE(" ret = %i", ret);
 
-- 
1.7.10.4

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to