December 6th Thursday (十二月 六日 木曜日)

  The apr_pool_cleanup_register() provided by APR is for managing memory, as well as a few other basic resources
such as files, sockets, and mutexes.

class poolclass {
private:
  apr_pool_t* pool;
public:
  poolclass(apr_pool_t* p) : pool(p) {
    apr_pool_cleanup_register(pool, (void*)this, myclassCleanup, apr_pool_cleanup_null);
  }

  virtual ~poolclass(){
    apr_pool_cleanup_kill(pool, (void*)this, myclassCleanup);
  }
};

  You can also streamline the kill the cleanup and free by running the cleanup and unregistering it with
the pool using a single function:
  apr_pool_cleanup_run(pool, my_res, my_res_free);

  In Apache, there are four pool structures corresponding to different types of resource.

  * The request pool, with the lifetime of an HTTP request (request->pool)
  * The process pool, with the lifetime of a server process (process->pool)
  * The connection pool, with the lifetime of a TCP connection (connection->pool)
  * The configuration pool (process->pconf)

  The fourth is also associated with the process, but differs from the process pool in that it is cleared
whenever Apache rereads its configuration.

  The process pool is suitable for long-lived resources, such as those that are initialized at server start-up.
The request pool is suitable for transient resources used to process a single request.

  The connection pool has the lifetime of a connection, which normally consists of one or more requests.  This
pool is useful for transient resources that cannot be associated with a request--most notably, in a connection-
level filter, where the request_rec structure is undefined, or in a non-HTTP protocol handler.

  In addition to these standard pools, special-purpose pools may be created for other purposes, such as configuration
and logging, or may be created privately by modules for their own use.

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值