Bojan Smojver
Wed, 23 Jul 2008 00:13:50 -0700
On Wed, 2008-07-23 at 17:00 +1000, Bojan Smojver wrote:
> When you create your socket with apr_socket_create(), there is a pool
> argument there. If you hang a cleanup off it, it will run before close()
> in socket_cleanup().
Example constructor:
--------------------------
struct my_socket_t{
apr_socket_t *s;
void *other_stuff;
};
typedef struct my_socket_t my_socket_t;
static apr_status_t my_close(void *data){
my_socket_t *s=data;
return my_fancy_thing_with_the_socket(s);
}
static apr_status_t db_create(void **rsc,void *parms,apr_pool_t *pool){
my_socket_t *s;
s=apr_pcalloc(pool,sizeof(*s));
apr_socket_create(&s->s,<can't remember what>,pool);
s->other_stuff=parms;
apr_pool_cleanup_register(pool,s,my_close,apr_pool_cleanup_null);
*rsc=s;
return APR_SUCCESS;
}
--------------------------
--
Bojan