socsvn commit: r239982 - in soc2012/gmiller/locking-head: .
lib/libwitness
gmiller at FreeBSD.org
gmiller at FreeBSD.org
Wed Aug 1 08:14:01 UTC 2012
Author: gmiller
Date: Wed Aug 1 08:13:59 2012
New Revision: 239982
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239982
Log:
r240027 at FreeBSD-dev: root | 2012-07-24 11:56:51 -0500
Fix crashes and graph generation errors that produced infinite loops and
more crashes.
Modified:
soc2012/gmiller/locking-head/ (props changed)
soc2012/gmiller/locking-head/lib/libwitness/graph.c
Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/graph.c Wed Aug 1 08:12:56 2012 (r239981)
+++ soc2012/gmiller/locking-head/lib/libwitness/graph.c Wed Aug 1 08:13:59 2012 (r239982)
@@ -34,6 +34,7 @@
scan_graph(struct lock_info *graph, struct lock_info *lock)
{
int ret;
+ struct lock_info *child;
if (graph == NULL) {
return (0);
@@ -43,9 +44,11 @@
return (1);
}
- ret = scan_graph(graph->child, lock);
- if (!ret) {
- ret = scan_graph(graph->sibling, lock);
+ ret = 0;
+ child = graph->child;
+ while (ret == 0 && child != NULL) {
+ ret = scan_graph(child, lock);
+ child = child->sibling;
}
return (ret);
@@ -74,28 +77,21 @@
child->sibling = from->child;
from->child = child;
}
+
+ break;
}
+ previous = child;
child = next;
}
}
-static void
-optimize_links(struct lock_info *to)
-{
- struct lock_info *from;
-
- SLIST_FOREACH(from, &graph_roots, root_next) {
- if (scan_graph(from, to)) {
- optimize_path(from, to);
- }
- }
-}
-
int
insert_lock(struct lock_info *from, struct lock_info *to)
{
struct lock_info *child;
+ struct lock_info *node;
+ struct lock_info *node_temp;
if (from == to || from == NULL || to == NULL) {
return (0);
@@ -105,19 +101,29 @@
return (-1);
}
- SLIST_REMOVE(&graph_roots, from, lock_info, root_next);
+ if (SLIST_FIRST(&graph_roots) == to) {
+ SLIST_REMOVE_HEAD(&graph_roots, root_next);
+ } else {
+ SLIST_FOREACH_SAFE(node, &graph_roots, root_next, node_temp) {
+ if (SLIST_NEXT(node, root_next) == to) {
+ SLIST_REMOVE_AFTER(node, root_next);
+ }
+ }
+ }
- to->sibling = from->child;
- from->child = to;
+ if (to != from->child) {
+ to->sibling = from->child;
+ from->child = to;
+ }
child = to->sibling;
while (child != NULL) {
- optimize_links(child);
+ optimize_path(from, child);
child = child->sibling;
}
- optimize_links(to);
+ optimize_path(from, to);
return (0);
}
More information about the svn-soc-all
mailing list