From owner-svn-soc-all@FreeBSD.ORG Wed Aug 1 08:14:01 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 4A3BE1065670 for ; Wed, 1 Aug 2012 08:13:59 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 01 Aug 2012 08:13:59 +0000 Date: Wed, 01 Aug 2012 08:13:59 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120801081359.4A3BE1065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239982 - in soc2012/gmiller/locking-head: . lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Aug 2012 08:14:01 -0000 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@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); }