snprintf(nodename, sizeof nodename, "%snode%d", namesprefix,i);
snprintf(filename, sizeof filename, "%s/%s", basebase, nodename);
bool itsnew = access(filename, R_OK);
- mesh[i] = meshlink_open(filename, nodename, "manynodes", DEV_CLASS_PORTABLE);
+ mesh[i] = meshlink_open(filename, nodename, "manynodes", i%_DEV_CLASS_MAX);
meshlink_set_log_cb(mesh[i], MESHLINK_INFO, log_message);
if(itsnew)
meshlink_add_address(mesh[i], "localhost");
timeout_set(&mesh->loop, data, &(struct timeval){mesh->pingtimeout, rand() % 100000});
}
-// devclass asc, last_connect_try desc
-static int node_compare_devclass_asc_last_connect_try_desc(const void *a, const void *b)
+// devclass asc, last_successfull_connection desc
+static int node_compare_devclass_asc_lsc_desc(const void *a, const void *b)
{
const node_t *na = a, *nb = b;
if(na->devclass > nb->devclass)
{ return 1; }
- if(na->last_connect_try == nb->last_connect_try)
+ if(na->last_successfull_connection == nb->last_successfull_connection)
return 0;
- if(na->last_connect_try == 0 || na->last_connect_try > nb->last_connect_try)
+ if(na->last_successfull_connection == 0 || na->last_successfull_connection > nb->last_successfull_connection)
return -1;
- if(nb->last_connect_try == 0 || na->last_connect_try < nb->last_connect_try)
+ if(nb->last_successfull_connection == 0 || na->last_successfull_connection < nb->last_successfull_connection)
return 1;
if(na < nb)
return 0;
}
-// last_connect_try desc
-static int node_compare_last_connect_try_desc(const void *a, const void *b)
+// last_successfull_connection desc
+static int node_compare_lsc_desc(const void *a, const void *b)
{
const node_t *na = a, *nb = b;
- if(na->last_connect_try == nb->last_connect_try)
+ if(na->last_successfull_connection == nb->last_successfull_connection)
return 0;
- if(na->last_connect_try == 0 || na->last_connect_try > nb->last_connect_try)
+ if(na->last_successfull_connection == 0 || na->last_successfull_connection > nb->last_successfull_connection)
return -1;
- if(nb->last_connect_try == 0 || na->last_connect_try < nb->last_connect_try)
+ if(nb->last_successfull_connection == 0 || na->last_successfull_connection < nb->last_successfull_connection)
return 1;
if(na < nb)
if(cur_connects < min_connects)
{
- splay_tree_t *nodes = splay_alloc_tree(node_compare_devclass_asc_last_connect_try_desc, NULL);
+ splay_tree_t *nodes = splay_alloc_tree(node_compare_devclass_asc_lsc_desc, NULL);
for splay_each(node_t, n, mesh->nodes)
{
if( connects < min_connects )
{
- splay_tree_t *nodes = splay_alloc_tree(node_compare_last_connect_try_desc, NULL);
+ splay_tree_t *nodes = splay_alloc_tree(node_compare_lsc_desc, NULL);
for splay_each(node_t, n, mesh->nodes)
{
if(!connect_to && min_connects <= cur_connects && cur_connects < max_connects)
{
- splay_tree_t *nodes = splay_alloc_tree(node_compare_devclass_asc_last_connect_try_desc, NULL);
+ splay_tree_t *nodes = splay_alloc_tree(node_compare_devclass_asc_lsc_desc, NULL);
for splay_each(node_t, n, mesh->nodes)
{
outgoing->mesh = mesh;
outgoing->name = xstrdup(connect_to->name);
list_insert_tail(mesh->outgoings, outgoing);
- setup_outgoing_connection(mesh, outgoing);
+ setup_outgoing_connection(mesh, outgoing);
}
else
{ logger(mesh, MESHLINK_INFO, "* skip autoconnect since it is an outgoing connection already"); }