From 1a0e4851043eb5679543c7779b00e3d925e83004 Mon Sep 17 00:00:00 2001 From: fche Date: Tue, 8 Nov 2005 18:43:37 +0000 Subject: [PATCH] 2005-11-08 Frank Ch. Eigler * translate.cxx (c_unparser::visit_foreach_loop): With PR 1275 done, add back read lock around foreach loop. Add a write lock around preceding sort operation. Leave a race condition window. :-( --- ChangeLog | 6 ++++++ translate.cxx | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9b4bc54c..ef0fca5b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-11-08 Frank Ch. Eigler + + * translate.cxx (c_unparser::visit_foreach_loop): With PR 1275 + done, add back read lock around foreach loop. Add a write lock + around preceding sort operation. Leave a race condition window. :-( + 2005-11-08 Frank Ch. Eigler * translate.cxx (mapvar::exists): Correct some more. diff --git a/translate.cxx b/translate.cxx index 95a37438e..799cf8d8e 100644 --- a/translate.cxx +++ b/translate.cxx @@ -1648,18 +1648,21 @@ c_unparser::visit_foreach_loop (foreach_loop *s) // initialization - // XXX: until bug #1275 is fixed, any reference into a foreach()-iterated - // array is an instant deadlock. For now, don't lock around foreach(), - // and hope that no concurrent probe handler will modify this array. - // - // varlock_r guard (*this, mv); - // sort array if desired if (s->sort_direction) - o->newline() << "_stp_map_sort (" << mv.qname() << ", " - << s->sort_column << ", " << - s->sort_direction << ");"; + { + varlock_w sort_guard (*this, mv); + o->newline() << "_stp_map_sort (" << mv.qname() << ", " + << s->sort_column << ", " << - s->sort_direction << ");"; + } // NB: sort direction sense is opposite in runtime, thus the negation + // XXX: There is a race condition here. Since we can't convert a + // write lock to a read lock, it is possible that another sort or update + // may get sandwiched between the release of sort_guard and the + // acquisition of guard. + + varlock_r guard (*this, mv); o->newline() << iv << " = " << iv.start (mv) << ";"; // condition -- 2.43.5