Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:unbit/uwsgi

  • Loading branch information...
commit f96ebd2b071d7cc6c8f2bc63abae7e9872604508 2 parents b8d0e7a + 14cca3d
unbit authored
Showing with 20 additions and 1 deletion.
  1. +15 −1 core/legion.c
  2. +1 −0  core/uwsgi.c
  3. +4 −0 uwsgi.h
16 core/legion.c
View
@@ -203,7 +203,6 @@ static void legions_check_nodes() {
struct uwsgi_legion_node *node = legion->nodes_head;
while (node) {
-
if (now - node->last_seen > uwsgi.legion_tolerance) {
struct uwsgi_legion_node *tmp_node = node;
node = node->next;
@@ -302,6 +301,18 @@ static void legions_check_nodes_step2() {
// we have quorum !!!
if (votes > 0 && votes >= ul->quorum) {
+ if (!ul->joined) {
+ // triggering join hooks
+ struct uwsgi_string_list *usl = ul->join_hooks;
+ while (usl) {
+ int ret = uwsgi_legion_action_call("join", ul, usl);
+ if (ret) {
+ uwsgi_log("[uwsgi-legion] ERROR, join hook returned: %d\n", ret);
+ }
+ usl = usl->next;
+ }
+ ul->joined = 1;
+ }
// something changed ???
if (ul->changed) {
legions_report_quorum(ul, best_valor, best_uuid, votes);
@@ -852,6 +863,9 @@ void uwsgi_opt_legion_hook(char *opt, char *value, void *foobar) {
else if (!strcmp(opt, "legion-death")) {
usl = uwsgi_string_new_list(&ul->death_hooks, space + 1);
}
+ else if (!strcmp(opt, "legion-join")) {
+ usl = uwsgi_string_new_list(&ul->join_hooks, space + 1);
+ }
if (!usl)
return;
1  core/uwsgi.c
View
@@ -383,6 +383,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"legion-unlord", required_argument, 0, "action to call on Lord dismiss", uwsgi_opt_legion_hook, NULL, UWSGI_OPT_MASTER},
{"legion-setup", required_argument, 0, "action to call on legion setup", uwsgi_opt_legion_hook, NULL, UWSGI_OPT_MASTER},
{"legion-death", required_argument, 0, "action to call on legion death (shutdown of the instance)", uwsgi_opt_legion_hook, NULL, UWSGI_OPT_MASTER},
+ {"legion-join", required_argument, 0, "action to call on legion join (first time quorum is reached)", uwsgi_opt_legion_hook, NULL, UWSGI_OPT_MASTER},
{"legion-quorum", required_argument, 0, "set the quorum of a legion", uwsgi_opt_legion_quorum, NULL, UWSGI_OPT_MASTER},
{"legion-scroll", required_argument, 0, "set the scroll of a legion", uwsgi_opt_legion_scroll, NULL, UWSGI_OPT_MASTER},
{"legion-scroll-max-size", required_argument, 0, "set max size of legion scroll buffer", uwsgi_opt_set_16bit, &uwsgi.legion_scroll_max_size, 0},
4 uwsgi.h
View
@@ -597,6 +597,9 @@ struct uwsgi_legion_node {
int quorum;
int changed;
+ // set to 1 first time when quorum is reached
+ int joined;
+
uint64_t checksum;
char *scroll;
@@ -634,6 +637,7 @@ struct uwsgi_legion_node {
struct uwsgi_string_list *unlord_hooks;
struct uwsgi_string_list *setup_hooks;
struct uwsgi_string_list *death_hooks;
+ struct uwsgi_string_list *join_hooks;
struct uwsgi_legion *next;
};
Please sign in to comment.
Something went wrong with that request. Please try again.