myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9-369-g9


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9-369-g9f1c92d
Date: Fri, 06 Nov 2009 21:47:10 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  9f1c92dd0e26be61966e575160fd19b4f778cf55 (commit)
       via  acd88b22484af18820aac9d319623708110fb11b (commit)
       via  ad8d6493d58bbf648d1565e00daeeb0bfe58f518 (commit)
       via  53541f6cb187e7d80f77e3156338a97b40c1d60e (commit)
      from  62e32877f1bbf2e92ecab11d88ff30eb3c5713cf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit 9f1c92dd0e26be61966e575160fd19b4f778cf55
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Nov 6 22:41:56 2009 +0100

    Use what buildHTTPResponseHeader returns in place of strlen on the buffer.
    
    Add a new test case to ensure the returned value is the same to the length
    computed by strlen.

diff --git a/myserver/src/protocol/http/http_headers.cpp 
b/myserver/src/protocol/http/http_headers.cpp
index 36344d3..c1031b6 100644
--- a/myserver/src/protocol/http/http_headers.cpp
+++ b/myserver/src/protocol/http/http_headers.cpp
@@ -886,9 +886,8 @@ int HttpHeaders::sendHeader (HttpResponseHeader &response, 
Stream &stream,
   if (ctx == NULL || (!ctx->appendOutputs && !ctx->headerSent))
     {
       u_long nbw;
-      buildHTTPResponseHeader (memBuf.getBuffer (), &response);
-      ret = stream.write (memBuf.getBuffer (), strlen (memBuf.getBuffer ()),
-                          &nbw);
+      u_long len = buildHTTPResponseHeader (memBuf.getBuffer (), &response);
+      ret = stream.write (memBuf.getBuffer (), len, &nbw);
 
       if (ctx)
         ctx->headerSent = true;
diff --git a/myserver/tests/test_http_response.cpp 
b/myserver/tests/test_http_response.cpp
index 62fe6a9..3afd4a0 100644
--- a/myserver/tests/test_http_response.cpp
+++ b/myserver/tests/test_http_response.cpp
@@ -34,12 +34,13 @@ using namespace std;
 
 class TestHttpResponse : public CppUnit::TestFixture
 {
-  CPPUNIT_TEST_SUITE ( TestHttpResponse );
-  CPPUNIT_TEST ( testSimpleHeader );
-  CPPUNIT_TEST ( testInvalidResponse );
-  CPPUNIT_TEST ( testJoinField );
-  CPPUNIT_TEST ( testValidResponse );
-  CPPUNIT_TEST ( testReset );
+  CPPUNIT_TEST_SUITE (TestHttpResponse);
+  CPPUNIT_TEST (testSimpleHeader);
+  CPPUNIT_TEST (testInvalidResponse);
+  CPPUNIT_TEST (testJoinField);
+  CPPUNIT_TEST (testValidResponse);
+  CPPUNIT_TEST (testReset);
+  CPPUNIT_TEST (testResponseLength);
   CPPUNIT_TEST_SUITE_END ();
 
 public:
@@ -103,7 +104,6 @@ ToJoin: b\r\n";
     CPPUNIT_ASSERT (ret != 0);
   }
 
-
   void testInvalidResponse ()
   {
     HttpResponseHeader header;
@@ -115,14 +115,11 @@ ToJoin: b\r\n";
     ret = HttpHeaders::validHTTPResponse (responseStr,
                                          &nLinesptr,
                                          &ncharsptr);
-
     CPPUNIT_ASSERT_EQUAL (ret, 0);
 
-
     ret = HttpHeaders::validHTTPResponse (NULL,
                                          &nLinesptr,
                                          &ncharsptr);
-
     CPPUNIT_ASSERT_EQUAL (ret, 0);
   }
 
@@ -157,8 +154,15 @@ ToJoin: b\r\n";
     CPPUNIT_ASSERT_EQUAL (header.getStatusType (), 
HttpResponseHeader::SERVER_ERROR);
   }
 
-
+  void testResponseLength ()
+  {
+    char buffer[512];
+    HttpResponseHeader response;
+    response.setValue ("foo", "bar");
+    response.setValue ("baz", "foo");
+    u_long len = HttpHeaders::buildHTTPResponseHeader (buffer, &response);
+    CPPUNIT_ASSERT_EQUAL (len, (u_long) strlen (buffer));
+  }
 };
 
-
 CPPUNIT_TEST_SUITE_REGISTRATION ( TestHttpResponse );



commit acd88b22484af18820aac9d319623708110fb11b
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Nov 6 22:30:29 2009 +0100

    Update plugins to recent interfaces changes

diff --git a/plugins/src/http_checker/http_checker.cpp 
b/plugins/src/http_checker/http_checker.cpp
index 2019bea..597df4c 100644
--- a/plugins/src/http_checker/http_checker.cpp
+++ b/plugins/src/http_checker/http_checker.cpp
@@ -15,18 +15,20 @@ You should have received a copy of the GNU General Public 
License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include <stdafx.h>
+
+#include <Python.h>
+
 #include <string.h>
 #include <include/server/server.h>
 #include <include/base/multicast/multicast.h>
 #include <include/protocol/http/http.h>
 #include <include/plugin/plugin.h>
 #include <include/conf/main/xml_main_configuration.h>
-#include <Python.h>
 
 #ifdef WIN32
-#define EXPORTABLE(x) x _declspec(dllexport)
+# define EXPORTABLE(x) x _declspec(dllexport)
 #else
-#define EXPORTABLE(x) extern "C" x
+# define EXPORTABLE(x) extern "C" x
 #endif
 
 typedef int (*executePROC)(char*, u_long);
@@ -231,21 +233,13 @@ EXPORTABLE(char*) name(char* name, u_long len)
 EXPORTABLE(int) load(void* server,void* parser)
 {
   Server* serverInstance = (Server*)server;
-  HttpStaticData* staticData =(HttpStaticData*) 
serverInstance->getGlobalData("http-static");
   string msg("new-http-request");
   string pythonName("python");
   Plugin* python;
   MainConfiguration* configuration;
   xmlDocPtr xmlDoc;
 
-  if(!staticData)
-    {
-      serverInstance->log (MYSERVER_LOG_MSG_ERROR, _("HttpChecker: invalid 
HTTP static data"));
-      return -1;
-    }
-
   python = serverInstance->getPluginsManager()->getPlugin(pythonName);
-
   if(!python)
     {
       serverInstance->log (MYSERVER_LOG_MSG_ERROR, _("HttpChecker: cannot find 
executors::python"));
@@ -253,13 +247,16 @@ EXPORTABLE(int) load(void* server,void* parser)
     }
   observer.setPythonExecutor(python);
 
-  staticData->addMulticast(msg, &observer);
+  string httpStr ("http");
+  Protocol *p = serverInstance->getProtocolsManager ()->getProtocol (httpStr);
+  static_cast<HttpProtocol*>(p)->addMulticast(msg, &observer);
 
   init = (INIT_MODULE) python->getDirectMethod((char*)"initModule");
 
   if(!init)
     {
-      serverInstance->log (MYSERVER_LOG_MSG_ERROR, _("HttpChecker: cannot find 
method initModule in executors::python"));
+      serverInstance->log (MYSERVER_LOG_MSG_ERROR,
+         _("HttpChecker: cannot find method initModule in executors::python"));
       return -1;
     }
 
diff --git a/plugins/src/python_http_handler/python_http_handler.cpp 
b/plugins/src/python_http_handler/python_http_handler.cpp
index 508e824..b15159d 100644
--- a/plugins/src/python_http_handler/python_http_handler.cpp
+++ b/plugins/src/python_http_handler/python_http_handler.cpp
@@ -16,21 +16,23 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 */
 #include <stdafx.h>
 #include <string.h>
+
+#include <Python.h>
+
 #include <include/server/server.h>
 #include <include/protocol/http/http_data_handler.h>
 #include <include/base/multicast/multicast.h>
 #include <include/protocol/http/http.h>
 #include <include/plugin/plugin.h>
 #include <include/conf/main/xml_main_configuration.h>
-#include <Python.h>
 
 
 static Server* serverInstance;
 
 #ifdef WIN32
-#define EXPORTABLE(x) x _declspec(dllexport)
+# define EXPORTABLE(x) x _declspec(dllexport)
 #else
-#define EXPORTABLE(x) extern "C" x
+# define EXPORTABLE(x) extern "C" x
 #endif
 
 typedef int (*executePROC)(char*, u_long);
@@ -45,39 +47,39 @@ class ThreadData : public HttpDataHandler
   FiltersChain chain;
 public:
 
-  ThreadData(HttpThreadContext* td)
+  ThreadData (HttpThreadContext* td)
   {
     this->td = td;
     ret = 0;
   }
 
-       HttpThreadContext* getHttpThreadContext(){return td;}
-       int getRet(){return ret;}
+       HttpThreadContext* getHttpThreadContext (){return td;}
+       int getRet (){return ret;}
 
-       void setHttpThreadContext(HttpThreadContext* td){this->td = td;}
-       void setRet(int r){ret = r;}
+       void setHttpThreadContext (HttpThreadContext* td){this->td = td;}
+       void setRet (int r){ret = r;}
 
 
-       virtual int send(HttpThreadContext*, ConnectionPtr s,
-                   const char* exec, const char* cmdLine,
-                   int execute, int onlyHeader)
+       virtual int send (HttpThreadContext*, ConnectionPtr s,
+                    const char* exec, const char* cmdLine,
+                    int execute, int onlyHeader)
   {
     return 0;
   }
 
-  int send(char* buffer, u_long size)
+  int send (char* buffer, u_long size)
   {
-    return appendDataToHTTPChannel(td, buffer, size, 0, &chain, 0, useChunks);
+    return appendDataToHTTPChannel (td, buffer, size, 0, &chain,
+                                    0, useChunks);
   }
 
-  void check()
+  void check ()
   {
-    checkDataChunks(td, &keepalive, &useChunks);
-    chain.setProtocol(td->http);
-    chain.setProtocolData(td);
-    chain.setStream(td->connection->socket);
+    checkDataChunks (td, &keepalive, &useChunks);
+    chain.setProtocol (td->http);
+    chain.setProtocolData (td);
+    chain.setStream (td->connection->socket);
   }
-
 };
 
 static HashMap<ThreadID, ThreadData*> pythonThreadData;
@@ -87,87 +89,86 @@ typedef int (*INIT_MODULE)(char* name, PyMethodDef 
methods[]);
 static INIT_MODULE init;
 
 
-static ThreadData* getThreadData()
+static ThreadData* getThreadData ()
 {
        ThreadID tid = Thread::threadID();
        ThreadData* ret;
-       mutex.lock();
-       ret = pythonThreadData.get(tid);
-       mutex.unlock();
+       mutex.lock ();
+       ret = pythonThreadData.get (tid);
+       mutex.unlock ();
        return ret;
 }
 
-static HttpThreadContext* getThreadContext()
+static HttpThreadContext* getThreadContext ()
 {
-       return getThreadData()->getHttpThreadContext();
+       return getThreadData ()->getHttpThreadContext ();
 }
 
-static PyObject *get_remote_addr(PyObject *self, PyObject *args)
+static PyObject *get_remote_addr (PyObject *self, PyObject *args)
 {
-       HttpThreadContext* context = getThreadContext();
-  return Py_BuildValue((char*)"s", context->connection->getIpAddr());
+       HttpThreadContext* context = getThreadContext ();
+  return Py_BuildValue((char*)"s", context->connection->getIpAddr ());
 }
 
-static PyObject *get_remote_port(PyObject *self, PyObject *args)
+static PyObject *get_remote_port (PyObject *self, PyObject *args)
 {
-       HttpThreadContext* context = getThreadContext();
-  return Py_BuildValue((char*)"i", context->connection->getPort());
+       HttpThreadContext* context = getThreadContext ();
+  return Py_BuildValue((char*)"i", context->connection->getPort ());
 }
 
-static PyObject *get_local_addr(PyObject *self, PyObject *args)
+static PyObject *get_local_addr (PyObject *self, PyObject *args)
 {
-       HttpThreadContext* context = getThreadContext();
-  return Py_BuildValue((char*)"s", context->connection->getLocalIpAddr());
+       HttpThreadContext* context = getThreadContext ();
+  return Py_BuildValue ((char*)"s", context->connection->getLocalIpAddr ());
 }
 
-static PyObject *get_local_port(PyObject *self, PyObject *args)
+static PyObject *get_local_port (PyObject *self, PyObject *args)
 {
-       HttpThreadContext* context = getThreadContext();
-  return Py_BuildValue((char*)"i", context->connection->getLocalPort());
+       HttpThreadContext* context = getThreadContext ();
+  return Py_BuildValue ((char*)"i", context->connection->getLocalPort ());
 }
 
 
-static PyObject *get_response_header(PyObject *self, PyObject *args)
+static PyObject *get_response_header (PyObject *self, PyObject *args)
 {
        char *header;
        string value;
-       if (!PyArg_ParseTuple(args, (char*)"s", &header))
+       if (!PyArg_ParseTuple (args, (char*)"s", &header))
                return NULL;
 
-       HttpThreadContext* context = getThreadContext();
+       HttpThreadContext* context = getThreadContext ();
 
-       context->response.getValue(header, &value);
+       context->response.getValue (header, &value);
 
-       return Py_BuildValue((char*)"s", value.c_str());
+       return Py_BuildValue ((char*)"s", value.c_str());
 }
 
-static PyObject *get_request_header(PyObject *self, PyObject *args)
+static PyObject *get_request_header (PyObject *self, PyObject *args)
 {
        char *header;
        string value;
        if (!PyArg_ParseTuple(args, (char*)"s", &header))
                return NULL;
 
-       HttpThreadContext* context = getThreadContext();
+       HttpThreadContext* context = getThreadContext ();
 
-       context->request.getValue(header, &value);
+       context->request.getValue (header, &value);
 
-       return Py_BuildValue((char*)"s", value.c_str());
+       return Py_BuildValue ((char*)"s", value.c_str ());
 }
 
-static PyObject *log_server_error(PyObject *self, PyObject *args)
+static PyObject *log_server_error (PyObject *self, PyObject *args)
 {
        char *msg;
 
        if (!PyArg_ParseTuple(args, (char*)"s", &msg))
                return NULL;
 
-  serverInstance->log(MYSERVER_LOG_MSG_ERROR, "%s", msg);
-
+  serverInstance->log (MYSERVER_LOG_MSG_ERROR, "%s", msg);
        return NULL;
 }
 
-static PyObject *set_response_header(PyObject *self, PyObject *args)
+static PyObject *set_response_header (PyObject *self, PyObject *args)
 {
        char *header;
        char *value;
@@ -175,19 +176,19 @@ static PyObject *set_response_header(PyObject *self, 
PyObject *args)
        if (!PyArg_ParseTuple(args, (char*)"ss", &header, &value))
                return NULL;
 
-       HttpThreadContext* context = getThreadContext();
+       HttpThreadContext* context = getThreadContext ();
 
-       string *retS =  context->response.setValue(header, value);
+       string *retS =  context->response.setValue (header, value);
 
-  if(retS)
-  {
-    ret = retS->c_str();
-    return Py_BuildValue((char*)"s", ret);
-  }
-  return Py_BuildValue((char*)"s", "");
+  if (retS)
+    {
+      ret = retS->c_str ();
+      return Py_BuildValue ((char*)"s", ret);
+    }
+  return Py_BuildValue ((char*)"s", "");
 }
 
-static PyObject *set_request_header(PyObject *self, PyObject *args)
+static PyObject *set_request_header (PyObject *self, PyObject *args)
 {
        char *header;
        char *value;
@@ -195,123 +196,120 @@ static PyObject *set_request_header(PyObject *self, 
PyObject *args)
        if (!PyArg_ParseTuple(args, (char*)"ss", &header, &value))
                return NULL;
 
-       HttpThreadContext* context = getThreadContext();
+       HttpThreadContext* context = getThreadContext ();
 
-       string *retS =  context->request.setValue(header, value);
-
-  if(retS)
-  {
-    ret = retS->c_str();
-    return Py_BuildValue((char*)"s", ret);
-  }
-  return Py_BuildValue((char*)"s", "");
+       string *retS =  context->request.setValue (header, value);
+  if (retS)
+    {
+      ret = retS->c_str ();
+      return Py_BuildValue ((char*)"s", ret);
+    }
+  return Py_BuildValue ((char*)"s", "");
 }
 
-static PyObject *send_header(PyObject *self, PyObject *args)
+static PyObject *send_header (PyObject *self, PyObject *args)
 {
-       ThreadData *tdata = getThreadData();
-       HttpThreadContext* td = tdata->getHttpThreadContext();
+       ThreadData *tdata = getThreadData ();
+       HttpThreadContext* td = tdata->getHttpThreadContext ();
 
-  tdata->check();
+  tdata->check ();
 
-  HttpHeaders::buildHTTPResponseHeader(td->buffer->getBuffer(),
-                                       &(td->response));
+  HttpHeaders::buildHTTPResponseHeader (td->buffer->getBuffer(),
+                                        &(td->response));
 
-  if(td->connection->socket->send(td->buffer->getBuffer(),
-             (u_long)strlen(td->buffer->getBuffer()), 0)
-     == SOCKET_ERROR)
-               {
-      return Py_BuildValue((char*)"i", 1);
-               }
+  if(td->connection->socket->send (td->buffer->getBuffer(),
+                                  (u_long)strlen(td->buffer->getBuffer()), 0)
+     < 0)
+    return Py_BuildValue((char*)"i", 1);
 
-  tdata->setRet(1);
+  tdata->setRet (1);
 
-  return Py_BuildValue((char*)"i", 0);
+  return Py_BuildValue ((char*)"i", 0);
 }
 
-static PyObject *get_document_root(PyObject *self, PyObject *args)
+static PyObject *get_document_root (PyObject *self, PyObject *args)
 {
        char *data;
        if (!PyArg_ParseTuple(args, (char*)"s", &data))
                return NULL;
 
-       HttpThreadContext* context = getThreadContext();
+       HttpThreadContext* context = getThreadContext ();
 
-       return Py_BuildValue((char*)"s", context->getVhostDir());
+       return Py_BuildValue ((char*)"s", context->getVhostDir ());
 }
 
-static PyObject *send_data(PyObject *self, PyObject *args)
+static PyObject *send_data (PyObject *self, PyObject *args)
 {
        char *data;
   u_long size = 0;
        if (!PyArg_ParseTuple(args, (char*)"s", &data))
                return NULL;
 
-  size = strlen(data);
+  size = strlen (data);
 
-       ThreadData *tdata = getThreadData();
+       ThreadData *tdata = getThreadData ();
 
-  if(tdata->send(data, size))
-    return Py_BuildValue((char*)"i", 0);
+  if (tdata->send(data, size))
+    return Py_BuildValue ((char*)"i", 0);
 
-  tdata->setRet(1);
+  tdata->setRet (1);
 
        return Py_BuildValue((char*)"i", size);
 }
 
-static PyObject *end_send_data(PyObject *, PyObject *)
+static PyObject *end_send_data (PyObject *, PyObject *)
 {
-       ThreadData *tdata = getThreadData();
+       ThreadData *tdata = getThreadData ();
 
-  tdata->send(0, 0);
+  tdata->send (0, 0);
 
-       return Py_BuildValue((char*)"i", 0);
+       return Py_BuildValue ((char*)"i", 0);
 }
 
-static PyObject *raise_error(PyObject *self, PyObject *args)
+static PyObject *raise_error (PyObject *self, PyObject *args)
 {
        int error;
        if (!PyArg_ParseTuple(args, (char*)"i", &error))
                return NULL;
 
-       ThreadData* data = getThreadData();
+       ThreadData* data = getThreadData ();
 
        if(data->getRet())
                return NULL;
 
-       data->getHttpThreadContext()->http->raiseHTTPError(error);
+       data->getHttpThreadContext ()->http->raiseHTTPError (error);
 
-       data->setRet(1);
+       data->setRet (1);
 
-       return Py_BuildValue((char*)"s", "");
+       return Py_BuildValue ((char*)"s", "");
 }
 
 
-static PyObject *is_ssl(PyObject *self, PyObject *args)
+static PyObject *is_ssl (PyObject *self, PyObject *args)
 {
-       HttpThreadContext* context = getThreadContext();
-       int isSsl = context->http->getProtocolOptions() & PROTOCOL_USES_SSL;
+       HttpThreadContext* context = getThreadContext ();
+       int isSsl = context->http->getProtocolOptions () & Protocol::SSL;
 
-       return Py_BuildValue((char*)"b", isSsl);
+       return Py_BuildValue ((char*)"b", isSsl);
 }
 
 
-static PyObject *send_redirect(PyObject *self, PyObject *args)
+static PyObject *send_redirect (PyObject *self, PyObject *args)
 {
        char* dest;
        if (!PyArg_ParseTuple(args, (char*)"s", &dest))
                return NULL;
 
-       ThreadData* data = getThreadData();
+       ThreadData* data = getThreadData ();
 
-       if(data->getRet())
+       if (data->getRet())
                return NULL;
 
-       data->getHttpThreadContext()->http->sendHTTPRedirect(dest);
+       data->getHttpThreadContext ()->http->sendHTTPRedirect (dest);
 
-       data->setRet(1);
+       data->setRet (1);
 
-       return Py_BuildValue((char*)"s", dest);
+       return Py_BuildValue ((char*)"s", dest);
 }
 
 static PyMethodDef PythonHttpHandlerMethods[] = {
@@ -344,46 +342,49 @@ class HttpObserver : public Multicast<string, void*, int>
        };
 public:
 
-       virtual int updateMulticast (MulticastRegistry<string, void*, int>* 
reg, string& msg, void* arg)
+       virtual int updateMulticast (MulticastRegistry<string, void*, int>* reg,
+                               string& msg, void* arg)
        {
                HttpThreadContext *td = (HttpThreadContext*)arg;
-               ThreadID tid = Thread::threadID();
+               ThreadID tid = Thread::threadID ();
                list<Item>::iterator it;
-               mutex.lock();
-               ThreadData threadData(td);
-               pythonThreadData.put(tid, &threadData);
-               mutex.unlock();
-
-               init((char*)"python_http_handler_internal", 
PythonHttpHandlerMethods);
-
-               for(it = rules.begin(); it != rules.end(); it++)
-               {
-                       if((*it).file)
-                       {
-                               executeFromFilePROC execute = 
((executeFromFilePROC)python->getDirectMethod((char*)"executeFromFile"));
-                               if (execute)
-                                 execute((char*)(*it).data.c_str());
-                       }else
-                       {
-                               executePROC execute = 
((executePROC)python->getDirectMethod((char*)"execute"));
-
-                               if (execute)
-                                 execute((char*)(*it).data.c_str(), 
(*it).data.length());
-                       }
-               }
-               return threadData.getRet();
+               mutex.lock ();
+               ThreadData threadData (td);
+               pythonThreadData.put (tid, &threadData);
+               mutex.unlock ();
+
+               init ((char*)"python_http_handler_internal", 
PythonHttpHandlerMethods);
+
+               for (it = rules.begin (); it != rules.end (); it++)
+      {
+        if ((*it).file)
+          {
+            char *method = (char*)"executeFromFile";
+            executeFromFilePROC execute =
+              ((executeFromFilePROC)python->getDirectMethod(method);
+            if (execute)
+              execute((char*)(*it).data.c_str ());
+          }
+        else
+          {
+            executePROC execute =
+              ((executePROC)python->getDirectMethod((char*)"execute"));
+            if (execute)
+              execute ((char*)(*it).data.c_str(), (*it).data.length());
+          }
+      }
+               return threadData.getRet ();
        }
 
        void addRule (const char* rule, bool file)
        {
                Item it;
-               it.data.assign(rule);
+               it.data.assign (rule);
                it.file = file;
-               rules.push_back(it);
+               rules.push_back (it);
        }
 
        void setPythonExecutor (Plugin* python){this->python = python;}
-
 private:
        list<Item> rules;
        Plugin* python;
@@ -403,34 +404,31 @@ EXPORTABLE(char*) name (char* name, u_long len)
 EXPORTABLE(int) load (void* server)
 {
        serverInstance = (Server*)server;
-       HttpStaticData* staticData =(HttpStaticData*) 
serverInstance->getGlobalData("http-static");
        string msg("new-http-request");
        string pythonName("python");
        Plugin* python;
   MainConfiguration* configuration;
        xmlDocPtr xmlDoc;
-
-       if(!staticData)
-    {
-      serverInstance->log (MYSERVER_LOG_MSG_ERROR, _("PythonHttpHandler: 
Invalid HTTP static data"));
-      return -1;
-    }
        python = serverInstance->getPluginsManager ()->getPlugin (pythonName);
 
        if(!python)
     {
-      serverInstance->log (MYSERVER_LOG_MSG_ERROR, _("PythonHttpHandler: 
Cannot find executors::python"));
+      serverInstance->log (MYSERVER_LOG_MSG_ERROR,
+                           _("PythonHttpHandler: Cannot find python"));
       return -1;
     }
        observer.setPythonExecutor(python);
 
-       staticData->addMulticast(msg, &observer);
+  string httpStr ("http");
+  Protocol *p = serverInstance->getProtocolsManager ()->getProtocol (httpStr);
+  static_cast<HttpProtocol*>(p)->addMulticast(msg, &observer);
 
        init = (INIT_MODULE) python->getDirectMethod((char*)"initModule");
 
        if(!init)
     {
-      serverInstance->log (MYSERVER_LOG_MSG_ERROR, _("PythonHttpHandler: 
Cannot find method initModule in executors::python"));
+      serverInstance->log (MYSERVER_LOG_MSG_ERROR,
+      _("PythonHttpHandler: Cannot find method initModule in python"));
       return -1;
     }
 
@@ -439,16 +437,16 @@ EXPORTABLE(int) load (void* server)
   /* FIXME: DON'T DO THIS.  */
   xmlDoc = ((XmlMainConfiguration*)configuration)->getDoc ();
 
-       for(xmlNodePtr ptr = xmlDoc->children->next->children; ptr; ptr = 
ptr->next)
+       for (xmlNodePtr ptr = xmlDoc->children->next->children; ptr; ptr = 
ptr->next)
          {
-           if(!xmlStrcmp(ptr->name, (const xmlChar *)"PYTHON_HTTP_HANDLER"))
+           if (!xmlStrcmp(ptr->name, (const xmlChar *)"PYTHON_HTTP_HANDLER"))
              {
           bool file = false;
           xmlAttrPtr properties = ptr->properties;
           char* data = 0;
-          while(properties)
+          while (properties)
             {
-              if(!xmlStrcmp(properties->name, (const xmlChar *)"file"))
+              if (!xmlStrcmp(properties->name, (const xmlChar *)"file"))
                 {
                   if(properties->children && properties->children->content)
                     data = (char*)properties->children->content;
@@ -458,12 +456,14 @@ EXPORTABLE(int) load (void* server)
               properties = properties->next;
             }
 
-          if(!file && ptr->children && ptr->children->next && 
ptr->children->next->content)
+          if (!file && ptr->children && ptr->children->next
+             && ptr->children->next->content)
             data = (char*)ptr->children->next->content;
 
-          if(!data)
+          if (!data)
             {
-              serverInstance->log (MYSERVER_LOG_MSG_ERROR, 
_("PythonHttpHandler: Invalid rule"));
+              serverInstance->log (MYSERVER_LOG_MSG_ERROR,
+                                   _("PythonHttpHandler: Invalid rule"));
               return -1;
             }
 
diff --git a/plugins/src/rules_checker/rules_checker.cpp 
b/plugins/src/rules_checker/rules_checker.cpp
index 682f29d..969ebbf 100644
--- a/plugins/src/rules_checker/rules_checker.cpp
+++ b/plugins/src/rules_checker/rules_checker.cpp
@@ -23,12 +23,11 @@
 #include "heading.h"
 
 #ifdef WIN32
-#define EXPORTABLE(x) x _declspec(dllexport)
+# define EXPORTABLE(x) x _declspec(dllexport)
 #else
-#define EXPORTABLE(x) extern "C" x
+# define EXPORTABLE(x) extern "C" x
 #endif
 
-
 class RulesCheckerObserver : public Multicast<string, void*, int>
 {
   struct Item
@@ -97,18 +96,12 @@ EXPORTABLE(char*) name (char* name, u_long len)
 EXPORTABLE(int) load (void* server)
 {
   Server* serverInstance = (Server*)server;
-  HttpStaticData* staticData =(HttpStaticData*) 
serverInstance->getGlobalData("http-static");
   string msg("new-http-request");
   MainConfiguration* configuration;
   xmlDocPtr xmlDoc;
-  if(!staticData)
-    {
-      serverInstance->log("RulesChecker: Invalid HTTP static data");
-      return -1;
-    }
-
-
-  staticData->addMulticast(msg, &observer);
+  string httpStr ("http");
+  Protocol *p = serverInstance->getProtocolsManager ()->getProtocol (httpStr);
+  static_cast<HttpProtocol*>(p)->addMulticast(msg, &observer);
 
   configuration = serverInstance->getConfiguration ();
 



commit ad8d6493d58bbf648d1565e00daeeb0bfe58f518
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Nov 6 22:07:03 2009 +0100

    The Server class does not store any opaque static data anymore.
    
    The methods Server::{get,set}GlobalData are not offered by Server.
    
    Store any static data related to the Http implementation in the
    HttpProtocol class.  It is shared by different Http class instances.

diff --git a/myserver/include/protocol/http/http.h 
b/myserver/include/protocol/http/http.h
index d50ec75..1978b68 100644
--- a/myserver/include/protocol/http/http.h
+++ b/myserver/include/protocol/http/http.h
@@ -41,33 +41,8 @@
 
 using namespace std;
 
-class HttpStaticData : public MulticastRegistry<string, void*, int>
-{
-public:
-  vector<Multicast<string, void*, int>*>* getHandlers (string& msg)
-  {
-    return MulticastRegistry<string, void*, int>::getHandlers (msg);
-  }
-
-  HttpStaticData ();
-  virtual ~HttpStaticData ();
-
-  void clear ()
-  {
-    clearMulticastRegistry ();
-    dynManagerList.clear ();
-    dynCmdManager.clear ();
-  }
-
-  u_long timeout;
-  int allowVhostMime;
-
-  DynHttpCommandManager dynCmdManager;
-  DynHttpManagerList dynManagerList;
-};
-
 /*!
- *Data used only by an HTTP user.
+ * Data used only by an HTTP user.
  */
 class HttpUserData : public ProtocolBuffer
 {
@@ -97,6 +72,7 @@ public:
   void reset ();
 };
 
+class HttpProtocol;
 
 class Http : public Protocol
 {
@@ -160,7 +136,7 @@ public:
   int logHTTPaccess ();
   int sendHTTPRedirect (const char *newURL);
   int sendHTTPNonModified ();
-  Http ();
+  Http (HttpProtocol *staticData);
   virtual ~Http ();
   virtual const char* getName (){return getNameImpl ();}
 
@@ -170,7 +146,6 @@ public:
                          u_long tid);
 
   static int loadProtocolStatic ();
-  static int unLoadProtocolStatic ();
 
   u_long getTimeout ();
   int preprocessHttpRequest (string& filename, int yetmapped,
@@ -180,10 +155,8 @@ public:
                           string& file, string &filenamePath,
                           int yetmapped, int* permissions);
 
-  static HttpStaticData* getStaticData ();
-
   SecurityToken *getSecurityToken (){return &(td->securityToken);}
-
+  HttpProtocol *getStaticData () {return staticData;}
 protected:
   int processDefaultFile (string& uri, int permissions, int onlyHeader);
 
@@ -191,13 +164,17 @@ protected:
   void clean ();
   void computeDigest (char*, char*);
   u_long checkDigest ();
+
+  HttpProtocol *staticData;
+
 };
 
 
 /*!
  *Adapter class to make Http reentrant.
  */
-class HttpProtocol : public Protocol
+class HttpProtocol : public Protocol,
+                     public MulticastRegistry<string, void*, int>
 {
 public:
   HttpProtocol ()
@@ -219,20 +196,30 @@ public:
                                  u_long auxBufLen, u_long reqLen,
                                  u_long tid)
   {
-    Http http;
+    Http http (this);
     return http.controlConnection (con, request, auxBuf, reqBufLen, auxBufLen,
                                    reqLen, tid);
   }
 
-  virtual int loadProtocol ()
-  {
-    return Http::loadProtocolStatic ();
-  }
+  virtual int loadProtocol ();
+  virtual int unLoadProtocol ();
 
-  virtual int unLoadProtocol ()
+  vector<Multicast<string, void*, int>*>* getHandlers (string& msg)
   {
-    return Http::unLoadProtocolStatic ();
+    return MulticastRegistry<string, void*, int>::getHandlers (msg);
   }
+
+  DynHttpCommandManager *getDynCmdManager (){return &dynCmdManager;}
+  DynHttpManagerList *getDynManagerList (){return &dynManagerList;}
+
+  u_long getTimeout () {return timeout;}
+  int getAllowVhostMime () {return allowVhostMime;}
+private:
+  u_long timeout;
+  int allowVhostMime;
+
+  DynHttpCommandManager dynCmdManager;
+  DynHttpManagerList dynManagerList;
 };
 
 
diff --git a/myserver/include/protocol/https/https.h 
b/myserver/include/protocol/https/https.h
index 3f2a896..badcb3d 100644
--- a/myserver/include/protocol/https/https.h
+++ b/myserver/include/protocol/https/https.h
@@ -27,18 +27,9 @@ class Https : public Http
 public:
   static const char* getNameImpl ();
   virtual const char* getName ();
-  Https ();
+  Https (HttpProtocol *https);
   virtual ~Https ();
 
-  static int loadProtocolStatic (XmlParser* lang)
-  {
-    return 1;
-  }
-  static int unLoadProtocolStatic (XmlParser* lang)
-  {
-    return 1;
-  }
-
 };
 
 /*!
@@ -47,9 +38,10 @@ public:
 class HttpsProtocol : public Protocol
 {
 public:
-  HttpsProtocol ()
+  HttpsProtocol (HttpProtocol *http)
   {
     protocolOptions = Protocol::SSL;
+    this->http = http;
   }
 
   virtual ~HttpsProtocol ()
@@ -67,20 +59,12 @@ public:
                                  u_long auxBufLen, u_long reqLen,
                                  u_long tid)
   {
-    Https https;
+    Https https (http);
     return https.controlConnection (con, request, auxBuf, reqBufLen, auxBufLen,
                                     reqLen, tid);
   }
-
-  virtual int loadProtocol (XmlParser* parser)
-  {
-    return Https::loadProtocolStatic (parser);
-  }
-
-  virtual int unLoadProtocol (XmlParser* parser)
-  {
-    return Https::unLoadProtocolStatic (parser);
-  }
+protected:
+  HttpProtocol *http;
 };
 
 #endif
diff --git a/myserver/include/server/server.h b/myserver/include/server/server.h
index 9a9b3e4..9740482 100644
--- a/myserver/include/server/server.h
+++ b/myserver/include/server/server.h
@@ -92,9 +92,6 @@ public:
   CachedFileFactory* getCachedFiles ();
   const char* getData (const char *name, const char *defValue = NULL);
 
-  void setGlobalData (const char* name, void* data);
-  void* getGlobalData (const char* name);
-
   FiltersFactory* getFiltersFactory ();
   int getMaxThreads ();
   const char *getUid ();
@@ -215,7 +212,6 @@ private:
   list<NodeTree<string>*> hashedDataTrees;
   HashMap<string, NodeTree<string>*> hashedData;
 
-  HashMap<string, void*> globalData;
   FiltersFactory filtersFactory;
   string uid;
   string gid;
diff --git a/myserver/src/http_handler/fastcgi/fastcgi.cpp 
b/myserver/src/http_handler/fastcgi/fastcgi.cpp
index c5d9adc..2e1bbd9 100644
--- a/myserver/src/http_handler/fastcgi/fastcgi.cpp
+++ b/myserver/src/http_handler/fastcgi/fastcgi.cpp
@@ -755,8 +755,9 @@ int FastCgi::handleHeader (FcgiContext* con, FiltersChain* 
chain, bool* response
       string *sendfile = con->td->response.getValue ("X-Sendfile", NULL);
       if (sendfile)
         {
-          HttpStaticData *staticData = con->td->http->getStaticData ();
-          HttpDataHandler *handler = staticData->dynManagerList.getHttpManager 
("SEND");
+          DynHttpManagerList *m =
+            con->td->http->getStaticData ()->getDynManagerList ();
+          HttpDataHandler *handler = m->getHttpManager ("SEND");
           if (!handler)
             {
               con->td->connection->host->warningsLogWrite
diff --git a/myserver/src/protocol/http/http.cpp 
b/myserver/src/protocol/http/http.cpp
index 56cb45b..2e8adc8 100644
--- a/myserver/src/protocol/http/http.cpp
+++ b/myserver/src/protocol/http/http.cpp
@@ -1,20 +1,19 @@
 /*
-MyServer
-Copyright (C) 2002-2009 Free Software Foundation, Inc.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
+  MyServer
+  Copyright (C) 2002-2009 Free Software Foundation, Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
 
 #include <include/protocol/http/http.h>
 #include <include/protocol/http/http_headers.h>
@@ -61,19 +60,46 @@ extern "C"
 #endif
 }
 
-static HttpStaticData staticHttp;
-
-/*!
- * Get a pointer to a structure shared among all the instances.
- */
-HttpStaticData* Http::getStaticData ()
+int HttpProtocol::loadProtocol ()
 {
-  return &staticHttp;
-}
+  const char *data = NULL;
+
+  timeout = MYSERVER_SEC (15);
+  dynManagerList.addHttpManager ("SEND", new HttpFile ());
+  dynManagerList.addHttpManager ("DIR", new HttpDir ());
+  dynManagerList.addHttpManager ("CGI", new Cgi ());
+  dynManagerList.addHttpManager ("MSCGI", new MsCgi ());
+  dynManagerList.addHttpManager ("SCGI", new Scgi ());
+  dynManagerList.addHttpManager ("WINGI", new WinCgi ());
+  dynManagerList.addHttpManager ("FASTCGI", new FastCgi ());
+  dynManagerList.addHttpManager ("ISAPI", new Isapi ());
+  dynManagerList.addHttpManager ("PROXY", new Proxy ());
+
+  data = Server::getInstance ()->getData ("vhost.allow_mime");
+  if (data)
+    {
+
+      if (!strcmpi (data, "YES"))
+        allowVhostMime = 1;
+      else
+        allowVhostMime = 0;
+    }
 
-HttpStaticData::HttpStaticData () { }
+  data = Server::getInstance ()->getData ("cgi.timeout");
+  if (data)
+    timeout = MYSERVER_SEC (atoi (data));
+
+  return 1;
+}
 
-HttpStaticData::~HttpStaticData () { }
+int HttpProtocol::unLoadProtocol ()
+{
+  HttpErrors::unLoad ();
+  clearMulticastRegistry ();
+  dynManagerList.clear ();
+  dynCmdManager.clear ();
+  return 0;
+}
 
 /*!
  * Build a response for an OPTIONS request.
@@ -89,8 +115,9 @@ int Http::optionsHTTPRESOURCE (string& filename, int 
yetmapped)
       HttpRequestHeader::Entry *connection = td->request.other.get 
("Connection");
       string methods ("OPTIONS, GET, POST, HEAD, DELETE, PUT, TRACE");
 
-      HashMap<string, DynamicHttpCommand*>::Iterator it = 
staticHttp.dynCmdManager.begin ();
-      while (it != staticHttp.dynCmdManager.end ())
+      HashMap<string, DynamicHttpCommand*>::Iterator it =
+        staticData->getDynCmdManager ()->begin ();
+      while (it != staticData->getDynCmdManager ()->end ())
         {
           methods.append (", ");
           methods.append ((*it)->getName ());
@@ -210,7 +237,7 @@ bool Http::allowMethod (const char *method)
  */
 u_long Http::getTimeout ()
 {
-  return staticHttp.timeout;
+  return staticData->getTimeout ();
 }
 
 /*!
@@ -649,15 +676,15 @@ Http::sendHTTPResource (string& uri, int systemrequest, 
int onlyHeader,
           cgiManager = "";
         }
 
-      if (td->mime && (manager = staticHttp.dynManagerList.getHttpManager 
(td->mime->cmdName)))
+      if (td->mime && (manager =
+          staticData->getDynManagerList ()->getHttpManager 
(td->mime->cmdName)))
         return manager->send (td, td->filenamePath.c_str (), cgiManager,
                               td->mime->selfExecuted, onlyHeader);
 
-
       if (!(td->permissions & MYSERVER_PERMISSION_READ))
         return sendAuth ();
 
-      manager = staticHttp.dynManagerList.getHttpManager ("SEND");
+      manager = staticData->getDynManagerList ()->getHttpManager ("SEND");
       if (!manager)
         {
           td->connection->host->warningsLogWrite (_("HTTP: internal error"));
@@ -876,7 +903,8 @@ int Http::controlConnection (ConnectionPtr a, char*, char*, 
u_long, u_long,
       FilesUtility::temporaryFileName (td->id, td->inputDataPath);
       FilesUtility::temporaryFileName (td->id, td->outputDataPath);
 
-      dynamicCommand = staticHttp.dynCmdManager.getHttpCommand 
(td->request.cmd);
+      dynamicCommand =
+        staticData->getDynCmdManager ()->getHttpCommand (td->request.cmd);
 
       /* If the used method supports POST data, read it.  */
       if ((!td->request.cmd.compare ("POST")) ||
@@ -1077,15 +1105,13 @@ int Http::controlConnection (ConnectionPtr a, char*, 
char*, u_long, u_long,
           {
             string msg ("new-http-request");
             vector<Multicast<string, void*, int>*>* handlers =
-                    staticHttp.getHandlers (msg);
-
+                    staticData->getHandlers (msg);
             if (handlers)
               {
                 for (size_t i = 0; i < handlers->size (); i++)
                   {
                     int handlerRet = (*handlers)[i]->updateMulticast 
(getStaticData (),
                                                                       msg, td);
-
                     if (handlerRet == ClientsThread::DELETE_CONNECTION)
                       {
                         ret = ClientsThread::DELETE_CONNECTION;
@@ -1495,7 +1521,7 @@ MimeRecord* Http::getMIME (string &filename)
   const char *handler = td->securityToken.getData ("mime.handler",
                       MYSERVER_VHOST_CONF | MYSERVER_SERVER_CONF, NULL);
 
-  if (staticHttp.allowVhostMime && td->connection->host->isMIME ())
+  if (staticData->getAllowVhostMime () && td->connection->host->isMIME ())
     return td->connection->host->getMIME ()->getMIME (filename);
 
   return Server::getInstance ()->getMimeManager ()->getMIME (filename, 
handler);
@@ -1625,7 +1651,8 @@ int Http::processDefaultFile (string& uri, int 
permissions, int onlyHeader)
         }
     }
 
-  HttpDataHandler *handler = staticHttp.dynManagerList.getHttpManager ("DIR");
+  HttpDataHandler *handler =
+    staticData->getDynManagerList ()->getHttpManager ("DIR");
   if (!handler)
     {
       td->connection->host->warningsLogWrite (_("HTTP: internal error"));
@@ -1721,50 +1748,6 @@ int Http::sendAuth ()
  */
 int Http::loadProtocolStatic ()
 {
-  const char *data = NULL;
-
-  staticHttp.timeout = MYSERVER_SEC (15);
-
-  Server::getInstance ()->setGlobalData ("http-static", getStaticData ());
-
-  staticHttp.dynManagerList.addHttpManager ("SEND", new HttpFile ());
-  staticHttp.dynManagerList.addHttpManager ("DIR", new HttpDir ());
-  staticHttp.dynManagerList.addHttpManager ("CGI", new Cgi ());
-  staticHttp.dynManagerList.addHttpManager ("MSCGI", new MsCgi ());
-  staticHttp.dynManagerList.addHttpManager ("SCGI", new Scgi ());
-  staticHttp.dynManagerList.addHttpManager ("WINGI", new WinCgi ());
-  staticHttp.dynManagerList.addHttpManager ("FASTCGI", new FastCgi ());
-  staticHttp.dynManagerList.addHttpManager ("ISAPI", new Isapi ());
-  staticHttp.dynManagerList.addHttpManager ("PROXY", new Proxy ());
-
-  data = Server::getInstance ()->getData ("vhost.allow_mime");
-  if (data)
-    {
-
-      if (!strcmpi (data, "YES"))
-        staticHttp.allowVhostMime = 1;
-      else
-        staticHttp.allowVhostMime = 0;
-    }
-
-  data = Server::getInstance ()->getData ("cgi.timeout");
-  if (data)
-    staticHttp.timeout = MYSERVER_SEC (atoi (data));
-
-  return 1;
-}
-
-/*!
- * Unload the HTTP protocol.
- */
-int Http::unLoadProtocolStatic ()
-{
-  /* Unload the errors.  */
-  HttpErrors::unLoad ();
-
-  staticHttp.clear ();
-
-  return 1;
 }
 
 /*!
@@ -1779,10 +1762,10 @@ const char* Http::getNameImpl ()
 /*!
  * Constructor for the class http.
  */
-Http::Http ()
+Http::Http (HttpProtocol *staticData)
 {
   td = new HttpThreadContext ();
-
+  this->staticData = staticData;
   protocolPrefix.assign ("http://";);
   protocolOptions = 0;
   td->filenamePath.assign ("");
diff --git a/myserver/src/protocol/https/https.cpp 
b/myserver/src/protocol/https/https.cpp
index fe97141..cbd53e0 100644
--- a/myserver/src/protocol/https/https.cpp
+++ b/myserver/src/protocol/https/https.cpp
@@ -1,18 +1,18 @@
 /*
-MyServer
-Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  MyServer
+  Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, 
Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include <include/protocol/protocol.h>
@@ -30,11 +30,10 @@ extern "C"
 #endif
 }
 
-
 /*!
- *Returns the name of the protocol. If an out buffer is defined
- *fullfill it with the name too.
- */
+  Returns the name of the protocol. If an out buffer is defined
+  fullfill it with the name too.
+*/
 const char* Https::getNameImpl ()
 {
   return "HTTPS";
@@ -46,17 +45,17 @@ const char* Https::getName ()
 }
 
 /*!
- *Https class constructor.
- */
-Https::Https ()
+  Https class constructor.
+*/
+Https::Https (HttpProtocol *http) : Http (http)
 {
   protocolPrefix.assign ("https://";);
   protocolOptions = Protocol::SSL;
 }
 
 /*!
- *Destructor for the class Https.
- */
+  Destructor for the class Https.
+*/
 Https::~Https ()
 {
 
diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index 4fd32c9..690a9a9 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -390,8 +390,9 @@ void Server::loadStaticComponents ()
   if (filtersFactory.insert ("gzip", Gzip::factory))
     log (MYSERVER_LOG_MSG_ERROR, _("Error while loading plugins"));
 
-  Protocol *protocolsSet[] = {new HttpProtocol (),
-                              new HttpsProtocol (),
+  HttpProtocol *http = new HttpProtocol ();
+  Protocol *protocolsSet[] = {http,
+                              new HttpsProtocol (http),
                               new GopherProtocol (),
                               new FtpProtocol (),
                               new ControlProtocol (),
@@ -762,8 +763,6 @@ int Server::terminate ()
 
   clearMulticastRegistry ();
 
-  globalData.clear ();
-
   /*
    * Free all the threads.
    */
@@ -1750,21 +1749,3 @@ u_long Server::getBuffersize ()
 {
   return buffersize;
 }
-
-/*!
- * Set a global descriptor.
- */
-void Server::setGlobalData (const char* name, void* data)
-{
-  string str (name);
-  globalData.put (str, data);
-}
-
-/*!
- * Get a global descriptor.
- */
-void* Server::getGlobalData (const char* name)
-{
-  string str (name);
-  return globalData.get (str);
-}



commit 53541f6cb187e7d80f77e3156338a97b40c1d60e
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Nov 6 20:45:35 2009 +0100

    Rename ConnectionsScheduler::getConnectionsNumber to 
ConnectionsScheduler::getNumAliveConnections.

diff --git a/myserver/include/connections_scheduler/connections_scheduler.h 
b/myserver/include/connections_scheduler/connections_scheduler.h
index 64ebf90..5fe13bd 100644
--- a/myserver/include/connections_scheduler/connections_scheduler.h
+++ b/myserver/include/connections_scheduler/connections_scheduler.h
@@ -94,7 +94,7 @@ public:
   void initialize ();
   void listener (struct ListenerArg* );
   void removeListener (struct ListenerArg*);
-  u_long getConnectionsNumber ();
+  u_long getNumAliveConnections ();
   void removeConnection (ConnectionPtr connection);
   void terminateConnections ();
   void getConnections (list<ConnectionPtr> &out);
diff --git a/myserver/src/connections_scheduler/connections_scheduler.cpp 
b/myserver/src/connections_scheduler/connections_scheduler.cpp
index 585bdba..1e56f60 100644
--- a/myserver/src/connections_scheduler/connections_scheduler.cpp
+++ b/myserver/src/connections_scheduler/connections_scheduler.cpp
@@ -528,7 +528,7 @@ void ConnectionsScheduler::getConnections 
(list<ConnectionPtr> &out)
 /*!
  * Get the alive connections number.
  */
-u_long ConnectionsScheduler::getConnectionsNumber ()
+u_long ConnectionsScheduler::getNumAliveConnections ()
 {
   return connections.size ();
 }
diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index d7edcb7..4fd32c9 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -1,18 +1,18 @@
 /*
-MyServer
-Copyright (C) 2002-2009 Free Software Foundation, Inc.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  MyServer
+  Copyright (C) 2002-2009 Free Software Foundation, Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "stdafx.h"
@@ -674,7 +674,7 @@ const char *Server::getGid ()
  */
 u_long Server::getNumConnections ()
 {
-  return connectionsScheduler.getConnectionsNumber ();
+  return connectionsScheduler.getNumAliveConnections ();
 }
 
 /*!
@@ -1042,9 +1042,8 @@ int Server::addConnection (Socket *s, MYSERVER_SOCKADDRIN 
*asockIn)
    * Do not accept this connection if a MAX_CONNECTIONS_TO_ACCEPT limit is
    * defined.
    */
-  if (maxConnectionsToAccept
-      && ((u_long)connectionsScheduler.getConnectionsNumber ()
-          >= maxConnectionsToAccept))
+  if (maxConnectionsToAccept && connectionsScheduler.getNumAliveConnections ()
+      >= maxConnectionsToAccept)
     return -1;
 
 #if ( HAVE_IPV6 )
@@ -1213,8 +1212,8 @@ ConnectionPtr Server::addConnectionToList (Socket* s,
    * is bigger than it say to the protocol that will parse the connection
    * to remove it from the active connections list.
    */
-  if (maxConnections && ((u_long)connectionsScheduler.getConnectionsNumber ()
-                         > maxConnections))
+  if (maxConnections
+      && connectionsScheduler.getNumAliveConnections () > maxConnections)
     newConnection->setToRemove (Connection::REMOVE_OVERLOAD);
 
   connectionsScheduler.registerConnectionID (newConnection);
diff --git a/myserver/tests/test_connections_scheduler.cpp 
b/myserver/tests/test_connections_scheduler.cpp
index d7653c6..3d8478f 100644
--- a/myserver/tests/test_connections_scheduler.cpp
+++ b/myserver/tests/test_connections_scheduler.cpp
@@ -1,19 +1,19 @@
 /*
- MyServer
- Copyright (C) 2008, 2009 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
+  MyServer
+  Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
 
 #include "stdafx.h"
 #include <ctype.h>
@@ -130,11 +130,11 @@ public:
     u_long max = 3;
 
     for (u_long i = 0; i < max; i++)
-    {
-      ConnectionPtr conn = new Connection;
-      conn->socket = new MockSocket ((FileHandle) i);
-      scheduler->addWaitingConnection (conn);
-    }
+      {
+        ConnectionPtr conn = new Connection;
+        conn->socket = new MockSocket ((FileHandle) i);
+        scheduler->addWaitingConnection (conn);
+      }
 
     scheduler->accept (&visitor, arg);
 
@@ -216,12 +216,12 @@ public:
 
     scheduler->addWaitingConnection (conn);
 
-    CPPUNIT_ASSERT_EQUAL (scheduler->getConnectionsNumber (), 1ul);
+    CPPUNIT_ASSERT_EQUAL (scheduler->getNumAliveConnections (), 1ul);
 
     scheduler->removeConnection (conn);
 
     CPPUNIT_ASSERT_EQUAL (scheduler->getNumTotalConnections (), 0ul);
-    //The connection is freed by the scheduler.
+    /* The connection is freed by the scheduler.  */
   }
 
 

-----------------------------------------------------------------------

Summary of changes:
 .../connections_scheduler/connections_scheduler.h  |    2 +-
 myserver/include/protocol/http/http.h              |   65 ++---
 myserver/include/protocol/https/https.h            |   28 +--
 myserver/include/server/server.h                   |    4 -
 .../connections_scheduler.cpp                      |    2 +-
 myserver/src/http_handler/fastcgi/fastcgi.cpp      |    5 +-
 myserver/src/protocol/http/http.cpp                |  151 +++++------
 myserver/src/protocol/http/http_headers.cpp        |    5 +-
 myserver/src/protocol/https/https.cpp              |   45 ++--
 myserver/src/server/server.cpp                     |   64 ++---
 myserver/tests/test_connections_scheduler.cpp      |   44 ++--
 myserver/tests/test_http_response.cpp              |   28 +-
 plugins/src/http_checker/http_checker.cpp          |   23 +-
 .../python_http_handler/python_http_handler.cpp    |  310 ++++++++++----------
 plugins/src/rules_checker/rules_checker.cpp        |   17 +-
 15 files changed, 358 insertions(+), 435 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]