You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Jérôme Renard <jr...@ez.no> on 2008/09/17 10:04:07 UTC
[apr_dbd] apr_dbd_datum_get example
Good morning.
I am actually working on a apache module which uses apr_dbd.
Here is what I need to do :
In a mysql database I have a table which stores files splitted
in 64Kb rows each and stored in a BLOB.
I get (almost) all the code working fine so far except for the most
important point. I am not able to fetch BLOBs, whenever I
try to use apr_dbd_datum_get, Apache crashes. I am sure this is
due to a wrong use of the API, but I can not find my mistake.
Hence my question : is there any example of apr_dbd_datum_get ?
I googled and searched in other modules but found nothing.
The actual code is below but I am sure it is wrong (stupid ?) :
[...]
void *data = NULL;
[...]
for (rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1);
rv != -1;
rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1)) {
data = apr_palloc(r->pool, 65536);
/* TODO : output filedata : BLOB */
if( apr_dbd_datum_get(dbd->driver, row, 3, APR_DBD_TYPE_BLOB, data) == -1 )
{
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "Unable to fetch BLOB");
}
}
And the backtrace :
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x0000000c
0x00130eb2 in apr_bucket_alloc (size=36, list=0x0) at buckets/apr_buckets_alloc.c:120
120 apr_memnode_t *active = list->blocks;
(gdb) bt
#0 0x00130eb2 in apr_bucket_alloc (size=36, list=0x0) at buckets/apr_buckets_alloc.c:120
#1 0x006ed9a7 in apr_bucket_lob_create (row=0x720018, col=3, offset=0, len=65535, p=0x18f1c18, list=0x0) at dbd/apr_dbd_mysql.c:203
#2 0x006ee0c3 in dbd_mysql_datum_get (row=0x720018, n=3, type=APR_DBD_TYPE_BLOB, data=0x11f8018) at dbd/apr_dbd_mysql.c:437
#3 0x00147e99 in apr_dbd_datum_get (driver=0x6f00c0, row=0x720018, col=3, type=APR_DBD_TYPE_BLOB, data=0x11f8018) at dbd/apr_dbd.c:558
#4 0x006e5cf8 in ezclustered_image_handler (r=0x18f1c58) at mod_ezclustered_image.c:149
#5 0x0001b716 in ap_run_handler (r=0x18f1c58) at config.c:157
#6 0x0001bf5c in ap_invoke_handler (r=0x18f1c58) at config.c:372
#7 0x0002d43f in ap_process_request (r=0x18f1c58) at http_request.c:258
#8 0x000296d4 in ap_process_http_connection (c=0x18d31c0) at http_core.c:190
#9 0x000246f5 in ap_run_process_connection (c=0x18d31c0) at connection.c:43
#10 0x00024b6e in ap_process_connection (c=0x18d31c0, csd=0x18d2e58) at connection.c:178
#11 0x00033fe4 in child_main (child_num_arg=0) at prefork.c:650
#12 0x00034104 in make_child (s=0x1808310, slot=0) at prefork.c:690
#13 0x000347b6 in ap_mpm_run (_pconf=0x1806418, plog=0x1834418, s=0x1808310) at prefork.c:966
#14 0x00003215 in main (argc=2, argv=0xbffff74c) at main.c:730
Thanks in advance for any help and please accept my excuses if my question is
utter stupid.
Have a nice day
Best Regards.
--
Jérôme :)
Re: [apr_dbd] apr_dbd_datum_get example
Posted by Jérôme Renard <jr...@ez.no>.
I actually fixed my issue with the following code :
for (rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1);
rv != -1;
rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1)) {
file_data = apr_brigade_create(r->pool, r->connection->bucket_alloc);
if(apr_dbd_datum_get(dbd->driver, row, 3, APR_DBD_TYPE_BLOB, file_data) != APR_SUCCESS)
{
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "Unable to fetch file data");
apr_brigade_destroy(file_data);
return DECLINED;
}
apr_brigade_destroy(file_data);
}
I am not sure it is correct though.
Thanks in advance for any help.
--
Jérôme :)
Re: [apr_dbd] apr_dbd_datum_get example
Posted by Jérôme Renard <jr...@ez.no>.
Arturo 'Buanzo' Busleiman a écrit :
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> Jérôme Renard wrote:
>> No idea ?
>
> I got a lot of nice code out of this file:
> $APACHE_SRC_DIR/modules/cache/mod_socache_dbm.c
I got it from SVN :
http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/
Thanks!
--
Jérôme :)
Re: [apr_dbd] apr_dbd_datum_get example
Posted by Arturo 'Buanzo' Busleiman <bu...@buanzo.com.ar>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Jérôme Renard wrote:
> No idea ?
I got a lot of nice code out of this file:
$APACHE_SRC_DIR/modules/cache/mod_socache_dbm.c
Hope it helps you!
- --
Arturo "Buanzo" Busleiman
Independent Linux and Security Consultant - SANS - OISSG - OWASP
http://www.buanzo.com.ar/pro/eng.html
Mailing List Archives at http://archiver.mailfighter.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFI2YHhAlpOsGhXcE0RCpd8AJ945w0jjI9SYfsTSJ+0q7kqbcYbzACfUH8W
IwuwIYSbo4CPFWpPjDdMkK0=
=o/cr
-----END PGP SIGNATURE-----
Re: [apr_dbd] apr_dbd_datum_get example
Posted by Jérôme Renard <jr...@ez.no>.
Jérôme Renard a écrit :
[...]
No idea ?
Thanks in advance.
Best Regards.
--
Jérôme :)