Example #1
0
static void _release_mapboj(mapcache_context *ctx, mapcache_map *map, struct mc_mapobj *mcmap) {
   mapcache_source_mapserver *src = (mapcache_source_mapserver*) map->tileset->source;
   msFreeLabelCache(&mcmap->map->labelcache);
   apr_reslist_t *mapobjs = apr_hash_get(mapobj_container,src->source.name, APR_HASH_KEY_STRING);
   assert(mapobjs);
   if (GC_HAS_ERROR(ctx)) {
      apr_reslist_invalidate(mapobjs, (void*) mcmap);
   } else {
      apr_reslist_release(mapobjs, (void*) mcmap);
   }
}
Example #2
0
static void _bdb_release_conn(mapcache_context *ctx, mapcache_tile *tile, struct bdb_env *benv) {
   mapcache_cache_bdb* cache = (mapcache_cache_bdb*)tile->tileset->cache;
   apr_reslist_t *pool;
   if(benv->readonly) 
      pool = cache->ro_connection_pool;
   else
      pool = cache->rw_connection_pool;
   if(GC_HAS_ERROR(ctx)) {
      apr_reslist_invalidate(pool,(void*)benv);  
   } else {
      apr_reslist_release(pool, (void*)benv);
   }
}
Example #3
0
int ml_reslist_invalidate(lua_State*L)
{
  request_rec* r = CHECK_REQUEST_OBJECT(1);
  size_t l;
  const char* o = luaL_checklstring(L, 2, &l);
  void* resource = lua_touserdata(L, 3);
  struct dir_config *d = ap_get_module_config(r->per_dir_config, &luaex_module);
  apr_reslist_t *reslist = apr_hash_get(d->resource, o, l);

  apr_status_t status = apr_reslist_invalidate(reslist, resource);
  lua_pushboolean(L, status == APR_SUCCESS);
  return 1;
}
Example #4
0
static void _sqlite_release_conn(mapcache_context *ctx, mapcache_tile *tile, struct sqlite_conn *conn)
{
  apr_reslist_t *pool;
  apr_hash_t *pool_container;
  if(conn->readonly) {
    pool_container = ro_connection_pools;
  } else {
    pool_container = rw_connection_pools;
  }
  pool = apr_hash_get(pool_container,tile->tileset->cache->name, APR_HASH_KEY_STRING);

  if (GC_HAS_ERROR(ctx)) {
    apr_reslist_invalidate(pool, (void*) conn);
  } else {
    apr_reslist_release(pool, (void*) conn);
  }
}
Example #5
0
static apr_status_t proc_close_socket(jaxer_connection * ac)
{
	apr_status_t rv = APR_SUCCESS;

	if (ac->has_error)
	{
		compat_log_rerror(APLOG_MARK, APLOG_DEBUG, 0,ac->request, "mod_jaxer: invalidating connection (%d) due to error", ac->sock);

		apr_reslist_invalidate(ac->worker->ac_cache, ac);
		
	} else 
	{
		compat_log_rerror(APLOG_MARK, APLOG_DEBUG, 0,ac->request, "mod_jaxer: releasing connection (%d) back to pool", ac->sock);

		ac->has_error = 0;
		ac->request = 0;
		apr_reslist_release(ac->worker->ac_cache, ac);
	}

	return rv;
}
Example #6
0
static void * APR_THREAD_FUNC resource_consuming_thread(apr_thread_t *thd,
                                                        void *data)
{
    int i;
    apr_uint32_t chance;
    void *vp;
    apr_status_t rv;
    my_resource_t *res;
    my_thread_info_t *thread_info = data;
    apr_reslist_t *rl = thread_info->reslist;

#if APR_HAS_RANDOM
    apr_generate_random_bytes((void*)&chance, sizeof(chance));
#else
    chance = (apr_uint32_t)(apr_time_now() % APR_TIME_C(4294967291));
#endif

    for (i = 0; i < CONSUMER_ITERATIONS; i++) {
        rv = apr_reslist_acquire(rl, &vp);
        ABTS_INT_EQUAL(thread_info->tc, APR_SUCCESS, rv);
        res = vp;
        apr_sleep(thread_info->work_delay_sleep);

        /* simulate a 5% chance of the resource being bad */
        chance = lgc(chance);
        if ( chance < PERCENT95th ) {
            rv = apr_reslist_release(rl, res);
            ABTS_INT_EQUAL(thread_info->tc, APR_SUCCESS, rv);
        } else {
            rv = apr_reslist_invalidate(rl, res);
            ABTS_INT_EQUAL(thread_info->tc, APR_SUCCESS, rv);
        }
    }

    return APR_SUCCESS;
}
Example #7
0
/*
 * This function gets a connection back either by connecting it, or reuse one.
 */
apr_status_t jxr_conn_open(jaxer_worker* aw, jaxer_connection **pac, request_rec *r)
{
	apr_status_t rv = APR_SUCCESS;
	
	*pac = 0;

	compat_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "mod_jaxer: entered jxr_conn_open for worker %s", aw->name);

	if (!aw->ac_cache)
	{
		// Create the resource first.  Grab the mutex
#if APR_HAS_THREADS
		rv = apr_thread_mutex_lock(aw->mutex);
		if (rv != APR_SUCCESS)
		{
			compat_log_rerror(APLOG_MARK, APLOG_CRIT, rv, r, "mod_jaxer: Failed to acquire thread mutex for jaxerworker %s", aw->name);
			return rv;
		}
#endif

		// Make sure it is indeed uncreated
		if (!aw->ac_cache)
		{
			compat_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "mod_jaxer: jxr_conn_open: creating the connection pool for worker %s", aw->name);
			rv = jxr_conn_setup(aw);
		}

		// Before we do anything else, release the mutex.
#if APR_HAS_THREADS
		if (apr_thread_mutex_unlock(aw->mutex) != APR_SUCCESS)
		{
			compat_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r, "mod_jaxer: Failed to release thread mutex for jaxerworker %s", aw->name);
		}
#endif

		if (rv != APR_SUCCESS)
		{
			compat_log_rerror(APLOG_MARK, APLOG_CRIT, rv, r, "mod_jaxer: jxr_conn_setup failed for jaxerworker %s", aw->name);
			return rv;
		}
		compat_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "mod_jaxer: jxr_conn_open: created the connection pool for worker %s", aw->name);

	}

	// At this point, we have a cache
	compat_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "mod_jaxer: jxr_conn_open: acquiring a connection for worker %s", aw->name);

	rv = apr_reslist_acquire(aw->ac_cache, (void **)pac);
	if (rv != APR_SUCCESS)
	{
		compat_log_rerror(APLOG_MARK, APLOG_CRIT, rv, r, "mod_jaxer: Failed to acquire connection from pool for jaxerworker %s", aw->name);
		return rv;
	}

	compat_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "mod_jaxer: jxr_conn_open: acquired a connection (%d) for worker %s", (*pac)->sock, aw->name);

	// Setup additional parameters
	(*pac)->request = r;
	(*pac)->has_error = 0;
	(*pac)->last_active_time = apr_time_now();
	
	compat_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "mod_jaxer: jxr_conn_open: checking connection (%d) for worker %s", (*pac)->sock, aw->name);

	// Make sure it is connected
	if((rv = jxr_send_begin_request_messsage(*pac, 0)) != APR_SUCCESS &&
			((rv = jxr_connect_and_begin_request(*pac)) != APR_SUCCESS))
	{
		compat_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, "mod_jaxer: reuse connection or reconnect failed");
		apr_reslist_invalidate(aw->ac_cache, *pac);
		*pac = 0;

		return rv;
	}

	compat_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "mod_jaxer: jxr_conn_open: acquiredconnection (%d) successfully for worker %s", (*pac)->sock, aw->name);

	return rv;

}
Example #8
0
static void _couchbase_invalidate_connection(mapcache_tile *tile, libcouchbase_t* instance)
{
   mapcache_cache_couchbase* cache = (mapcache_cache_couchbase*)tile->tileset->cache;
   apr_reslist_invalidate(cache->connection_pool, (void*)instance);
}