Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BBB7D105ED for ; Fri, 27 Sep 2013 09:15:38 +0000 (UTC) Received: (qmail 79184 invoked by uid 500); 27 Sep 2013 09:12:37 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 78952 invoked by uid 500); 27 Sep 2013 09:12:18 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 78934 invoked by uid 99); 27 Sep 2013 09:12:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Sep 2013 09:12:12 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of pon.umapathy@gmail.com designates 209.85.217.177 as permitted sender) Received: from [209.85.217.177] (HELO mail-lb0-f177.google.com) (209.85.217.177) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Sep 2013 09:12:07 +0000 Received: by mail-lb0-f177.google.com with SMTP id w7so2003937lbi.22 for ; Fri, 27 Sep 2013 02:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=SWxcoLTL1wXuOL4XEHB/l0prZHXU0eFyrWIog4MaJaA=; b=DUfmRMTprC4WlCTcTYUX8bVsVUcbblyxpjB2qoUQu49PLvRRArvbYeelYGpe/j6IsG rp8xU77ea/f7uV8dPKyoBsPGKsg1YC6uSmnaXpd0Dqc9dpAPWwI3AqJCMtolDSGjuyJT Sdhj1lYBa7ZR+uY44n8SPKr1cOsuGusPwZuve5T2dgtsVg95705ToE8Eb0ChGTogmasK kjBklGRysAGSKWFqlV4I4WtOZwKDIfrz2eojQ2jQnVigdXs4/QAzzL3OfD+HQTNFPtkc 3miMrtTlOMRzPyqLf/tY9MsVsPirdKXZL7Q5nAfXM333W2+FqAdVwlV427zm8mu6cATS KNaA== MIME-Version: 1.0 X-Received: by 10.112.157.67 with SMTP id wk3mr1536503lbb.32.1380273105572; Fri, 27 Sep 2013 02:11:45 -0700 (PDT) Received: by 10.114.82.65 with HTTP; Fri, 27 Sep 2013 02:11:45 -0700 (PDT) In-Reply-To: <52452CDF.3090906@gmail.com> References: <52452CDF.3090906@gmail.com> Date: Fri, 27 Sep 2013 14:41:45 +0530 Message-ID: Subject: Re: response handling inside ap_hook_create_request cb function From: Pon Umapathy Kailash S To: modules-dev@httpd.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Thanks for your response, Sorin. My concern in this approach is that - it would require one worker thread to be held up for as long as this connection is open(and this might be long + the number of clients can be higher than the worker threads for my use-case/platform). Given that the 1st handshake message is over http, i can setup the connection in a handler hookup function and return a response, freeing up the worker thread while keeping the connection persistent(plus save the socket/ssl in a cache shared the worker threads). Now, when the next set of messages come in(which is not over http), I would need to intercept these and add my handling(ideally write something on the socket on which the message came and be done with the request while keeping the connection persistent unless the message was a control frame to close). Regards, Umapathy On Fri, Sep 27, 2013 at 12:29 PM, Sorin Manolache wrote: > On 2013-09-27 03:06, Pon Umapathy Kailash S wrote: >> >> Hi, >> Here is a quick background on what I am trying to do(basically adding >> support for websockets - in a slightly customised manner as needed for >> my app): >> >> - Handle the initial handshake inside a cb function registered as a >> handler hook(from here, I compute checksums required and return the >> response headers as needed). >> Also, the socket from which the request was read is stored in a cache. >> >> - For subsequent message reception(on the same connection), i have a >> function cb registered using ap_hook_create_request(since this is a >> different protocol format message). Here, I read and parse the >> messages/requests which are coming in from the cached list of >> sockets(this is working). >> >> However, once I return from this cb, the connection/socket seems to be >> closed. I guess the request is further passed down to hooks down the >> line and the connection is closed since the req format is not known. >> >> What would be the best way to handle this scenario? >> >> I have the following in mind: >> - let the request not be processed any further(and keep the connection >> on). >> - create a req structure with dummy http headers that i can later >> recognise and handle inside my handler hook to just ignore later on >> >> are there any examples/notes on how these can be achieved? > > > In my opinion, it is too late to handle non-http in the create_request > callback. > > The create_request callback is called from > ap_run_process_connection->ap_process_http_{sync|async}_connection->ap_read_request. > > Your create_request callback returns to ap_read_request from where the > request is further processed as an http request. > > In my opinion you should short-cut the http processing and hook > ap_hook_process_connection. However, there, in process_connection, you have > no request_rec, you have just a conn_rec. process_connection is called only > once per connection creation. So it should handle all the requests that > arrive while the connection is open. > > Sorin > > > > > >> >> Regards, >> Umapathy >> >