svn_error_t * svn_wc__db_drop_root(svn_wc__db_t *db, const char *local_abspath, apr_pool_t *scratch_pool) { svn_wc__db_wcroot_t *root_wcroot = svn_hash_gets(db->dir_data, local_abspath); apr_hash_index_t *hi; apr_status_t result; if (!root_wcroot) return SVN_NO_ERROR; if (strcmp(root_wcroot->abspath, local_abspath) != 0) return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL, _("'%s' is not a working copy root"), svn_dirent_local_style(local_abspath, scratch_pool)); for (hi = apr_hash_first(scratch_pool, db->dir_data); hi; hi = apr_hash_next(hi)) { svn_wc__db_wcroot_t *wcroot = apr_hash_this_val(hi); if (wcroot == root_wcroot) svn_hash_sets(db->dir_data, apr_hash_this_key(hi), NULL); } result = apr_pool_cleanup_run(db->state_pool, root_wcroot, close_wcroot); if (result != APR_SUCCESS) return svn_error_wrap_apr(result, NULL); return SVN_NO_ERROR; }
static apr_status_t dav_request_cleanup(void *baton) { svn_ra_neon__request_t *req = baton; apr_pool_cleanup_run(req->sess->pool, req, dav_request_sess_cleanup); return APR_SUCCESS; }
APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t * pollset) { if (pollset->flags & APR_POLLSET_WAKEABLE || pollset->provider->cleanup) return apr_pool_cleanup_run(pollset->pool, pollset, pollset_cleanup); else return APR_SUCCESS; }
svn_error_t * svn_sqlite__close(svn_sqlite__db_t *db) { apr_status_t result = apr_pool_cleanup_run(db->state_pool, db, close_apr); if (result == APR_SUCCESS) return SVN_NO_ERROR; return svn_error_wrap_apr(result, NULL); }
apr_status_t proc_close_ipc(fcgid_ipc * ipc_handle) { apr_status_t rv; rv = apr_pool_cleanup_run(ipc_handle->request->pool, ipc_handle->ipc_handle_info, ipc_handle_cleanup); ipc_handle->ipc_handle_info = NULL; return rv; }
static int dbd_mysql_get_row(apr_pool_t *pool, apr_dbd_results_t *res, apr_dbd_row_t **row, int rownum) { MYSQL_ROW r = NULL; int ret = 0; if (res->statement) { if (res->random) { if (rownum > 0) { mysql_stmt_data_seek(res->statement, (my_ulonglong) --rownum); } else { return -1; /* invalid row */ } } ret = mysql_stmt_fetch(res->statement); switch (ret) { case 1: ret = mysql_stmt_errno(res->statement); break; case MYSQL_NO_DATA: ret = -1; break; default: ret = 0; /* bad luck - get_entry will deal with this */ break; } } else { if (res->random) { if (rownum > 0) { mysql_data_seek(res->res, (my_ulonglong) --rownum); } else { return -1; /* invalid row */ } } r = mysql_fetch_row(res->res); if (r == NULL) { ret = -1; } } if (ret == 0) { if (!*row) { *row = apr_palloc(pool, sizeof(apr_dbd_row_t)); } (*row)->row = r; (*row)->res = res; (*row)->len = mysql_fetch_lengths(res->res); } else { apr_pool_cleanup_run(res->pool, res->res, free_result); } return ret; }
static int dbd_sqlite_get_row(apr_pool_t * pool, apr_dbd_results_t * res, apr_dbd_row_t ** rowp, int rownum) { apr_dbd_row_t *row = *rowp; int sequential = ((rownum >= 0) && res->random) ? 0 : 1; if (row == NULL) { row = apr_palloc(pool, sizeof(apr_dbd_row_t)); *rowp = row; row->res = res; row->n = sequential ? 0 : rownum - 1; } else { if (sequential) { ++row->n; } else { row->n = rownum - 1; } } if (row->n >= res->ntuples) { *rowp = NULL; apr_pool_cleanup_run(pool, res->res, free_table); res->res = NULL; return -1; } /* Pointer magic explanation: * The sqlite result is an array such that the first res->sz elements are * the column names and each tuple follows afterwards * ex: (from the sqlite2 documentation) SELECT employee_name, login, host FROM users WHERE login LIKE * 'd%'; nrow = 2 ncolumn = 3 result[0] = "employee_name" result[1] = "login" result[2] = "host" result[3] = "dummy" result[4] = "No such user" result[5] = 0 result[6] = "D. Richard Hipp" result[7] = "drh" result[8] = "zadok" */ row->data = res->res + res->sz + (res->sz * row->n); return 0; }
APU_DECLARE(apr_status_t) apr_xml_parser_done(apr_xml_parser *parser, apr_xml_doc **pdoc) { char end; apr_status_t status = do_parse(parser, &end, 0, 1 /* is_final */); /* get rid of the parser */ (void) apr_pool_cleanup_run(parser->p, parser, cleanup_parser); if (status) return status; if (pdoc != NULL) *pdoc = parser->doc; return APR_SUCCESS; }
svn_error_t * svn_wc__db_close_many_wcroots(apr_hash_t *roots, apr_pool_t *state_pool, apr_pool_t *scratch_pool) { apr_hash_index_t *hi; for (hi = apr_hash_first(scratch_pool, roots); hi; hi = apr_hash_next(hi)) { svn_wc__db_wcroot_t *wcroot = apr_hash_this_val(hi); apr_status_t result; result = apr_pool_cleanup_run(state_pool, wcroot, close_wcroot); if (result != APR_SUCCESS) return svn_error_wrap_apr(result, NULL); } return SVN_NO_ERROR; }
static int dbd_freetds_get_row(apr_pool_t *pool, apr_dbd_results_t *res, apr_dbd_row_t **rowp, int rownum) { RETCODE rv = 0; apr_dbd_row_t *row = *rowp; int sequential = ((rownum >= 0) && res->random) ? 0 : 1; if (row == NULL) { row = apr_palloc(pool, sizeof(apr_dbd_row_t)); *rowp = row; row->res = res; } /* else { if ( sequential ) { ++row->n; } else { row->n = rownum; } } */ if (sequential) { rv = dbnextrow(res->proc); } else { rv = (rownum >= 0) ? dbgetrow(res->proc, rownum) : NO_MORE_ROWS; } switch (rv) { case SUCCEED: return 0; case REG_ROW: return 0; case NO_MORE_ROWS: apr_pool_cleanup_run(res->pool, res->proc, clear_result); *rowp = NULL; return -1; case FAIL: return 1; case BUF_FULL: return 2; /* FIXME */ default: return 3; } return 0; }
static void vt_gdbm_freedatum(apr_dbm_t *dbm, apr_datum_t data) { (void) apr_pool_cleanup_run(dbm->pool, data.dptr, datum_cleanup); }
APU_DECLARE(apr_status_t) apr_thread_pool_destroy(apr_thread_pool_t * me) { return apr_pool_cleanup_run(me->pool, me, thread_pool_cleanup); }
mapcache_map* mapcache_assemble_maps(mapcache_context *ctx, mapcache_map **maps, int nmaps, mapcache_resample_mode mode) { mapcache_tile ***maptiles; int *nmaptiles; mapcache_tile **tiles; mapcache_map *basemap = NULL; int ntiles = 0; int i; maptiles = apr_pcalloc(ctx->pool,nmaps*sizeof(mapcache_tile**)); nmaptiles = apr_pcalloc(ctx->pool,nmaps*sizeof(int)); for(i=0; i<nmaps; i++) { mapcache_tileset_get_map_tiles(ctx,maps[i]->tileset,maps[i]->grid_link, &maps[i]->extent, maps[i]->width, maps[i]->height, &(nmaptiles[i]), &(maptiles[i])); ntiles += nmaptiles[i]; } tiles = apr_pcalloc(ctx->pool,ntiles * sizeof(mapcache_tile*)); ntiles = 0; for(i=0; i<nmaps; i++) { int j; for(j=0; j<nmaptiles[i]; j++) { tiles[ntiles] = maptiles[i][j]; tiles[ntiles]->dimensions = maps[i]->dimensions; ntiles++; } } mapcache_prefetch_tiles(ctx,tiles,ntiles); if(GC_HAS_ERROR(ctx)) return NULL; for(i=0; i<nmaps; i++) { int j,hasdata = 0; for(j=0; j<nmaptiles[i]; j++) { mapcache_tile *tile = maptiles[i][j]; if(tile->nodata) { continue; } hasdata++; /* update the map modification time if it is older than the tile mtime */ if(tile->mtime>maps[i]->mtime) { maps[i]->mtime = tile->mtime; } /* set the map expiration delay to the tile expiration delay, * either if the map hasn't got an expiration delay yet * or if the tile expiration is shorter than the map expiration */ if(!maps[i]->expires || tile->expires<maps[i]->expires) { maps[i]->expires = tile->expires; } } if(hasdata) { maps[i]->raw_image = mapcache_tileset_assemble_map_tiles(ctx,maps[i]->tileset,maps[i]->grid_link, &maps[i]->extent, maps[i]->width, maps[i]->height, nmaptiles[i], maptiles[i], mode); if(!basemap) { basemap = maps[i]; } else { mapcache_image_merge(ctx,basemap->raw_image,maps[i]->raw_image); if(GC_HAS_ERROR(ctx)) return NULL; if(maps[i]->mtime > basemap->mtime) basemap->mtime = maps[i]->mtime; if(!basemap->expires || maps[i]->expires<basemap->expires) basemap->expires = maps[i]->expires; apr_pool_cleanup_run(ctx->pool, maps[i]->raw_image->data, (void*)free) ; maps[i]->raw_image = NULL; } } else { maps[i]->nodata = 1; } } if(!basemap) { ctx->set_error(ctx,404, "no tiles containing image data could be retrieved to create map (not in cache, and/or no source configured)"); return NULL; } return basemap; }
static int dbd_mysql_select(apr_pool_t *pool, apr_dbd_t *sql, apr_dbd_results_t **results, const char *query, int seek) { int sz; int ret; if (sql->trans && sql->trans->errnum) { return sql->trans->errnum; } ret = mysql_query(sql->conn, query); if (!ret) { if (sz = mysql_field_count(sql->conn), sz > 0) { if (!*results) { *results = apr_palloc(pool, sizeof(apr_dbd_results_t)); } (*results)->random = seek; (*results)->statement = NULL; #if APU_MAJOR_VERSION >= 2 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 3) (*results)->pool = pool; #endif if (seek) { (*results)->res = mysql_store_result(sql->conn); } else { (*results)->res = mysql_use_result(sql->conn); } apr_pool_cleanup_register(pool, (*results)->res, free_result,apr_pool_cleanup_null); } } else { ret = mysql_errno(sql->conn); } #if APU_MAJOR_VERSION >= 2 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 3) if (TXN_NOTICE_ERRORS(sql->trans)) { #else if (sql->trans) { #endif sql->trans->errnum = ret; } return ret; } #if APU_MAJOR_VERSION >= 2 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 3) static const char *dbd_mysql_get_name(const apr_dbd_results_t *res, int n) { if ((n < 0) || (n >= mysql_num_fields(res->res))) { return NULL; } return mysql_fetch_fields(res->res)[n].name; } #endif static int dbd_mysql_get_row(apr_pool_t *pool, apr_dbd_results_t *res, apr_dbd_row_t **row, int rownum) { MYSQL_ROW r = NULL; int ret = 0; if (res->statement) { if (res->random) { if (rownum >= 0) { mysql_stmt_data_seek(res->statement, (my_ulonglong)rownum); } } ret = mysql_stmt_fetch(res->statement); switch (ret) { case 1: ret = mysql_stmt_errno(res->statement); break; case MYSQL_NO_DATA: ret = -1; break; default: ret = 0; /* bad luck - get_entry will deal with this */ break; } } else { if (res->random) { if (rownum >= 0) { mysql_data_seek(res->res, (my_ulonglong) rownum); } } r = mysql_fetch_row(res->res); if (r == NULL) { ret = -1; } } if (ret == 0) { if (!*row) { *row = apr_palloc(pool, sizeof(apr_dbd_row_t)); } (*row)->row = r; (*row)->res = res; #if APU_MAJOR_VERSION >= 2 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 3) (*row)->len = mysql_fetch_lengths(res->res); #endif } else { apr_pool_cleanup_run(pool, res->res, free_result); } return ret; }
APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m) { return apr_pool_cleanup_run(m->pool, m, shm_cleanup_owner); }
APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset) { return apr_pool_cleanup_run(pollset->pool, pollset, backend_cleanup); }
APU_DECLARE(apr_status_t) apr_reslist_destroy(apr_reslist_t *reslist) { return apr_pool_cleanup_run(reslist->pool, reslist, reslist_cleanup); }
APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) { return apr_pool_cleanup_run(mutex->pool, mutex, apr_proc_mutex_cleanup); }
AP_DECLARE(void) ap_close_piped_log(piped_log *pl) { apr_pool_cleanup_run(pl->p, pl, piped_log_cleanup); }
APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond) { return apr_pool_cleanup_run(cond->pool, cond, thread_cond_cleanup); }
APR_DECLARE(apr_status_t) apr_dso_unload(struct apr_dso_handle_t *handle) { return apr_pool_cleanup_run(handle->cont, handle, dso_cleanup); }
static int dbd_pgsql_get_row(apr_pool_t *pool, apr_dbd_results_t *res, apr_dbd_row_t **rowp, int rownum) { apr_dbd_row_t *row = *rowp; int sequential = ((rownum >= 0) && res->random) ? 0 : 1; if (row == NULL) { row = apr_palloc(pool, sizeof(apr_dbd_row_t)); *rowp = row; row->res = res; if ( sequential ) { row->n = 0; } else { if (rownum > 0) { row->n = --rownum; } else { return -1; /* invalid row */ } } } else { if ( sequential ) { ++row->n; } else { if (rownum > 0) { row->n = --rownum; } else { return -1; /* invalid row */ } } } if (res->random) { if ((row->n >= 0) && (size_t)row->n >= res->ntuples) { *rowp = NULL; apr_pool_cleanup_run(pool, res->res, clear_result); res->res = NULL; return -1; } } else { if ((row->n >= 0) && (size_t)row->n >= res->ntuples) { /* no data; we have to fetch some */ row->n -= res->ntuples; if (res->res != NULL) { PQclear(res->res); } res->res = PQgetResult(res->handle); if (res->res) { res->ntuples = PQntuples(res->res); while (res->ntuples == 0) { /* if we got an empty result, clear it, wait a mo, try * again */ PQclear(res->res); apr_sleep(100000); /* 0.1 secs */ res->res = PQgetResult(res->handle); if (res->res) { res->ntuples = PQntuples(res->res); } else { return -1; } } if (res->sz == 0) { res->sz = PQnfields(res->res); } } else { return -1; } } } return 0; }
APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock) { return apr_pool_cleanup_run(rwlock->pool, rwlock, thread_rwlock_cleanup); }