Re: ap_log_rerror limit size
On Wed, Mar 13, 2013 at 04:40:50PM +0100, Hoang-Vu Dang wrote: I traced this into the Apache source code (ver 2.4.4). It looks like the error message string is really limited by the size of 8KB. This line is in server/log.c:1097 static void log_error_core(const char *file, int line, int module_index, int level, apr_status_t status, const server_rec *s, const conn_rec *c, const request_rec *r, apr_pool_t *pool, const char *fmt, va_list args) { char errstr[MAX_STRING_LEN]; And MAX_STRING_LEN is defined in include/httpd.h:298 /** The default string length */ #define MAX_STRING_LEN HUGE_STRING_LEN /** The length of a Huge string */ #define HUGE_STRING_LEN 8192 I tried to increase this value, recompile, and apparently I got a longer message. Please correct me if I am wrong... If this is true then can anyone tell me why this HUGE_STRING_LEN value is a hard-coded value but not a configurable option ? I can't speak for the apache core team, but such a limit usually is done for security reasons. Tracking buffer overflows in dynamically allocated memory can be rather tricky. Btw, what's your goal here? I get the feeling that you try to (ab)use the error log as a place to dump large blobs of information (traces?). Remember, this is an error log, not a place to dump Tolstoy's War and Peace HTH Ralf Mattes Cheers, Vu that you try to (ab)use the error log as a place to dump large blobs of information (traces?). Remember, this is an error log, not a place to dump Tolstoy's War and Peace HTH Ralf Mattes On 03/13/2013 11:16 AM, Eric Covener wrote: On Wed, Mar 13, 2013 at 6:01 AM, Hoang Vu Dang dang@gmail.com wrote: Hi guys, Is there any limit of the size of a message log entry? How to control this ? I did this: ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, f-r, %s, buffer); And the buffer was truncated on the error log. I check the strlen of the buffer and it was about 320K, and I got only around: ~ 8KB If it's more than PIPE_BUF, it won't be atomic and can be interleaved with other entries. Are you sure it's truncated and not just spread out?
Delegating to confiured error page from within a filter
Dear collected list wisdom, I think I'm hitting a wall here: my module's filter needs to replace the running request with the configured error page for that error (all in the 4xx range). The error is detected before any content is pushed down the bucket line. Setting the request's status will produce the correct HTTP status line but (of course?) it won't send the error document as configured in the server's configuration. Any ideas? TIA Ralf Mattes
Re: Delegating to confiured error page from within a filter
On Mon, Feb 11, 2013 at 10:26:41PM +0100, r...@tuxteam.de wrote: Dear collected list wisdom, I think I'm hitting a wall here: my module's filter needs to replace the running request with the configured error page for that error (all in the 4xx range). The error is detected before any content is pushed down the bucket line. Setting the request's status will produce the correct HTTP status line but (of course?) it won't send the error document as configured in the server's configuration. Any ideas? Answering my own question: ap_send_error_response(filter-r, 0) seems to work just fine (but feels slightly wrong ;-) Cheers, RalfD TIA Ralf Mattes
Re: Fwd: Document on developing modules for 2.4 and onwards
On Wed, Apr 11, 2012 at 11:12:31AM +0200, Daniel Gruno wrote: As per Igor's advice, I'm forwarding this message to the dev@ and modules-dev@ lists as well: Hello all httpd document lovers, As per our nifty little STATUS document, it came to my attention that we were missing an introductory segment on how to develop simple modules for httpd 2.4, so I took the liberty of drawing up a proposal for what we could put in place for this request. The draft is located at http://httpd.apache.org/docs/trunk/developer/modguide.html and I would much appreciate it if you guys could give me some feedback on whether this will fit in as an, at least for the time being, appropriate document to describe how to develop modules for the server. I plan to expand on the subject, probably add another 10 pages or so, during the summer, as well as letting it into the 2.4 fold, provided I get positive feedback from this mailing list. So, please do read the document and tell me what you think :) Any suggestions, critique etc you might have will be warmly accepted. With regards, Daniel. More comments: first, it might be a matter of style (or good habbits) but i think you should cast void pointers to the correct type in your code. So: example_config* base = BASE ; should be: example_config* base = (example_config*) BASE ; A real bug? strcpy(conf-path, strlen(add-path) ? add-path : base-path); Don't you mean strncpy here? BTW, 'char path[256];' is pretty dangerous, there are OS/Compiler constants that provide the operating sytem's max path length. Cheers, RalfD
Re: Inject html into response body
On Sun, Dec 04, 2011 at 11:47:37PM +0200, O??uzhan TOPG?L wrote: Hi, I' ve search for all the archieve but i couln't find the answer, may be i missed up, don't know. I'm trying to write an apache module and i want to inject some html code into resonses. It might be in body, header or footer. The only thing that i want to implemet is inserting an url or a text into all response bodies without damaging the original page that is serving. Is there any basic way of doing that? Well, why don't you just write an output filter that does this? I think Nick's book will provide all the information you need. Or have a look at mod_include in apache's source code. Cheers, Ralf Mattes thanks Oguzhan
Re: Binary Tree Shared Memory Problem
On Tue, Nov 29, 2011 at 12:29:20AM +0200, O??uzhan TOPG?L wrote: Hi, is there any example mod_slotmem codes that we can understand the usage? Have you looked at the code? 'mod_slotmem_shm.c' is less than 650 lines of code, 'mod_slotmem_plain.c' less than 300. Sorry, but you have to do _some_ reading yourself. Or could you give me an usage example? For example we are using apr_shm_create() in post_config, but mod_slotmem is a little bit hard to understand i think. And i want to ask a question, is it a problem to create typedef struct node { ELEMENT node_element; struct node *left; struct node *right; }NODE; kind of struct. A struct that has two struct elements. No, it doesn't. It holds two _pointers_ to node structures (learn some C as well ..). You can't share such a structure since the address in *left or *right will only be valid in one process. You could store an offset to the node's base address in left/right and write some support code to do all the pointer magic to get/set these values but you still would need to write your own memory allocator and tree balancing code and somehow I get the feeling that's to demanding a task ... We've had similr questions in the ML just recently - consult the archive. HTH Ralf Mattes As i mentioned before what i'm trying to implement is a binary tree as a data structure. regards O??uzhan TOPGÜL On Mon, Nov 28, 2011 at 11:52 PM, Ignaz Birnstingl ign...@gmail.com wrote: Hi, apr_shm_baseaddr_get returns the base address for the shared memory segment. You will have to implement your own allocator within the shared memory. Also keep in mind that you can't reliably use pointers inside the shared memory segment, because - as the documentation states - the address returned by apr_shm_baseaddr_get is only usable within the callers address space, since this API does not guarantee that other attaching processes will maintain the same address mapping. Inter- and intra-process synchronization will be problems you will encounter later on. Btw Apache 2.3 offers mod_slotmem which helps in using shared memory - maybe you should have a look at it? -- Ignaz
Re: apr shared memory handling
On Mon, Nov 14, 2011 at 02:18:20PM +0100, michaelr wrote: Hi all, first excuse my bad english. As a beginner in apache module development i have a problem understanding the apr shared memeory handling. In the following example i removed all the locks and error handling to bring my problem in front. Even the malloc and free calls are only for testing purposes (in a real module i will use memory pools). As an example i have the following struct defined in my header: typedef struct { unsigned int active ; char *test ; } shm_seg_t ; That char pointer smells funky! [...] // malloc just for testing purposes! acl_pool-test = (char *) malloc ( 40 * sizeof(char) ); And here is why: acl_pool-test will now point to an address on the current process' heap. That's just a number with no relevance to other processes. strcpy(acl_pool-test, POSTCONFIGHANDLER); fprintf(stderr, post: -- %s\n, acl_pool-test); fflush(stderr); Yes, because you read from your own memory. This works. So in the module handler i can access the varaibles like this: apr_shm_attach(acl_pool_shm, /tmp/file, r-pool) ; acl_pool = (shm_seg_t *) apr_shm_baseaddr_get(acl_pool_shm) ; printf(stderr, HANDLER: -- %d - %s\n, acl_pool-active, acl_pool-test) ; fflush(stderr) ; Everything is fine until here - it prints out: HANDLER: -- 0 - POSTCONFIGHANDLER to the error log. I want to update the data in the shared memeory segement in an monitor_hook which i set up also. In the monitor_hook i do the following: apr_shm_attach(acl_pool_shm, /tmp/file, p) ; acl_pool = (shm_seg_t *) apr_shm_baseaddr_get(acl_pool_shm) ; acl_pool-active++ ; if ( acl_pool-test != NULL) { free(acl_pool-test) ; Kawoom! You just handed free a number that has only meaning within the context of the process that did _set_ this number. There's no magic to get your hands on another processes memory (at least not since Mac Os7 and OS/2 left this planet). acl_pool-test = (char *) malloc(40 * sizeof(char)) ; strcpy(acl_pool-test, SCHEDULER) ; fprintf(stderr, scheduler: -- %s\n, acl_pool-test) ; fflush(stderr) ; } Now i run into the problem that the module_handler did'nt recognise the changes i have made so far in the monitor_hook. acl_pool-test did not change in the child process and it always prints out: HANDLER: -- 1 - POSTCONFIGHANDLER HANDLER: -- 2 - POSTCONFIGHANDLER HANDLER: -- 3 - POSTCONFIGHANDLER The integer varaibles get incremented as expected. The dynamic variable: char *test did'nt change at all. I set MaxRequestsPerChild to zero in this first try. Yes, acl_pool-active is a storage location, i.e. the value get's stored and read from shared memory, but acl_pool-test is only a _pointer_ to a storage location local to one process. When i set MaxRequestsPerChild to 4 for something else below and the childs get restarted by the root-Server the next call to the module-handler prints out: HANDLER: -- 1 - SCHEDULER Here you most likely happen to get the request served from the same process where acl_pool-test _happens_ to point to the right location ... So my questions is: Why i can not see the changes which the monitor hook has done until the childs gets restarted? The integer variable is readable with the correct update at any time. You would have to allocate the character data from shared memory, but keep in mind that even then a simple pointer wouldn't work (since one location in shared memory can and will have different addresses in different processes). A bit of googling will bring you further material (this has been discussed in this mailing list abd elsewhere). HTH Ralf Mattes Thank's for your help. Greetings Michael
Re: using mod_proxy for subrequests
On Wed, May 04, 2011 at 02:00:33PM +0200, Sorin Manolache wrote: I didn't mean that I'm really clueless. I trawled through the apache sources quite extensively and I decided to do it. And there's a commercial/financial stake in my case too. If you look at mod_proxy's sources, there're 4 places in which r-main is checked, two in ap_proxy_http_request, one in ap_proxy_backend_broke and one in mod_proxy_ajp.c In the first place, If-Match, If-None-Match, If-Range, If-Modified-Since, If-Unmodified-Since are not passed through in the subrequest. In the second place, for subrequests: *) the connection is marked to be closed after the request *) Content-Length and Transfer-Encoding are removed *) the main request body, if any, is not forwarded to the subrequest's backend. So if you set subreq-main to NULL you won't have the effects listed above. In ap_proxy_backend_broke, if r is a subrequest and the backend broke, the main request response is marked as non-cacheable. I didn't look into mod_proxy_ajp.c. Yes, but what makes me feel quite uneasy is the fact that both your solution as well as mine rely on internal knowledge and assumptions build on that. From a programmers point of view this is o.k. in an open source implementation but this creates administrative nightmares ... What happens iff the programmers of mod_proxy decide to change their internal processing? After all, line 426 ff. in mod_proxy.c aren't part of a published API. So, maybe years after installing your fine module, an inocent software update breaks it ... 8-/ I guess an exported mod_proxy function to fetch metadata would be a nice thing to have. Cheers, RalfD Sorin
Re: Strange EOS bucket in filter
On Sat, Oct 23, 2010 at 12:55:05PM +0200, r...@tuxteam.de wrote: On Sat, Oct 23, 2010 at 11:22:20AM +0100, Nick Kew wrote: On 23 Oct 2010, at 11:06, r...@tuxteam.de wrote: Hello list, I'm currently developing an output filter that , dpending on some condition either parses all data to convert it (and hence don't pass any of the incomming buckets down the pipe) or decides to leave the data as it is and just pushes all incomming buckets down. Now, strangely, for the second case every second request my filter only gets an EOS bucket (as the first bucket te filter sees) for all resources that the filter doesn't need to touch. This only seems to happen for requests with keep-alive true. That somehow sounds like someting I've encoutered before but I can't recall when or where :-/ Any ideas what's going on? Are you clearing all the input once you've consumed it? You mean input buckets that i get as a the brigade parameter in my filter callback? Yes, at least mod_diagnostics shows an EOS buffer comming from my filter as the last buffer for that request. Strange Ah, found some hint: this only happens when I run the request through a proxy (had accidently set http_proxy in my debugging shell ...). Hm: I can narrow this dow to a second request with an If-Modified-Since header with the same value as the last sent Last-Modified header. So 304/Not-Modified will still chase an EOF through the content filter chain? Good to know ... Thanks RalfD -- Nick Kew