本文整理汇总了C++中pr_pool_tag函数的典型用法代码示例。如果您正苦于以下问题:C++ pr_pool_tag函数的具体用法?C++ pr_pool_tag怎么用?C++ pr_pool_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pr_pool_tag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: schedule
void schedule(void (*f)(void*,void*,void*,void*),int nloops, void *a1,
void *a2, void *a3, void *a4) {
pool *p, *sub_pool;
sched_t *s;
if (scheds == NULL) {
p = make_sub_pool(permanent_pool);
pr_pool_tag(p, "Schedules Pool");
scheds = xaset_create(p, NULL);
} else {
p = scheds->pool;
}
sub_pool = make_sub_pool(p);
pr_pool_tag(sub_pool, "schedule pool");
s = pcalloc(sub_pool, sizeof(sched_t));
s->pool = sub_pool;
s->f = f;
s->a1 = a1;
s->a2 = a2;
s->a3 = a3;
s->a4 = a4;
s->loops = nloops;
xaset_insert(scheds, (xasetmember_t *) s);
}
示例2: schedule
void schedule(void (*cb)(void *, void *, void *, void *), int nloops,
void *arg1, void *arg2, void *arg3, void *arg4) {
pool *p, *sub_pool;
sched_t *s;
if (cb == NULL ||
nloops < 0) {
return;
}
if (scheds == NULL) {
p = make_sub_pool(permanent_pool);
pr_pool_tag(p, "Schedules Pool");
scheds = xaset_create(p, NULL);
} else {
p = scheds->pool;
}
sub_pool = make_sub_pool(p);
pr_pool_tag(sub_pool, "schedule pool");
s = pcalloc(sub_pool, sizeof(sched_t));
s->pool = sub_pool;
s->cb = cb;
s->arg1 = arg1;
s->arg2 = arg2;
s->arg3 = arg3;
s->arg4 = arg4;
s->nloops = nloops;
xaset_insert(scheds, (xasetmember_t *) s);
}
示例3: make_sub_pool
pr_regex_t *pr_regexp_alloc(module *m) {
pr_regex_t *pre = NULL;
pool *re_pool = NULL;
/* If no regex-tracking list has been allocated, create one. Register a
* cleanup handler for this pool, to free up the data in the list.
*/
if (regexp_pool == NULL) {
regexp_pool = make_sub_pool(permanent_pool);
pr_pool_tag(regexp_pool, "Regexp Pool");
regexp_list = make_array(regexp_pool, 0, sizeof(pr_regex_t *));
}
re_pool = pr_pool_create_sz(regexp_pool, 128);
pr_pool_tag(re_pool, "regexp pool");
pre = pcalloc(re_pool, sizeof(pr_regex_t));
pre->regex_pool = re_pool;
pre->m = m;
/* Add this pointer to the array. */
*((pr_regex_t **) push_array(regexp_list)) = pre;
return pre;
}
示例4: child_add
int child_add(pid_t pid, int fd) {
pool *p;
pr_child_t *ch;
/* If no child-tracking list has been allocated, create one. */
if (!child_pool) {
child_pool = make_sub_pool(permanent_pool);
pr_pool_tag(child_pool, "Child Pool");
}
if (!child_list)
child_list = xaset_create(make_sub_pool(child_pool), NULL);
p = make_sub_pool(child_pool);
pr_pool_tag(p, "child session pool");
ch = pcalloc(p, sizeof(pr_child_t));
ch->ch_pool = p;
ch->ch_pid = pid;
time(&ch->ch_when);
ch->ch_pipefd = fd;
ch->ch_dead = FALSE;
xaset_insert(child_list, (xasetmember_t *) ch);
child_listlen++;
return 0;
}
示例5: init_pools
void init_pools(void) {
if (permanent_pool == NULL) {
permanent_pool = make_sub_pool(NULL);
}
pr_pool_tag(permanent_pool, "permanent_pool");
}
示例6: make_sub_pool
modret_t *pr_module_call(module *m, modret_t *(*func)(cmd_rec *),
cmd_rec *cmd) {
modret_t *res;
module *prev_module = curr_module;
if (m == NULL ||
func == NULL ||
cmd == NULL) {
errno = EINVAL;
return NULL;
}
if (!cmd->tmp_pool) {
cmd->tmp_pool = make_sub_pool(cmd->pool);
pr_pool_tag(cmd->tmp_pool, "Module call tmp_pool");
}
curr_module = m;
res = func(cmd);
curr_module = prev_module;
/* Note that we don't clear the pool here because the function may
* return data which resides in this pool.
*/
return res;
}
示例7: vroot_fsio_stat
int vroot_fsio_stat(pr_fs_t *fs, const char *stat_path, struct stat *st) {
int res, xerrno;
char vpath[PR_TUNABLE_PATH_MAX + 1], *path = NULL;
pool *tmp_pool = NULL;
if (session.curr_phase == LOG_CMD ||
session.curr_phase == LOG_CMD_ERR ||
(session.sf_flags & SF_ABORT) ||
vroot_path_have_base() == FALSE) {
/* NOTE: once stackable FS modules are supported, have this fall through
* to the next module in the stack.
*/
return stat(stat_path, st);
}
tmp_pool = make_sub_pool(session.pool);
pr_pool_tag(tmp_pool, "VRoot FSIO stat pool");
path = vroot_realpath(tmp_pool, stat_path, 0);
if (vroot_path_lookup(NULL, vpath, sizeof(vpath)-1, path, 0, NULL) < 0) {
xerrno = errno;
destroy_pool(tmp_pool);
errno = xerrno;
return -1;
}
res = stat(vpath, st);
xerrno = errno;
destroy_pool(tmp_pool);
errno = xerrno;
return res;
}
示例8: log_failure_event
static void log_failure_event(const char *event_name, int flags) {
int res;
char *msg = NULL;
size_t msg_len = 0;
pool *p;
p = make_sub_pool(log_failure_pool);
pr_pool_tag(p, "FailureLog Message Pool");
res = log_failure_fmt_msg(p, log_failure_fmt, event_name, &msg, &msg_len,
flags);
if (res < 0) {
pr_trace_msg(trace_channel, 2, "error formatting message: %s",
strerror(errno));
} else {
res = write(log_failure_fd, msg, msg_len);
while (res < 0) {
int xerrno = errno;
if (xerrno == EINTR) {
pr_signals_handle();
res = write(log_failure_fd, msg, msg_len);
continue;
}
pr_trace_msg(trace_channel, 2, "error writing message to FailureLog: %s",
strerror(xerrno));
break;
}
}
destroy_pool(p);
}
示例9: proxy_db_init
int proxy_db_init(pool *p) {
const char *version;
if (p == NULL) {
errno = EINVAL;
return -1;
}
if (db_pool != NULL) {
return 0;
}
/* Check that the SQLite headers used match the version of the SQLite
* library used.
*
* For now, we only log if there is a difference.
*/
version = sqlite3_libversion();
if (strcmp(version, SQLITE_VERSION) != 0) {
(void) pr_log_writefile(proxy_logfd, MOD_PROXY_VERSION,
"compiled using SQLite version '%s' headers, but linked to "
"SQLite version '%s' library", SQLITE_VERSION, version);
}
pr_trace_msg(trace_channel, 9, "using SQLite %s", version);
db_pool = make_sub_pool(p);
pr_pool_tag(db_pool, "Proxy Database Pool");
return 0;
}
示例10: pr_class_open
int pr_class_open(pool *p, const char *name) {
pr_class_t *cls;
pool *cls_pool;
if (!p || !name) {
errno = EINVAL;
return -1;
}
/* Allocate a sub pool from the given pool, from which a new Class will
* be allocated.
*/
cls_pool = make_sub_pool(p);
pr_pool_tag(cls_pool, "<Class> Pool");
cls = pcalloc(cls_pool, sizeof(pr_class_t));
cls->cls_pool = cls_pool;
cls->cls_name = pstrdup(cls->cls_pool, name);
cls->cls_satisfy = PR_CLASS_SATISFY_ANY;
/* Change the configuration context type. */
main_server->config_type = CONF_CLASS;
curr_cls = cls;
return 0;
}
示例11: mcache_init
static int mcache_init(void) {
const char *version;
memcache_pool = make_sub_pool(permanent_pool);
pr_pool_tag(memcache_pool, MOD_MEMCACHE_VERSION);
memcache_server_lists = make_array(memcache_pool, 2,
sizeof(memcached_server_st **));
memcache_init();
pr_event_register(&memcache_module, "core.restart", mcache_restart_ev, NULL);
version = memcached_lib_version();
if (strcmp(version, LIBMEMCACHED_VERSION_STRING) != 0) {
pr_log_pri(PR_LOG_INFO, MOD_MEMCACHE_VERSION
": compiled using libmemcached-%s headers, but linked to "
"libmemcached-%s library", LIBMEMCACHED_VERSION_STRING, version);
} else {
pr_log_debug(DEBUG2, MOD_MEMCACHE_VERSION ": using libmemcached-%s",
version);
}
return 0;
}
示例12: dynmasq_init
static int dynmasq_init(void) {
#if defined(PR_SHARED_MODULE)
pr_event_register(&dynmasq_module, "core.module-unload",
dynmasq_mod_unload_ev, NULL);
#endif /* !PR_SHARED_MODULE */
pr_event_register(&dynmasq_module, "core.postparse", dynmasq_postparse_ev,
NULL);
pr_event_register(&dynmasq_module, "core.restart", dynmasq_restart_ev,
NULL);
#ifdef PR_USE_CTRLS
if (pr_ctrls_register(&dynmasq_module, "dynmasq", "mod_dynmasq controls",
dynmasq_handle_dynmasq) < 0) {
pr_log_pri(PR_LOG_NOTICE, MOD_DYNMASQ_VERSION
": error registering 'dynmasq' control: %s", strerror(errno));
} else {
register unsigned int i;
dynmasq_act_pool = make_sub_pool(permanent_pool);
pr_pool_tag(dynmasq_act_pool, "DynMasq Controls Pool");
for (i = 0; dynmasq_acttab[i].act_action; i++) {
dynmasq_acttab[i].act_acl = palloc(dynmasq_act_pool, sizeof(ctrls_acl_t));
pr_ctrls_init_acl(dynmasq_acttab[i].act_acl);
}
}
#endif /* PR_USE_CTRLS */
return 0;
}
示例13: pr_ctrls_add_arg
int pr_ctrls_add_arg(pr_ctrls_t *ctrl, char *ctrls_arg) {
/* Sanity checks */
if (!ctrl || !ctrls_arg) {
errno = EINVAL;
return -1;
}
/* Make sure the pr_ctrls_t has a temporary pool, from which the args will
* be allocated.
*/
if (!ctrl->ctrls_tmp_pool) {
ctrl->ctrls_tmp_pool = make_sub_pool(ctrls_pool);
pr_pool_tag(ctrl->ctrls_tmp_pool, "ctrls tmp pool");
}
if (!ctrl->ctrls_cb_args)
ctrl->ctrls_cb_args = make_array(ctrl->ctrls_tmp_pool, 0, sizeof(char *));
/* Add the given argument */
*((char **) push_array(ctrl->ctrls_cb_args)) = pstrdup(ctrl->ctrls_tmp_pool,
ctrls_arg);
return 0;
}
示例14: pr_ctrls_add_response
int pr_ctrls_add_response(pr_ctrls_t *ctrl, char *fmt, ...) {
char buf[PR_TUNABLE_BUFFER_SIZE] = {'\0'};
va_list resp;
/* Sanity check */
if (!ctrl || !fmt) {
errno = EINVAL;
return -1;
}
/* Make sure the pr_ctrls_t has a temporary pool, from which the responses
* will be allocated
*/
if (!ctrl->ctrls_tmp_pool) {
ctrl->ctrls_tmp_pool = make_sub_pool(ctrls_pool);
pr_pool_tag(ctrl->ctrls_tmp_pool, "ctrls tmp pool");
}
if (!ctrl->ctrls_cb_resps)
ctrl->ctrls_cb_resps = make_array(ctrl->ctrls_tmp_pool, 0,
sizeof(char *));
/* Affix the message */
va_start(resp, fmt);
vsnprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), fmt, resp);
va_end(resp);
buf[sizeof(buf) - 1] = '\0';
/* add the given response */
*((char **) push_array(ctrl->ctrls_cb_resps)) =
pstrdup(ctrl->ctrls_tmp_pool, buf);
return 0;
}
示例15: pr_ctrls_copy_args
int pr_ctrls_copy_args(pr_ctrls_t *src_ctrl, pr_ctrls_t *dst_ctrl) {
/* Sanity checks */
if (!src_ctrl || !dst_ctrl) {
errno = EINVAL;
return -1;
}
/* If source ctrl has no ctrls_cb_args member, there's nothing to be
* done.
*/
if (!src_ctrl->ctrls_cb_args)
return 0;
/* Make sure the pr_ctrls_t has a temporary pool, from which the args will
* be allocated.
*/
if (!dst_ctrl->ctrls_tmp_pool) {
dst_ctrl->ctrls_tmp_pool = make_sub_pool(ctrls_pool);
pr_pool_tag(dst_ctrl->ctrls_tmp_pool, "ctrls tmp pool");
}
/* Overwrite any existing dst_ctrl->ctrls_cb_args. This is OK, as
* the ctrl will be reset (cleared) once it has been processed.
*/
dst_ctrl->ctrls_cb_args = copy_array(dst_ctrl->ctrls_tmp_pool,
src_ctrl->ctrls_cb_args);
return 0;
}