From 9d155a9f9464cfb85bf864c8e0075743dc15a52a Mon Sep 17 00:00:00 2001 From: Pixel Date: Fri, 13 Nov 2009 17:55:35 -0800 Subject: BigClean: Action should now be threadsafe. --- lib/Action.cc | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/Action.cc b/lib/Action.cc index 33b0b36..7cffc70 100644 --- a/lib/Action.cc +++ b/lib/Action.cc @@ -23,7 +23,6 @@ #include "BString.h" #include "Action.h" #include "HttpServ.h" -#include "Atomic.h" Action * Action::start = 0; @@ -41,24 +40,29 @@ static String genurl(const String & u) { } Action::Action(const String & u, HtmlSkinner * _skin) : next(start), prev(0), URL(genurl(u)), hastoclean(false), accessed(false), skin(_skin) { + lock.lock(); start = this; if (next) next->prev = this; + lock.unlock(); if (!skin) { skin = &default_skinner; } } Action::~Action() { + lock.lock(); if (start == this) { start = next; } if (next) next->prev = prev; if (prev) prev->next = next; + lock.unlock(); } Action * Action::Look4URL(const String & URL) { Action * p; + lock.lock(); // cerr << "Looking for " << URL << endl; for (p = start; p; p = p->next) { // cerr << "p->GetURL() = " << p->GetURL() << endl; @@ -68,9 +72,13 @@ Action * Action::Look4URL(const String & URL) { // était déclarée en mode CleanUp, puis a été accédée. delete p; } else { - if (URL == p->GetURL()) return p; + if (URL == p->GetURL()) { + return p; + lock.unlock(); + } } } + lock.unlock(); return 0; } @@ -88,23 +96,12 @@ void Action::SendFoot(Handle * h) { (*h) << skin->Footer(); } -HtmlSkinner * Action::GetSkinner() { - return skin; -} - String Action::GetURL(void) { // Comme décrit plus haut, il faut renvoyer la chaîne vide si l'action est en // mode CleanUp et a été lue. return (hastoclean && accessed) ? "" : URL; } -void Action::CleanUp(void) { - hastoclean = true; -} - -void Action::Accessed(void) { - accessed = true; -} void Action::ShowButton(Handle * h, const String & l, const String & u) { (*h) << "
" << endnl << -- cgit v1.2.3