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_2-13-g


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-13-g542891e
Date: Fri, 19 Feb 2010 14:48:14 +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  542891e6822b2e087eab85bdeffca8cd38a10637 (commit)
       via  2266681e100b2229e104b0b75945abfe81e0f1e8 (commit)
       via  96f3660d8c508bf0a42fc286910ef54e62658428 (commit)
      from  c382a8224b8fc000aadb6a7d9f630ff894b62a21 (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 542891e6822b2e087eab85bdeffca8cd38a10637
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Feb 19 15:45:06 2010 +0100

    Use "::1" in place of "127.0.0.1" when IPv6 is enabled.
    
    Reported by: Alexandru Iancu <address@hidden>

diff --git a/myserver/include/base/socket/socket.h 
b/myserver/include/base/socket/socket.h
index c65752a..0146039 100644
--- a/myserver/include/base/socket/socket.h
+++ b/myserver/include/base/socket/socket.h
@@ -55,6 +55,12 @@ typedef int SocketHandle;
 #  define MAX_IP_STRING_LEN  32
 # endif
 
+# if HAVE_IPV6
+#  define LOCALHOST_ADDRESS "::1"
+# else
+#  define LOCALHOST_ADDRESS "127.0.0.1"
+# endif
+
 typedef struct sockaddr_storage MYSERVER_SOCKADDR_STORAGE;
 typedef struct sockaddr_storage MYSERVER_SOCKADDRIN;
 typedef struct sockaddr_storage MYSERVER_SOCKADDR;
diff --git a/myserver/src/base/process/process_server_manager.cpp 
b/myserver/src/base/process/process_server_manager.cpp
index cf1618e..9e55079 100644
--- a/myserver/src/base/process/process_server_manager.cpp
+++ b/myserver/src/base/process/process_server_manager.cpp
@@ -18,7 +18,7 @@
 #include "myserver.h"
 
 #include <include/base/process/process_server_manager.h>
-
+#include <include/base/socket/socket.h>
 #include <include/server/server.h>
 #include <include/base/process/process.h>
 #include <string>
@@ -401,7 +401,7 @@ int ProcessServerManager::runServer 
(ProcessServerManager::Server* server,
   MYSERVER_SOCKADDRIN serverSockAddrIn;
   int addrLen = sizeof (serverSockAddrIn);
 
-  server->host.assign ("127.0.0.1");
+  server->host.assign (LOCALHOST_ADDRESS);
   server->isLocal = true;
 
   if (nServers >= maxServers)
diff --git a/myserver/src/base/socket/socket.cpp 
b/myserver/src/base/socket/socket.cpp
index 70dadc6..27b81f5 100644
--- a/myserver/src/base/socket/socket.cpp
+++ b/myserver/src/base/socket/socket.cpp
@@ -296,11 +296,11 @@ int Socket::getLocalIPsList (string &out)
       for (i = 0; (localhe->h_addr_list[i]); i++)
         {
 # ifdef WIN32
-          ia.S_un.S_addr = *((u_long FAR*) (localhe->h_addr_list[i]));
+          ia.S_un.S_addr = *((u_long FAR *) (localhe->h_addr_list[i]));
 # else
           ia.s_addr = *((u_long *) (localhe->h_addr_list[i]));
 # endif
-          stream << ( (i != 0) ? ", " : "") << inet_ntoa (ia);
+          stream << ((i != 0) ? ", " : "") << inet_ntoa (ia);
         }
 
       out.assign (stream.str ());
@@ -308,7 +308,7 @@ int Socket::getLocalIPsList (string &out)
     }
   else
     {
-      out.assign ("127.0.0.1");
+      out.assign (LOCALHOST_ADDRESS);
       return 0;
     }
 #endif//HAVE_IPV6
@@ -353,7 +353,7 @@ int Socket::send (const char* buffer, int len, int flags)
         /*! On errors returns directly -1.  */
         if (ret < 0)
           return -1;
-        toSend -= (u_long)ret;
+        toSend -= (u_long) ret;
         /*!
          *If there are other bytes to send wait before cycle again.
          */
diff --git a/myserver/tests/test_connection.cpp 
b/myserver/tests/test_connection.cpp
index ba7fbcf..30fea07 100644
--- a/myserver/tests/test_connection.cpp
+++ b/myserver/tests/test_connection.cpp
@@ -18,6 +18,7 @@
 #include "myserver.h"
 #include <ctype.h>
 
+#include "../include/base/socket/socket.h"
 #include <cppunit/CompilerOutputter.h>
 #include <cppunit/extensions/TestFactoryRegistry.h>
 #include <cppunit/ui/text/TestRunner.h>
@@ -87,8 +88,8 @@ public:
 
   void testIpAddress ()
   {
-    connection->setIpAddr ("127.0.0.1");
-    CPPUNIT_ASSERT (strcmp (connection->getIpAddr (), "127.0.0.1") == 0);
+    connection->setIpAddr (LOCALHOST_ADDRESS);
+    CPPUNIT_ASSERT (strcmp (connection->getIpAddr (), LOCALHOST_ADDRESS) == 0);
   }
 
   void testActiveThread ()
@@ -104,8 +105,8 @@ public:
 
   void testLocalIpAddress ()
   {
-    connection->setLocalIpAddr ("127.0.0.1");
-    CPPUNIT_ASSERT (strcmp (connection->getLocalIpAddr (), "127.0.0.1") == 0);
+    connection->setLocalIpAddr (LOCALHOST_ADDRESS);
+    CPPUNIT_ASSERT (strcmp (connection->getLocalIpAddr (), LOCALHOST_ADDRESS) 
== 0);
   }
 
   void testTries ()
diff --git a/myserver/tests/test_log_manager.cpp 
b/myserver/tests/test_log_manager.cpp
index 67ada1d..27afaf3 100644
--- a/myserver/tests/test_log_manager.cpp
+++ b/myserver/tests/test_log_manager.cpp
@@ -32,6 +32,7 @@
 #include <include/log/log_manager.h>
 #include <include/filter/filters_factory.h>
 #include <include/base/file/files_utility.h>
+#include <include/base/socket/socket.h>
 #include <include/base/file/file.h>
 #include <include/base/utility.h>
 #include <include/filter/gzip/gzip.h>
@@ -509,7 +510,8 @@ public:
 
     filters.push_back ("not_existing_filter");
 
-    CPPUNIT_ASSERT (lm->add (this, "test", "socket://127.0.0.1:6666", filters, 
0));
+    CPPUNIT_ASSERT (lm->add (this, "test", "socket://" LOCALHOST_ADDRESS 
":6666",
+                             filters, 0));
   }
 
   void testConsoleStreamAddWithNotExistingFilter ()
diff --git a/myserver/tests/test_log_stream_factory.cpp 
b/myserver/tests/test_log_stream_factory.cpp
index 367f023..3d4886b 100644
--- a/myserver/tests/test_log_stream_factory.cpp
+++ b/myserver/tests/test_log_stream_factory.cpp
@@ -24,6 +24,7 @@
 #include <cppunit/ui/text/TestRunner.h>
 #include <cppunit/extensions/HelperMacros.h>
 
+#include <include/base/socket/socket.h>
 #include <include/log/stream/log_stream_factory.h>
 #include <include/filter/filters_factory.h>
 
@@ -54,7 +55,7 @@ public:
   {
     CPPUNIT_ASSERT (!lsf->getPath ("foo:bla").size ());
     CPPUNIT_ASSERT (!lsf->getPath ("foo://bar").size ());
-    CPPUNIT_ASSERT (lsf->getPath ("socket://127.0.0.1:0").size ());
+    CPPUNIT_ASSERT (lsf->getPath ("socket://" LOCALHOST_ADDRESS ":0").size ());
   }
 
   void testCreation ()
@@ -68,7 +69,8 @@ public:
     CPPUNIT_ASSERT (!ls);
     ls = lsf->create (&ff, "console://stdout", filters, 0);
     CPPUNIT_ASSERT (ls);
-    CPPUNIT_ASSERT (!lsf->create (&ff, "socket://127.0.0.1:0", filters, 0));
+    CPPUNIT_ASSERT (!lsf->create (&ff, "socket://" LOCALHOST_ADDRESS ":0",
+                                  filters, 0));
     delete ls;
   }
 
diff --git a/myserver/tests/test_socket.cpp b/myserver/tests/test_socket.cpp
index 326917c..385984c 100644
--- a/myserver/tests/test_socket.cpp
+++ b/myserver/tests/test_socket.cpp
@@ -95,7 +95,7 @@ public:
     int status;
 
     ((sockaddr_in*) (&sockIn))->sin_family = AF_INET;
-    ((sockaddr_in*) (&sockIn))->sin_addr.s_addr = inet_addr ("127.0.0.1");
+    ((sockaddr_in*) (&sockIn))->sin_addr.s_addr = inet_addr 
(LOCALHOST_ADDRESS);
     ((sockaddr_in*) (&sockIn))->sin_port = htons (arg.port);
 
     socklen_t sockInLen = sizeof (sockaddr_in);
@@ -178,7 +178,7 @@ static DEFINE_THREAD (testRecvClient, pParam)
     {
       int ret;
       Socket *obj2 = new Socket;
-      char host[] = "127.0.0.1";
+      char host[] = LOCALHOST_ADDRESS;
 
       ret = obj2->socket (AF_INET, SOCK_STREAM, 0);
       CPPUNIT_ASSERT (ret != -1);
diff --git a/myserver/tests/test_socket_stream_creator.cpp 
b/myserver/tests/test_socket_stream_creator.cpp
index 1f37c27..abc53df 100644
--- a/myserver/tests/test_socket_stream_creator.cpp
+++ b/myserver/tests/test_socket_stream_creator.cpp
@@ -46,7 +46,7 @@ public:
   void testCreation ()
   {
     list<string> filters;
-    LogStream* ls = ssc->create (ff, "127.0.0.1:0", filters, 0);
+    LogStream* ls = ssc->create (ff, LOCALHOST_ADDRESS ":0", filters, 0);
     CPPUNIT_ASSERT (!ls);
   }
 
diff --git a/myserver/tests/test_ssl_socket.cpp 
b/myserver/tests/test_ssl_socket.cpp
index 5a1ba0a..a65d618 100644
--- a/myserver/tests/test_ssl_socket.cpp
+++ b/myserver/tests/test_ssl_socket.cpp
@@ -25,11 +25,12 @@
 #include <cppunit/ui/text/TestRunner.h>
 #include <cppunit/extensions/HelperMacros.h>
 
-#include "../include/base/socket/ssl_socket.h"
-#include "../include/base/file/file.h"
-#include "../include/base/file/files_utility.h"
-#include "../include/base/thread/thread.h"
-#include "../include/base/utility.h"
+#include <include/base/socket/socket.h>
+#include <include/base/socket/ssl_socket.h>
+#include <include/base/file/file.h>
+#include <include/base/file/files_utility.h>
+#include <include/base/thread/thread.h>
+#include <include/base/utility.h>
 
 extern "C"
 {
@@ -144,7 +145,7 @@ public:
     int status;
 
     ((sockaddr_in*) (&sockIn))->sin_family = AF_INET;
-    ((sockaddr_in*) (&sockIn))->sin_addr.s_addr = inet_addr ("127.0.0.1");
+    ((sockaddr_in*) (&sockIn))->sin_addr.s_addr = inet_addr 
(LOCALHOST_ADDRESS);
     ((sockaddr_in*) (&sockIn))->sin_port = htons (port);
 
     socklen_t sockInLen = sizeof (sockaddr_in);
@@ -234,7 +235,7 @@ static DEFINE_THREAD (testSslRecvClient, pParam)
   MYSERVER_SOCKADDRIN sockIn = { 0 };
 
   ((sockaddr_in*) (&sockIn))->sin_family = AF_INET;
-  ((sockaddr_in*) (&sockIn))->sin_addr.s_addr = inet_addr ("127.0.0.1");
+  ((sockaddr_in*) (&sockIn))->sin_addr.s_addr = inet_addr (LOCALHOST_ADDRESS);
   ((sockaddr_in*) (&sockIn))->sin_port = htons (arg->port);
 
   int sockInLen = sizeof (struct sockaddr_in);



commit 2266681e100b2229e104b0b75945abfe81e0f1e8
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Feb 19 15:31:24 2010 +0100

    Indent according to the coding style.

diff --git a/myserver/src/protocol/ftp/ftp_parser.ypp 
b/myserver/src/protocol/ftp/ftp_parser.ypp
index 3b9c3fd..618dd09 100755
--- a/myserver/src/protocol/ftp/ftp_parser.ypp
+++ b/myserver/src/protocol/ftp/ftp_parser.ypp
@@ -12,11 +12,12 @@
 %parse-param { Ftp *pContext }
 %locations
 
-%union {
-       int             m_nInt;
-       char            m_nChar;
-       char            m_szStr[PARSER_STR_LEN];
-       FtpHost         m_host;
+%union
+{
+  int          m_nInt;
+  char         m_nChar;
+  char         m_szStr[PARSER_STR_LEN];
+  FtpHost      m_host;
 }
 
 %{
@@ -361,85 +362,91 @@ format_control_code : 'n'
 
 int Ftp::parseControlConnection()
 {
-       if ( td.buffer == NULL || td.buffer->getBuffer() == NULL )
-               return ClientsThread::DELETE_CONNECTION;
-       FtpuserData *pFtpuserData = static_cast<FtpuserData 
*>(td.pConnection->protocolBuffer);
-       if ( pFtpuserData == NULL )
-               return ClientsThread::DELETE_CONNECTION;
-
-       // awaiting commands reply
-       if ( pFtpuserData->m_nFtpstate <= FtpuserData::NO_CONTROL_CONNECTION )
-       {
-               ftpReply(220);
-               pFtpuserData->m_nFtpstate = FtpuserData::CONTROL_CONNECTION_UP;
-       }
-
-       MemBuf out;
-       escapeTelnet(*td.buffer, out);
-       if ( !m_bEnablePipelining )
-       {
-               MemBuf tmpBuff(out);
-               removePipelinedCmds(tmpBuff, out);
-       }
-       char *pBuffToParse = out.getBuffer();
-
-       if ( pBuffToParse == NULL || td.buffersize <= td.m_nParseLength )// 
nothing to parse ...
-               return ClientsThread::KEEP_CONNECTION;
-       else
-               pBuffToParse += td.m_nParseLength;
-
-       yylex_init(&m_scanner);
-       yy_buffer_state *bufstate = yy_scan_string (pBuffToParse, m_scanner);
-       int nParserRet = yyparse(this);
-       yy_delete_buffer(bufstate, m_scanner);
-       yylex_destroy(m_scanner);
-       switch ( nParserRet )
-       {
-               case 0:
-                       if ( pFtpuserData->m_nFtpstate == 
FtpuserData::NO_CONTROL_CONNECTION )
-                               return ClientsThread::DELETE_CONNECTION;
-                       else
-                               return ClientsThread::KEEP_CONNECTION;
-               case 1:
-                       // parsing failed because of invalid input!
-                       return ClientsThread::DELETE_CONNECTION;
-               case 2:
-                       // memory exhaustion!
-                       return ClientsThread::DELETE_CONNECTION;
-       }//TODO: handle INCOMPLETE_REQUEST
-       return ClientsThread::DELETE_CONNECTION;
+  if (td.buffer == NULL || td.buffer->getBuffer() == NULL)
+    return ClientsThread::DELETE_CONNECTION;
+
+  FtpuserData *pFtpuserData = static_cast<FtpuserData *> 
(td.pConnection->protocolBuffer);
+  if (pFtpuserData == NULL)
+    return ClientsThread::DELETE_CONNECTION;
+
+  /* awaiting commands reply.  */
+  if (pFtpuserData->m_nFtpstate <= FtpuserData::NO_CONTROL_CONNECTION)
+    {
+      ftpReply (220);
+      pFtpuserData->m_nFtpstate = FtpuserData::CONTROL_CONNECTION_UP;
+    }
+
+  MemBuf out;
+  escapeTelnet (*td.buffer, out);
+  if (! m_bEnablePipelining)
+    {
+      MemBuf tmpBuff (out);
+      removePipelinedCmds (tmpBuff, out);
+    }
+  char *pBuffToParse = out.getBuffer ();
+
+  if (pBuffToParse == NULL || td.buffersize <= td.m_nParseLength )
+    return ClientsThread::KEEP_CONNECTION;
+  else
+    pBuffToParse += td.m_nParseLength;
+
+  yylex_init (&m_scanner);
+  yy_buffer_state *bufstate = yy_scan_string (pBuffToParse, m_scanner);
+  int nParserRet = yyparse (this);
+  yy_delete_buffer (bufstate, m_scanner);
+  yylex_destroy (m_scanner);
+
+  switch (nParserRet)
+    {
+    case 0:
+      if (pFtpuserData->m_nFtpstate == FtpuserData::NO_CONTROL_CONNECTION )
+        return ClientsThread::DELETE_CONNECTION;
+      else
+        return ClientsThread::KEEP_CONNECTION;
+
+    case 1:
+      /* Invalid input.  */
+      return ClientsThread::DELETE_CONNECTION;
+
+    case 2:
+      /* memory exhaustion!  */
+      return ClientsThread::DELETE_CONNECTION;
+    }
+  /*TODO: handle INCOMPLETE_REQUEST */
+  return ClientsThread::DELETE_CONNECTION;
 }
 
-u_long Ftp::computeParseLength(const YYLTYPE &location)
+u_long Ftp::computeParseLength (const YYLTYPE &location)
 {
-       if ( td.buffer == NULL )
-               return 1;
-       int nBuffLine = 1, nBuffCol = 0;
-       char *pszBuff = td.buffer->getBuffer();
-       for ( u_long i = 0; i < td.buffersize; i++ )
-       {
-               if ( pszBuff[i] == '\n' )
-               {
-                       nBuffLine++;
-                       nBuffCol = 0;
-               }
-               else
-                       nBuffCol++;
-               if ( nBuffLine == location.last_line && nBuffCol == 
location.last_column )
-               {
-                       td.m_nParseLength = i;
-                       return 0;
-               }
-       }
-       return 1;//error
+  if (td.buffer == NULL)
+    return 1;
+
+  int nBuffLine = 1, nBuffCol = 0;
+  char *pszBuff = td.buffer->getBuffer ();
+  for (u_long i = 0; i < td.buffersize; i++)
+    {
+      if (pszBuff[i] == '\n')
+        {
+          nBuffLine++;
+          nBuffCol = 0;
+        }
+      else
+        nBuffCol++;
+      if (nBuffLine == location.last_line && nBuffCol == location.last_column)
+        {
+          td.m_nParseLength = i;
+          return 0;
+        }
+    }
+
+  return 1;
 }
 
-///////////////////////////////////////////////////////////
-// global fncs
+/* Global functions.  */
 
-void yyerror(YYLTYPE *pLoc, Ftp *pContext, const char *msg)
+void yyerror (YYLTYPE *pLoc, Ftp *pContext, const char *msg)
 {
-       if ( pContext == NULL )
-               return;
-       pContext->printError(msg);
+  if (pContext == NULL)
+    return;
+  pContext->printError (msg);
 }



commit 96f3660d8c508bf0a42fc286910ef54e62658428
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Feb 19 15:23:18 2010 +0100

    The buffer length reflects the number of bytes ready for processing

diff --git a/myserver/src/server/clients_thread.cpp 
b/myserver/src/server/clients_thread.cpp
index 4704956..bc78372 100644
--- a/myserver/src/server/clients_thread.cpp
+++ b/myserver/src/server/clients_thread.cpp
@@ -271,7 +271,7 @@ int ClientsThread::controlConnections ()
   if (err == -1 && !server->deleteConnection (c))
     return 0;
 
-  buffer.setRealLength (dataRead + err);
+  buffer.setLength (dataRead + err);
   c->setForceControl (0);
 
   /* Refresh with the right value.  */
@@ -295,26 +295,25 @@ int ClientsThread::controlConnections ()
   c->setActiveThread (this);
   try
   {
+    retcode = ClientsThread::DELETE_CONNECTION;
     if (c->hasContinuation ())
       {
-        retcode = c->getContinuation ()(c, (char*)buffer.getBuffer (),
-                                   (char*)auxiliaryBuffer.getBuffer (),
-                                   buffer.getRealLength (),
-                                   auxiliaryBuffer.getRealLength (),
-                                   nBytesToRead, id);
+        retcode = c->getContinuation ()(c, (char*) buffer.getBuffer (),
+                                   (char*) auxiliaryBuffer.getBuffer (),
+                                        buffer.getRealLength (),
+                                        auxiliaryBuffer.getRealLength (),
+                                        nBytesToRead, id);
         c->setContinuation (NULL);
       }
     else
       {
         protocol = server->getProtocol (c->host->getProtocolName ());
         if (protocol)
-          retcode = protocol->controlConnection (c, (char*)buffer.getBuffer (),
-                                           (char*)auxiliaryBuffer.getBuffer (),
-                                           buffer.getRealLength (),
-                                           auxiliaryBuffer.getRealLength (),
-                                           nBytesToRead, id);
-        else
-          retcode = ClientsThread::DELETE_CONNECTION;
+          retcode = protocol->controlConnection (c, (char*) buffer.getBuffer 
(),
+                                                 (char*) 
auxiliaryBuffer.getBuffer (),
+                                                 buffer.getRealLength (),
+                                                 auxiliaryBuffer.getRealLength 
(),
+                                                 nBytesToRead, id);
       }
   }
   catch (...)

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

Summary of changes:
 myserver/include/base/socket/socket.h              |    6 +
 .../src/base/process/process_server_manager.cpp    |    4 +-
 myserver/src/base/socket/socket.cpp                |    8 +-
 myserver/src/protocol/ftp/ftp_parser.ypp           |  165 ++++++++++----------
 myserver/src/server/clients_thread.cpp             |   25 ++--
 myserver/tests/test_connection.cpp                 |    9 +-
 myserver/tests/test_log_manager.cpp                |    4 +-
 myserver/tests/test_log_stream_factory.cpp         |    6 +-
 myserver/tests/test_socket.cpp                     |    4 +-
 myserver/tests/test_socket_stream_creator.cpp      |    2 +-
 myserver/tests/test_ssl_socket.cpp                 |   15 +-
 11 files changed, 133 insertions(+), 115 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

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