Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 35480 invoked from network); 26 Oct 2006 04:17:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Oct 2006 04:17:08 -0000 Received: (qmail 95776 invoked by uid 500); 24 Oct 2006 15:53:16 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 95728 invoked by uid 500); 24 Oct 2006 15:53:15 -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 95623 invoked by uid 99); 24 Oct 2006 15:53:15 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Oct 2006 08:53:14 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [81.88.129.4] (HELO mail.noip.sk) (81.88.129.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Oct 2006 08:52:59 -0700 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by mail.noip.sk (Postfix) with ESMTP id A218C2EB60 for ; Tue, 24 Oct 2006 17:55:37 +0200 (CEST) Message-ID: <453E36C3.3040800@noip.sk> Date: Tue, 24 Oct 2006 17:52:35 +0200 From: bronto User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: modules-dev@httpd.apache.org Subject: Re: dropping a connection abruptly Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hello experts, I think i can give you some point to go to with this socket thing. We are on project, where we have to get the socket descriptor out of the apache thus we can use it with external libraries. In one time I've found myself with grep and apache sources, google and a lot of coffee ;) We are on Linux (64 bit architecture). here's how to get socket from apache in module: static int my_post_read_request(request_rec *r) { conn_rec *conn = r->connection; apr_socket_t *csd = ((core_net_rec *)conn->input_filters->ctx)->client_socket; ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "mod_my_download: client socket file descriptor: %d",csd->socketdes); return OK; } static void my_register_hooks(apr_pool_t *p) { ap_hook_post_read_request(my_post_read_request, NULL, NULL, APR_HOOK_REALLY_FIRST); } module AP_MODULE_DECLARE_DATA my_download_module = { STANDARD20_MODULE_STUFF, NULL, NULL, NULL, NULL, NULL, my_register_hooks }; so in my_post_read_request(..) you will have csd->socketdes at one point. This is fully functional socket descriptor. I really believe this is not the way apache team would like mod developers to play with sockets...I believe they don't want it at all (i guess, that's the point of storing apr_socket as (void) pointer in input_filters->ctx :) ). If you know any cleaner (better), way how to do this, I would appreciate any comments. I'll be glad, if this helps. Anyway, why i got interested in your mail Roy. You mention there some approach to mark a connection as aborted. If one _marks_ a connection as aborted, will: - apache close this connection right after return from module ? - if yes, is there a way to preserve this socket? - apache send anything to the (appropriate) socket (connection)? In general, I want to read headers and check the URL. If it's in certain namespace, I would like to: - tell apache to forget about this connection (mark as aborted?) - pass socket from this connection to 'worker' (my own thread inside apache, which will know what to do) - return from module, and rely on apache to let this connection as is (no data, no further read() from socket, no other modules touch it etc.) If I'm confusing about something, reply please and I will extend(explain) my thoughts. Best regards, Stefan On Oct 23, 2006, at 2:22 PM, Brian McQueen wrote: > This is sounding good. How do I gain the level of control that you > are describing here? The request_rec has a conn_rec, but I don't see > how to get beyond that. If I've successfully read 4096 bytes, how do > I then stop any further transactions on the socket? I don't know how > to grab the socket in order to close it! There is a (at least one) way to mark the connection as aborted after the read. I'd explain, but have too much on my plate right now (flight to switzerland in the morning). Search for "aborted" in the code and see what others do. ....Roy