diff options
-rw-r--r-- | include/Action.h | 9 | ||||
-rw-r--r-- | lib/Action.cc | 23 |
2 files changed, 16 insertions, 16 deletions
diff --git a/include/Action.h b/include/Action.h index c458403..581b093 100644 --- a/include/Action.h +++ b/include/Action.h @@ -25,6 +25,8 @@ #include <Variables.h> #include <Exceptions.h> #include <HtmlSkinner.h> +#include <Atomic.h> +#include <LockSmith.> //! This is the basic HTTP action. /*! @@ -61,13 +63,13 @@ class Action : public Base { //! This returns the recorded URL for that action. String GetURL(void); //! Mark this action to be erased as soon as the Do method ends. - void CleanUp(void); + void CleanUp(void) { hastoclean = true; } //! Skinner accessor. - HtmlSkinner * GetSkinner(); + HtmlSkinner * GetSkinner() { return skin; } protected: //! Mark this action as beeing accessed. - void Accessed(void); + void Accessed(void) { accessed = true; } private: static Action * start; @@ -75,6 +77,7 @@ class Action : public Base { String URL; bool hastoclean, accessed; HtmlSkinner * skin; + iLock lock; }; #endif 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) << "<CENTER><FORM METHOD=\"POST\" ACTION=\"/bin/" << u << "\">" << endnl << |