projects
/
revag-nm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Detect limp home state
[revag-nm.git]
/
vw-nm-tools.h
diff --git
a/vw-nm-tools.h
b/vw-nm-tools.h
index 44d5a1b39c1c7cd39878e0695d69fd7d0a9889f7..7d3c32681e0d1435270f1911cb40ce46ba997e7e 100644
(file)
--- a/
vw-nm-tools.h
+++ b/
vw-nm-tools.h
@@
-137,19
+137,38
@@
static void nm_reset(struct NM_Main *nm)
{
unsigned id;
{
unsigned id;
+ if (nm->nodes[nm->my_id].next == nm->my_id) {
+ nm->lonely_resets++;
+ }
+
for (id = 0; id < nm->max_nodes; id++) {
nm->nodes[id].next = 0xff;
nm->nodes[id].state = NM_MAIN_OFF;
}
nm->nodes[nm->my_id].next = nm->my_id;
for (id = 0; id < nm->max_nodes; id++) {
nm->nodes[id].next = 0xff;
nm->nodes[id].state = NM_MAIN_OFF;
}
nm->nodes[nm->my_id].next = nm->my_id;
- nm->nodes[nm->my_id].state = NM_MAIN_LOGIN;
+ if (nm->lonely_resets >= 5) {
+ printf("Limp home detected :(\n");
+
+ nm->nodes[nm->my_id].state = NM_MAIN_LIMPHOME;
+ nm_set_timer_limphome(nm);
+ } else {
+ nm->nodes[nm->my_id].state = NM_MAIN_LOGIN;
+ nm_set_timer_now(nm);
+ }
+}
+
- nm_set_timer_now(nm);
+static void nm_initreset(struct NM_Main *nm)
+{
+ nm_reset(nm);
+
+ nm->lonely_resets = 0;
}
}
+
static struct NM_Main* nm_alloc(unsigned node_bits, NM_ID my_id, canid_t can_base)
{
struct NM_Main *nm;
static struct NM_Main* nm_alloc(unsigned node_bits, NM_ID my_id, canid_t can_base)
{
struct NM_Main *nm;
@@
-173,7
+192,7
@@
static struct NM_Main* nm_alloc(unsigned node_bits, NM_ID my_id, canid_t can_bas
nm->my_id = my_id;
nm->can_base = can_base;
nm->my_id = my_id;
nm->can_base = can_base;
- nm_reset(nm);
+ nm_
init
reset(nm);
return nm;
}
return nm;
}