Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "Revert "Don't pass bucket_engine config to the default engine…

…...""

This reverts commit aa7fcbf.

Change-Id: I5feea10603b2d6fc6499690c48abac7b134d3028
Reviewed-on: http://review.membase.org/6384
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
  • Loading branch information...
commit 9f0a6c433e557a447d9890341a7319ad2bd569d9 1 parent aa7fcbf
@trondn trondn authored chiyoung committed
Showing with 30 additions and 13 deletions.
  1. +5 −0 README.markdown
  2. +25 −13 bucket_engine.c
View
5 README.markdown
@@ -70,6 +70,11 @@ users first attempt to use them.
If true, a default bucket exists for unauthenticated users, or users
who don't have buckets created for them when `auto_create` is disabled.
+### default\_bucket\_config
+
+The "default_bucket_config" parameter specifies a parameter to
+send to the default engine (ex: default_bucket_engine=tap_keepalive=500).
+
### engine
The contained engine is configured using the `engine` parameter (see
View
38 bucket_engine.c
@@ -89,6 +89,7 @@ struct bucket_engine {
char *default_engine_path;
char *admin_user;
char *default_bucket_name;
+ char *default_bucket_config;
proxied_engine_handle_t default_engine;
pthread_mutex_t engines_mutex;
pthread_mutex_t dlopen_mutex;
@@ -132,8 +133,6 @@ ENGINE_ERROR_CODE create_instance(uint64_t interface,
static const engine_info* bucket_get_info(ENGINE_HANDLE* handle);
-static const char *get_default_bucket_config(void);
-
static ENGINE_ERROR_CODE bucket_initialize(ENGINE_HANDLE* handle,
const char* config_str);
static void bucket_destroy(ENGINE_HANDLE* handle,
@@ -334,11 +333,6 @@ static const char * bucket_state_name(bucket_state_t s) {
return rv;
}
-static const char *get_default_bucket_config() {
- const char *config = getenv("MEMCACHED_DEFAULT_BUCKET_CONFIG");
- return config != NULL ? config : "";
-}
-
static SERVER_HANDLE_V1 *bucket_get_server_api(void) {
return &bucket_engine.server;
}
@@ -888,10 +882,9 @@ static void handle_connect(const void *cookie,
// Assign a default named bucket (if there is one).
peh = find_bucket(e->default_bucket_name);
if (!peh && e->auto_create) {
- // XXX: Need default config.
create_bucket(e, e->default_bucket_name,
e->default_engine_path,
- get_default_bucket_config(), &peh, NULL, 0);
+ e->default_bucket_config, &peh, NULL, 0);
}
} else {
// Assign the default bucket (if there is one).
@@ -926,8 +919,8 @@ static void handle_auth(const void *cookie,
release_handle(peh);
}
-static ENGINE_ERROR_CODE init_default_bucket(struct bucket_engine* se,
- const char* config_str) {
+static ENGINE_ERROR_CODE init_default_bucket(struct bucket_engine* se)
+{
ENGINE_ERROR_CODE ret;
memset(&se->default_engine, 0, sizeof(se->default_engine));
if ((ret = init_engine_handle(&se->default_engine, "",
@@ -941,7 +934,7 @@ static ENGINE_ERROR_CODE init_default_bucket(struct bucket_engine* se,
return ENGINE_FAILED;
}
- ret = dv1->initialize(se->default_engine.pe.v0, config_str);
+ ret = dv1->initialize(se->default_engine.pe.v0, se->default_bucket_config);
if (ret != ENGINE_SUCCESS) {
dv1->destroy(se->default_engine.pe.v0, false);
}
@@ -1002,7 +995,7 @@ static ENGINE_ERROR_CODE bucket_initialize(ENGINE_HANDLE* handle,
// engine, but we check flags here to see if we should have and
// shut it down if not.
if (se->has_default) {
- if ((ret = init_default_bucket(se, config_str)) != ENGINE_SUCCESS) {
+ if ((ret = init_default_bucket(se)) != ENGINE_SUCCESS) {
genhash_free(se->engines);
return ret;
}
@@ -1065,6 +1058,8 @@ static void bucket_destroy(ENGINE_HANDLE* handle,
se->admin_user = NULL;
free(se->default_bucket_name);
se->default_bucket_name = NULL;
+ free(se->default_bucket_config);
+ se->default_bucket_config = NULL;
pthread_mutex_destroy(&se->engines_mutex);
pthread_mutex_destroy(&se->dlopen_mutex);
se->initialized = false;
@@ -1618,6 +1613,9 @@ static ENGINE_ERROR_CODE initialize_configuration(struct bucket_engine *me,
{ .key = "default_bucket_name",
.datatype = DT_STRING,
.value.dt_string = &me->default_bucket_name },
+ { .key = "default_bucket_config",
+ .datatype = DT_STRING,
+ .value.dt_string = &me->default_bucket_config },
{ .key = "auto_create",
.datatype = DT_BOOL,
.value.dt_bool = &me->auto_create },
@@ -1627,6 +1625,20 @@ static ENGINE_ERROR_CODE initialize_configuration(struct bucket_engine *me,
};
ret = me->upstream_server->core->parse_config(cfg_str, items, stderr);
+ if (ret == ENGINE_SUCCESS) {
+ if (!items[0].found) {
+ me->default_engine_path = NULL;
+ }
+ if (!items[1].found) {
+ me->admin_user = NULL;
+ }
+ if (!items[3].found) {
+ me->default_bucket_name = NULL;
+ }
+ if (!items[4].found) {
+ me->default_bucket_config = strdup("");
+ }
+ }
}
return ret;
Please sign in to comment.
Something went wrong with that request. Please try again.