projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove last references to the global variable "running".
[tinc]
/
src
/
graph.c
diff --git
a/src/graph.c
b/src/graph.c
index
be6080e
..
9589477
100644
(file)
--- a/
src/graph.c
+++ b/
src/graph.c
@@
-58,8
+58,6
@@
#include "subnet.h"
#include "utils.h"
#include "subnet.h"
#include "utils.h"
-static bool graph_changed = true;
-
/* Implementation of Kruskal's algorithm.
Running time: O(EN)
Please note that sorting on weight is already done by add_edge().
/* Implementation of Kruskal's algorithm.
Running time: O(EN)
Please note that sorting on weight is already done by add_edge().
@@
-311,22
+309,13
@@
void sssp_bfs(void)
}
}
}
}
-void graph(void)
-{
- sssp_bfs();
- mst_kruskal();
- graph_changed = true;
-}
-
-
-
/* Dump nodes and edges to a graphviz file.
The file can be converted to an image with
dot -Tpng graph_filename -o image_filename.png -Gconcentrate=true
*/
/* Dump nodes and edges to a graphviz file.
The file can be converted to an image with
dot -Tpng graph_filename -o image_filename.png -Gconcentrate=true
*/
-
void dump_graph(void
)
+
static void dump_graph(int fd, short events, void *data
)
{
avl_node_t *node;
node_t *n;
{
avl_node_t *node;
node_t *n;
@@
-334,11
+323,9
@@
void dump_graph(void)
char *filename = NULL, *tmpname = NULL;
FILE *file;
char *filename = NULL, *tmpname = NULL;
FILE *file;
- if(!g
raph_changed || !g
et_config_string(lookup_config(config_tree, "GraphDumpFile"), &filename))
+ if(!get_config_string(lookup_config(config_tree, "GraphDumpFile"), &filename))
return;
return;
- graph_changed = false;
-
ifdebug(PROTOCOL) logger(LOG_NOTICE, "Dumping graph");
if(filename[0] == '|') {
ifdebug(PROTOCOL) logger(LOG_NOTICE, "Dumping graph");
if(filename[0] == '|') {
@@
-374,7
+361,22
@@
void dump_graph(void)
pclose(file);
} else {
fclose(file);
pclose(file);
} else {
fclose(file);
+#ifdef HAVE_MINGW
+ unlink(filename);
+#endif
rename(tmpname, filename);
free(tmpname);
}
}
rename(tmpname, filename);
free(tmpname);
}
}
+
+void graph(void)
+{
+ static struct event ev;
+
+ sssp_bfs();
+ mst_kruskal();
+
+ if(!timeout_initialized(&ev))
+ timeout_set(&ev, dump_graph, NULL);
+ event_add(&ev, &(struct timeval){5, 0});
+}