A simple module doesnt work.

2009-07-24 Thread Jieyun Fu
Hi All,

I am trying to write a simple apache module, and this module works on Apache
2.0 but not on Apache 2.2. The problem happens in ap_get_module_config
(bolded in the code). Any clue about the possible cause?

Thanks in advance
[CODE]
#include 
#include 
#include 
#include 
#include 
#include 
#include 

typedef struct {
  const char* conf_path;
  bool model;
  bool limit;
} my_config;

extern "C" module AP_MODULE_DECLARE_DATA my_module;

static const char*
setpath(cmd_parms *parms, void *dummy, const char *arg) {
  my_config *cfg = (my_config *)
ap_get_module_config(parms->server->module_config, &my_module);  *[B]//
Here, value of ap_get_module_config always null.[/B]*
  cfg->conf_path = arg;
  return NULL;
}

static void*
make_conf(apr_pool_t *p, server_rec *s)  {
  my_config *cfg =
(my_config *)apr_palloc(p, sizeof(my_config));
  cfg->conf_path = NULL;
  cfg->model = TRUE;
  cfg->limit = TRUE;
  return (void *)cfg;
}

static const command_rec com_table[] = {
  {"directive name", (cmd_func)setpath,
   NULL, RSRC_CONF, TAKE1,
   "hello message"},
  {NULL}
};

extern "C" {
module my_module = {
STANDARD20_MODULE_STUFF,
NULL,   /* create per-directory config structures */
NULL,   /* merge per-directory config structures  */
make_conf, /* create per-server config structures*/
NULL,   /* merge per-server config structures */
com_table, /* command handlers */
NULL  /* register hooks */
 };
};
[/CODE]


Problems in my module

2009-07-24 Thread ricardo13

Hi,

My idea's create queues for prioritize requests, so I would want handle
requests (perfectly as worker.c, but not handle sockets).
File worker.c adds and removes sockets in a queue. I want to create two
queues of request where there is 2 threads. One thread adds request,
according classification, and another threads "gets" a request and process
it.

This picture shows exactly my idea.

http://www.nabble.com/file/p24645448/imagem.jpg 

I developed a module using post_read_request hook, but doesn't work because
each request, the module create 2 threads, 2 queues, et cetera. This is my
doubt.

Thank you
Ricardo
-- 
View this message in context: 
http://www.nabble.com/Problems-in-my-module-tp24645448p24645448.html
Sent from the Apache HTTP Server - Module Writers mailing list archive at 
Nabble.com.



Re: How do I debug a module ?

2009-07-24 Thread ricardo13

Hi,

I thought that ap_process_request was a parameter for GDB. Sorry !!
Then, Is ap_process_request a function in http_request.c ?

Thank you
Ricardo


Tom Evans-3 wrote:
> 
> On Fri, 2009-07-24 at 03:00 -0700, ricardo13 wrote:
>> hi,
>> 
>> The GDB session is very large.
>> 
> 
>> 
>> My module calls mod_teste !!!
>> 
>> Thank you
>> Ricardo
>> 
>> 
>> 
> 
> So whats the problem? It seems to be working fine. Your breakpoint is on
> ap_process_request, and you single step through it, successfully.
> 
> If you want to debug your module, set a breakpoint in your module. 
> 
> Cheers
> 
> Tom
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-do-I-debug-a-module---tp24630579p24642497.html
Sent from the Apache HTTP Server - Module Writers mailing list archive at 
Nabble.com.



Re: How do I debug a module ?

2009-07-24 Thread Tom Evans
On Fri, 2009-07-24 at 03:00 -0700, ricardo13 wrote:
> hi,
> 
> The GDB session is very large.
> 

> 
> My module calls mod_teste !!!
> 
> Thank you
> Ricardo
> 
> 
> 

So whats the problem? It seems to be working fine. Your breakpoint is on
ap_process_request, and you single step through it, successfully.

If you want to debug your module, set a breakpoint in your module. 

Cheers

Tom



Re: How do I debug a module ?

2009-07-24 Thread ricardo13

hi,

The GDB session is very large.

mach...@tkt-test:/usr/local/apache2$ sudo gdb bin/httpd
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later

This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
(gdb) b ap_process_request
Breakpoint 1 at 0x80b0fe9: file http_request.c, line 276.
(gdb) run -X -d /usr/local/apache
Starting program: /usr/local/apache2/bin/httpd -X -d /usr/local/apache
[Thread debugging using libthread_db enabled]
httpd: Could not open configuration file /usr/local/apache/conf/httpd.conf:
No such file or directory

Program exited with code 01.
(gdb) run -X -d /usr/local/apache2
Starting program: /usr/local/apache2/bin/httpd -X -d /usr/local/apache2
[Thread debugging using libthread_db enabled]
[New Thread 0xb7d58940 (LWP 4129)]
[New Thread 0xb7cdbb90 (LWP 4131)]
[New Thread 0xb74dab90 (LWP 4132)]
[New Thread 0xb6cd9b90 (LWP 4133)]
[New Thread 0xb64d8b90 (LWP 4134)]
[New Thread 0xb5cd7b90 (LWP 4135)]
[New Thread 0xb54d6b90 (LWP 4136)]
[New Thread 0xb4cd5b90 (LWP 4137)]
[New Thread 0xb44d4b90 (LWP 4138)]
[New Thread 0xb3cd3b90 (LWP 4139)]
[New Thread 0xb34d2b90 (LWP 4140)]
[New Thread 0xb2cd1b90 (LWP 4141)]
[New Thread 0xb24d0b90 (LWP 4142)]
[New Thread 0xb1ccfb90 (LWP 4143)]
[New Thread 0xb14ceb90 (LWP 4144)]
[New Thread 0xb0ccdb90 (LWP 4145)]
[New Thread 0xb04ccb90 (LWP 4146)]
[New Thread 0xafccbb90 (LWP 4147)]
[New Thread 0xaf4cab90 (LWP 4148)]
[New Thread 0xaecc9b90 (LWP 4149)]
[New Thread 0xae4c8b90 (LWP 4150)]
[New Thread 0xadcc7b90 (LWP 4151)]
[New Thread 0xad4c6b90 (LWP 4152)]
[New Thread 0xaccc5b90 (LWP 4153)]
[New Thread 0xac4c4b90 (LWP 4154)]
[New Thread 0xabcc3b90 (LWP 4155)]
[New Thread 0xab4c2b90 (LWP 4156)]
[New Thread 0xaacc1b90 (LWP 4157)]
[Thread 0xb7cdbb90 (LWP 4131) exited]
[Switching to Thread 0xabcc3b90 (LWP 4155)]

/* Here, I request the webpage */

Breakpoint 1, ap_process_request (r=0xa12e048) at http_request.c:276
276 if (ap_extended_status)
(gdb) n
259 {
(gdb) n
276 if (ap_extended_status)
(gdb) n
278 access_status = ap_run_quick_handler(r, 0);  /* Not a look-up
request */
(gdb) n
279 if (access_status == DECLINED) {
(gdb) n
280 access_status = ap_process_request_internal(r);
(gdb) n
281 if (access_status == OK) {
(gdb) n
282 access_status = ap_invoke_handler(r);
(gdb) n
286 if (access_status == DONE) {
(gdb) n
291 if (access_status == OK) {
(gdb) n
292 ap_finalize_request_protocol(r);
(gdb) n
222 conn_rec *c = r->connection;
(gdb) n
226 bb = apr_brigade_create(r->pool, c->bucket_alloc);
(gdb) n
235 if (r->connection->keepalive != AP_CONN_CLOSE) {
(gdb) n
236 if (ap_get_brigade(r->input_filters, bb, AP_MODE_EATCRLF,
(gdb) n
238 c->data_in_input_filters = 0;  /* we got APR_EOF or an error
*/
(gdb) n
246 e = apr_bucket_flush_create(c->bucket_alloc);
(gdb) n
254 APR_BRIGADE_INSERT_HEAD(bb, e);
(gdb) n
255 ap_pass_brigade(r->connection->output_filters, bb);
(gdb) n
307 ap_update_child_status(r->connection->sbh, SERVER_BUSY_LOG, r);
(gdb) n
308 ap_run_log_transaction(r);
(gdb) n
309 if (ap_extended_status)
(gdb) n
311 }
(gdb) n
ap_process_http_connection (c=0xa127968) at http_core.c:192
192 if (ap_extended_status)
(gdb) n
195 if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted)
(gdb) n
198 ap_update_child_status(c->sbh, SERVER_BUSY_KEEPALIVE, r);
(gdb) n
199 apr_pool_destroy(r->pool);
(gdb) n
201 if (ap_graceful_stop_signalled())
(gdb) n
204 if (!csd) {
(gdb) n
205 csd = ap_get_module_config(c->conn_config, &core_module);
(gdb) n
207 apr_socket_opt_set(csd, APR_INCOMPLETE_READ, 1);
(gdb) n
208 apr_socket_timeout_set(csd, c->base_server->keep_alive_timeout);
(gdb) n
183 while ((r = ap_read_request(c)) != NULL) {
(gdb) n
213 }
(gdb) 
worker_thread (thd=0xa0dabc8, dummy=0xa1270b0) at worker.c:548
548 ap_lingering_close(current_conn);
(gdb) 
898 worker_sockets[thread_slot] = NULL;
(gdb) 
899 requests_this_child--; /* FIXME: should be synchronized - aaron
*/
(gdb) 
898 worker_sockets[thread_slot] = NULL;
(gdb) 
900 apr_pool_clear(ptrans);
(gdb) 
901 last_ptrans = ptrans;
(gdb) 
845 while (!workers_may_exit) {
(gdb) 
846 if (!is_idle) {
(gdb) 
847 rv = ap_queue_info_set_idle(worker_queue_info, last_ptrans);
(gdb) 
849 if (rv != APR_SUCCESS) {
(gdb) 
847 rv = ap_queue_info_set_idle(worker_queue_info, last_ptrans);
(gdb) 
849 if

Re: How do I debug a module ?

2009-07-24 Thread Tom Evans
On Thu, 2009-07-23 at 11:51 -0700, ricardo13 wrote:
> hi,
> 
> Thank you for reply.
> 
> I'm following this  http://httpd.apache.org/dev/debugging.html website
> website for debugging. I run command 'n' in GDB and doesn't show my module.
> 
> It show me about worker.c, http_request.c, but nothing about my module.
> What's wrong ??
> 
> My module's using port_read_request hook.
> 
> Thank you
> Ricardo
> 

Show us the debug session?

Cheers

Tom