From MAILER-DAEMON Thu Apr 02 04:30:52 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LpIK4-0007vf-4f for mharc-myserver-commit@gnu.org; Thu, 02 Apr 2009 04:30:52 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LpIK1-0007uA-Eh for myserver-commit@gnu.org; Thu, 02 Apr 2009 04:30:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LpIK0-0007tX-AF for myserver-commit@gnu.org; Thu, 02 Apr 2009 04:30:48 -0400 Received: from [199.232.76.173] (port=44803 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LpIK0-0007tJ-1J for myserver-commit@gnu.org; Thu, 02 Apr 2009 04:30:48 -0400 Received: from savannah.gnu.org ([199.232.41.3]:34358 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LpIJz-0001GB-Ol for myserver-commit@gnu.org; Thu, 02 Apr 2009 04:30:47 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LpIJx-0007y7-Qi for myserver-commit@gnu.org; Thu, 02 Apr 2009 08:30:46 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LpIJv-0007xh-Q8 for myserver-commit@gnu.org; Thu, 02 Apr 2009 08:30:44 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Thu, 02 Apr 2009 08:30:44 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3044] Don't use uninitialised memory. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2009 08:30:50 -0000 Revision: 3044 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3044 Author: gscrivano Date: 2009-04-02 08:30:35 +0000 (Thu, 02 Apr 2009) Log Message: ----------- Don't use uninitialised memory. Modified Paths: -------------- trunk/myserver/src/http_handler/http_dir/http_dir.cpp Modified: trunk/myserver/src/http_handler/http_dir/http_dir.cpp =================================================================== --- trunk/myserver/src/http_handler/http_dir/http_dir.cpp 2009-03-30 21:44:54 UTC (rev 3043) +++ trunk/myserver/src/http_handler/http_dir/http_dir.cpp 2009-04-02 08:30:35 UTC (rev 3044) @@ -307,7 +307,7 @@ bool keepalive = false; vector files; size_t sortIndex; - char sortType; + char sortType = 0; bool sortReverse = false; string linkPrefix; const char *formatString = td->securityToken.getHashedData ("http.dir.format", @@ -386,10 +386,10 @@ sort (files.begin(), files.end(), compareFileStructByName); } - browseDirCSSpath = td->securityToken.getHashedData ("http.dir.css", MYSERVER_SECURITY_CONF | MYSERVER_VHOST_CONF | + browseDirCSSpath = td->securityToken.getHashedData ("http.dir.css", + MYSERVER_SECURITY_CONF | MYSERVER_VHOST_CONF | MYSERVER_SERVER_CONF, NULL); - td->secondaryBuffer->setLength(0); *td->secondaryBuffer << "\r\n" ") id 1LpIKn-0001QC-OU for myserver-commit@gnu.org; Thu, 02 Apr 2009 04:31:37 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LpIKm-00085S-FL for myserver-commit@gnu.org; Thu, 02 Apr 2009 08:31:36 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LpIKl-00085B-Bi for myserver-commit@gnu.org; Thu, 02 Apr 2009 08:31:35 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Thu, 02 Apr 2009 08:31:35 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3045] Provide the right size to `Socket::accept'. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2009 08:31:39 -0000 Revision: 3045 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3045 Author: gscrivano Date: 2009-04-02 08:31:32 +0000 (Thu, 02 Apr 2009) Log Message: ----------- Provide the right size to `Socket::accept'. Modified Paths: -------------- trunk/myserver/src/connections_scheduler/connections_scheduler.cpp Modified: trunk/myserver/src/connections_scheduler/connections_scheduler.cpp =================================================================== --- trunk/myserver/src/connections_scheduler/connections_scheduler.cpp 2009-04-02 08:30:35 UTC (rev 3044) +++ trunk/myserver/src/connections_scheduler/connections_scheduler.cpp 2009-04-02 08:31:32 UTC (rev 3045) @@ -149,7 +149,7 @@ int asockInLen = 0; Socket asock; - asockInLen = sizeof (sockaddr_in); + asockInLen = sizeof (asockIn); asock = s->serverSocket->accept (&asockIn, &asockInLen); if (s->server && From MAILER-DAEMON Thu Apr 02 05:21:51 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LpJ7P-0006wt-An for mharc-myserver-commit@gnu.org; Thu, 02 Apr 2009 05:21:51 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LpJ7N-0006v6-CW for myserver-commit@gnu.org; Thu, 02 Apr 2009 05:21:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LpJ7L-0006tB-KY for myserver-commit@gnu.org; Thu, 02 Apr 2009 05:21:48 -0400 Received: from [199.232.76.173] (port=46873 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LpJ7K-0006sl-Ty for myserver-commit@gnu.org; Thu, 02 Apr 2009 05:21:47 -0400 Received: from savannah.gnu.org ([199.232.41.3]:54642 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LpJ7K-0007eN-3Z for myserver-commit@gnu.org; Thu, 02 Apr 2009 05:21:46 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LpJ7I-0004ZC-Pp for myserver-commit@gnu.org; Thu, 02 Apr 2009 09:21:45 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LpJ7H-0004Yl-EW for myserver-commit@gnu.org; Thu, 02 Apr 2009 09:21:44 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Thu, 02 Apr 2009 09:21:43 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3046] The `NOT_WIN' macro is not used anymore. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2009 09:21:49 -0000 Revision: 3046 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3046 Author: gscrivano Date: 2009-04-02 09:21:41 +0000 (Thu, 02 Apr 2009) Log Message: ----------- The `NOT_WIN' macro is not used anymore. Modified Paths: -------------- trunk/myserver/include/base/find_data/find_data.h trunk/myserver/include/base/pipe/pipe.h trunk/myserver/include/base/socket/socket.h trunk/myserver/include/base/socket/ssl_socket.h trunk/myserver/include/base/string/stringutils.h trunk/myserver/include/filter/console.h trunk/myserver/include/filter/stream.h trunk/myserver/include/protocol/http/http_headers.h trunk/myserver/include/protocol/http/http_thread_context.h trunk/myserver/include/server/server.h trunk/myserver/src/base/base64/mime_utils.cpp trunk/myserver/src/base/file/file.cpp trunk/myserver/src/base/file/files_utility.cpp trunk/myserver/src/base/files_cache/cached_file.cpp trunk/myserver/src/base/files_cache/cached_file_buffer.cpp trunk/myserver/src/base/files_cache/cached_file_factory.cpp trunk/myserver/src/base/find_data/find_data.cpp trunk/myserver/src/base/pipe/pipe.cpp trunk/myserver/src/base/process/fork_server.cpp trunk/myserver/src/base/process/process.cpp trunk/myserver/src/base/safetime/safetime.cpp trunk/myserver/src/base/socket/socket.cpp trunk/myserver/src/base/socket/ssl_socket.cpp trunk/myserver/src/base/socket_pair/socket_pair.cpp trunk/myserver/src/base/string/stringutils.cpp trunk/myserver/src/base/thread/thread.cpp trunk/myserver/src/base/utility.cpp trunk/myserver/src/connections_scheduler/listen_threads.cpp trunk/myserver/src/filter/console.cpp trunk/myserver/src/filter/gzip/gzip.cpp trunk/myserver/src/filter/gzip/gzip_decompress.cpp trunk/myserver/src/http_handler/http_dir/http_dir.cpp trunk/myserver/src/http_handler/http_file/http_file.cpp trunk/myserver/src/http_handler/isapi/isapi.cpp trunk/myserver/src/myserver.cpp trunk/myserver/src/plugin/plugins_manager.cpp trunk/myserver/src/protocol/control/control_header.cpp trunk/myserver/src/protocol/control/control_protocol.cpp trunk/myserver/src/protocol/ftp/ftp.cpp trunk/myserver/src/protocol/http/http.cpp trunk/myserver/src/protocol/http/http_data_read.cpp trunk/myserver/src/protocol/http/http_headers.cpp trunk/myserver/src/protocol/http/http_thread_context.cpp trunk/myserver/src/protocol/https/https.cpp trunk/myserver/src/server/clients_thread.cpp trunk/myserver/src/server/server.cpp trunk/myserver/stdafx.h trunk/myserver/tests/test_file_stream.cpp trunk/myserver/tests/test_homedir.cpp trunk/myserver/tests/test_log_manager.cpp Modified: trunk/myserver/include/base/find_data/find_data.h =================================================================== --- trunk/myserver/include/base/find_data/find_data.h 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/include/base/find_data/find_data.h 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 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 @@ -31,7 +31,7 @@ #include #include #include -#ifdef NOT_WIN +#ifndef WIN32 #include #endif #include @@ -67,17 +67,20 @@ int findclose(); FindData(); ~FindData(); -#ifdef NOT_WIN - struct stat* getStatStruct(){return &stats;} + struct stat* getStatStruct() + { +#ifndef WIN32 + return &stats; +#else + return NULL; #endif + } private: #ifdef WIN32 _finddata_t fd; intptr_t ff; -#endif - -#ifdef NOT_WIN +#else string DirName; DIR *dh; struct stat stats; Modified: trunk/myserver/include/base/pipe/pipe.h =================================================================== --- trunk/myserver/include/base/pipe/pipe.h 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/include/base/pipe/pipe.h 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 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 @@ -43,7 +43,7 @@ int waitForData (int sec, int usec); private: bool terminated; -#ifdef NOT_WIN +#ifndef WIN32 int handles[2]; #else HANDLE readHandle; Modified: trunk/myserver/include/base/socket/socket.h =================================================================== --- trunk/myserver/include/base/socket/socket.h 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/include/base/socket/socket.h 2009-04-02 09:21:41 UTC (rev 3046) @@ -35,7 +35,7 @@ #endif #endif -#ifdef NOT_WIN +#ifndef WIN32 extern "C" { #include #include Modified: trunk/myserver/include/base/socket/ssl_socket.h =================================================================== --- trunk/myserver/include/base/socket/ssl_socket.h 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/include/base/socket/ssl_socket.h 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 2006, 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 @@ -29,7 +29,7 @@ #include -#ifdef NOT_WIN +#ifndef WIN32 extern "C" { #include #include Modified: trunk/myserver/include/base/string/stringutils.h =================================================================== --- trunk/myserver/include/base/string/stringutils.h 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/include/base/string/stringutils.h 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 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 @@ -75,7 +75,7 @@ int stringcmpi(string const &a, const char* b); int stringcmp(string const &a, const char* b); -#ifdef NOT_WIN +#ifndef WIN32 extern "C" { char* strupr(char * string); Modified: trunk/myserver/include/filter/console.h =================================================================== --- trunk/myserver/include/filter/console.h 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/include/filter/console.h 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer - Copyright (C) 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2006, 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 @@ -42,8 +42,7 @@ #ifdef WIN32 map fg_colors; map bg_colors; -#endif -#ifdef NOT_WIN +#else map fg_colors; map bg_colors; #endif Modified: trunk/myserver/include/filter/stream.h =================================================================== --- trunk/myserver/include/filter/stream.h 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/include/filter/stream.h 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 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 @@ -23,8 +23,7 @@ #ifdef WIN32 typedef void* FileHandle; -#endif -#ifdef NOT_WIN +#else typedef int FileHandle; #endif Modified: trunk/myserver/include/protocol/http/http_headers.h =================================================================== --- trunk/myserver/include/protocol/http/http_headers.h 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/include/protocol/http/http_headers.h 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 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 @@ -26,8 +26,7 @@ #ifdef WIN32 #include #include -#endif -#ifdef NOT_WIN +#else #include #include #endif Modified: trunk/myserver/include/protocol/http/http_thread_context.h =================================================================== --- trunk/myserver/include/protocol/http/http_thread_context.h 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/include/protocol/http/http_thread_context.h 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 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 @@ -33,8 +33,7 @@ #ifdef WIN32 #include #include -#endif -#ifdef NOT_WIN +#else #include #include #endif Modified: trunk/myserver/include/server/server.h =================================================================== --- trunk/myserver/include/server/server.h 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/include/server/server.h 2009-04-02 09:21:41 UTC (rev 3046) @@ -57,8 +57,7 @@ */ #ifdef WIN32 unsigned int __stdcall listenServer(void* pParam); -#endif -#ifdef NO_WIN +#else void* listenServer(void* pParam); #endif Modified: trunk/myserver/src/base/base64/mime_utils.cpp =================================================================== --- trunk/myserver/src/base/base64/mime_utils.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/base64/mime_utils.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 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 @@ -21,15 +21,18 @@ #include extern "C" { -#include -#include -#ifdef NOT_WIN +#ifndef WIN32 #include #include #endif + +#include +#include } + #define strupos(x, y) (strustr(x, y) != NULL ? strustr(x, y) - x : -1) //char version -char* strustr(char *source, char *s) + +static char* strustr(char *source, char *s) { char *csource = new char[strlen(source) + 1]; Modified: trunk/myserver/src/base/file/file.cpp =================================================================== --- trunk/myserver/src/base/file/file.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/file/file.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -21,7 +21,7 @@ #include #include -#ifdef NOT_WIN +#ifndef WIN32 extern "C" { #include #include @@ -93,8 +93,7 @@ #ifdef WIN32 int ret = WriteFile((HANDLE)handle,buffer,buffersize,nbw,NULL); return (!ret); -#endif -#ifdef NOT_WIN +#else *nbw = ::write((long)handle, buffer, buffersize); return (*nbw == buffersize) ? 0 : 1 ; #endif @@ -180,9 +179,7 @@ return 1; } } - -#endif -#ifdef NOT_WIN +#else struct stat F_Stats; int F_Flags; if(opt & File::MYSERVER_OPEN_READ && opt & File::MYSERVER_OPEN_WRITE) @@ -356,8 +353,7 @@ #ifdef WIN32 ret = !FlushFileBuffers((HANDLE)handle); ret |= CloseHandle((HANDLE)handle); -#endif -#ifdef NOT_WIN +#else ret = fsync((long)handle); ret |= ::close((long)handle); #endif @@ -382,8 +378,7 @@ } else return (u_long)-1; -#endif -#ifdef NOT_WIN +#else struct stat F_Stats; ret = fstat((long)handle, &F_Stats); if(ret) @@ -404,8 +399,7 @@ ret = SetFilePointer ((HANDLE)handle, initialByte, NULL, FILE_BEGIN); /*! SetFilePointer returns INVALID_SET_FILE_POINTER on an error. */ return (ret == INVALID_SET_FILE_POINTER) ? 1 : 0; -#endif -#ifdef NOT_WIN +#else ret = lseek ((long)handle, initialByte, SEEK_SET); return (ret != initialByte ) ? 1 : 0; #endif @@ -459,8 +453,7 @@ #ifdef WIN32 int ret = ReadFile((HANDLE)handle, buffer, buffersize, nbr, NULL); return (!ret); -#endif -#ifdef NOT_WIN +#else int ret = ::read((long)handle, buffer, buffersize); *nbr = (u_long)ret; return (ret == -1) ; Modified: trunk/myserver/src/base/file/files_utility.cpp =================================================================== --- trunk/myserver/src/base/file/files_utility.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/file/files_utility.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -21,7 +21,7 @@ #include #include -#ifdef NOT_WIN +#ifndef WIN32 extern "C" { #include #include @@ -60,7 +60,7 @@ *The second IF tries to find at least two dots. *if it finds only 1, does nothing, *WIN32 if it finds 2 or more rec=rec-(number of dots -1) - *UNIX if it finds 2, decrements rec, if it finds more, + * *NIX if it finds 2, decrements rec, if it finds more, *increments it considering it's a name if it ends with *something else other then a bar of a NULL, *then it's a path of the form "/...qwerty/" that should be considered rec++ @@ -139,14 +139,8 @@ #ifdef WIN32 return MoveFile(before, after) ? 0 : 1; #else - -#ifdef NOT_WIN return rename(before, after); -#else - return -1; #endif - -#endif } /*! @@ -246,8 +240,7 @@ ret = DeleteFile(filename); if(ret) return 0; -#endif -#ifdef NOT_WIN +#else ret = remove(filename); #endif return ret; @@ -265,8 +258,7 @@ return(fa & FILE_ATTRIBUTE_DIRECTORY)?1:0; else return 0; -#endif -#ifdef NOT_WIN +#else struct stat F_Stats; int ret = stat(filename, &F_Stats); if(ret < 0) @@ -284,8 +276,7 @@ { #ifdef WIN32 return 0; -#endif -#ifdef NOT_WIN +#else struct stat F_Stats; int ret = lstat(filename, &F_Stats); if(ret < 0) @@ -315,8 +306,7 @@ int nRet = hFile != INVALID_HANDLE_VALUE ? 1 : 0; CloseHandle(hFile); return nRet; -#endif -#ifdef NOT_WIN +#else struct stat F_Stats; int ret = stat(filename, &F_Stats); if(ret < 0) @@ -337,12 +327,12 @@ #ifdef WIN32 struct _stat sf; res = _stat(filename,&sf); -#endif -#ifdef NOT_WIN +#else struct stat sf; res = stat(filename,&sf); #endif - if(res==0) + + if(res == 0) return sf.st_mtime; else return (-1); @@ -359,8 +349,7 @@ #ifdef WIN32 struct _stat sf; res = _stat(filename, &sf); -#endif -#ifdef NOT_WIN +#else struct stat sf; res = stat(filename, &sf); #endif @@ -381,8 +370,7 @@ #ifdef WIN32 struct _stat sf; res = _stat(filename, &sf); -#endif -#ifdef NOT_WIN +#else struct stat sf; res = stat(filename, &sf); #endif @@ -401,7 +389,7 @@ */ int FilesUtility::chown(const char* filename, int uid, int gid) { -#ifdef NOT_WIN +#ifndef WIN32 return ::chown(filename, uid, gid) ? 1 : 0; #endif return 0; @@ -622,8 +610,7 @@ if(!ret) return -1; return 0; -#endif -#ifdef NOT_WIN +#else strncpy(out, filePath, buffersize); return 0; #endif @@ -674,9 +661,7 @@ return -1; return 0; -#endif - -#ifdef NOT_WIN +#else char *buffer; int bufferLen; int bufferNewLen; @@ -739,9 +724,7 @@ fileName.assign(buffer); return 0; -#endif - -#ifdef NOT_WIN +#else ostringstream stream; /* We assume that path starting with / are yet completed. */ if(fileName[0] != '/') @@ -763,7 +746,7 @@ { #ifdef WIN32 return CreateDirectory(path, NULL)?0:-1; -#else // NOT_WIN +#else return mkdir(path, S_IRUSR | S_IWUSR); #endif } @@ -778,7 +761,7 @@ { #ifdef WIN32 return RemoveDirectory(path)?0:-1; -#else // NOT_WIN +#else return rmdir(path); #endif } Modified: trunk/myserver/src/base/files_cache/cached_file.cpp =================================================================== --- trunk/myserver/src/base/files_cache/cached_file.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/files_cache/cached_file.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -22,7 +22,7 @@ #include #include -#ifdef NOT_WIN +#ifndef WIN32 extern "C" { #include #include Modified: trunk/myserver/src/base/files_cache/cached_file_buffer.cpp =================================================================== --- trunk/myserver/src/base/files_cache/cached_file_buffer.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/files_cache/cached_file_buffer.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2006, 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 @@ -24,7 +24,7 @@ #include #include -#ifdef NOT_WIN +#ifndef WIN32 extern "C" { #include #include Modified: trunk/myserver/src/base/files_cache/cached_file_factory.cpp =================================================================== --- trunk/myserver/src/base/files_cache/cached_file_factory.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/files_cache/cached_file_factory.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -22,7 +22,7 @@ #include #include -#ifdef NOT_WIN +#ifndef WIN32 extern "C" { #include #include Modified: trunk/myserver/src/base/find_data/find_data.cpp =================================================================== --- trunk/myserver/src/base/find_data/find_data.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/find_data/find_data.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 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 @@ -31,9 +31,7 @@ { #ifdef WIN32 ff = 0; -#endif - -#ifdef NOT_WIN +#else DirName.empty(); dh = 0; #endif @@ -44,9 +42,7 @@ */ FindData::~FindData() { -#ifdef NOT_WIN - DirName.empty(); -#endif + } /*! @@ -74,9 +70,7 @@ } else return ff; -#endif - -#ifdef NOT_WIN +#else struct dirent * dirInfo; string TempName; @@ -124,9 +118,7 @@ size = fd.size ; } return ret; -#endif - -#ifdef NOT_WIN +#else struct dirent * dirInfo; string TempName; @@ -163,8 +155,7 @@ ret = _findclose(ff); ff = 0; return ret; -#endif -#ifdef NOT_WIN +#else if(dh) closedir(dh); DirName.empty(); Modified: trunk/myserver/src/base/pipe/pipe.cpp =================================================================== --- trunk/myserver/src/base/pipe/pipe.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/pipe/pipe.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -20,7 +20,7 @@ #include #include -#ifdef NOT_WIN +#ifndef WIN32 extern "C" { #include #include @@ -52,7 +52,7 @@ int Pipe::read(char* buffer, u_long len, u_long *nbr) { *nbr = 0; -#ifdef NOT_WIN +#ifndef WIN32 int ret = ::read(handles[0], buffer, len); if(ret == -1) { @@ -95,7 +95,7 @@ */ int Pipe::create(bool readPipe) { -#ifdef NOT_WIN +#ifndef WIN32 #ifdef HAVE_PIPE return pipe (handles); @@ -149,7 +149,7 @@ int Pipe::write(const char* buffer, u_long len, u_long *nbw) { *nbw = 0; -#ifdef NOT_WIN +#ifndef WIN32 int ret = ::write(handles[1], buffer, len); if(ret == -1) { @@ -169,7 +169,7 @@ */ long Pipe::getReadHandle() { -#ifdef NOT_WIN +#ifndef WIN32 return handles[0]; #else return (long)readHandle; @@ -181,7 +181,7 @@ */ long Pipe::getWriteHandle() { -#ifdef NOT_WIN +#ifndef WIN32 return handles[1]; #else return (long)writeHandle; @@ -195,7 +195,7 @@ int Pipe::close() { terminated = true; -#ifdef NOT_WIN +#ifndef WIN32 if(handles[0]) ::close(handles[0]); if(handles[1]) @@ -218,7 +218,7 @@ */ void Pipe::inverted(Pipe& pipe) { -#ifdef NOT_WIN +#ifndef WIN32 handles[0] = pipe.handles[1]; handles[1] = pipe.handles[0]; #else @@ -230,7 +230,7 @@ Pipe::Pipe() { terminated = false; -#ifdef NOT_WIN +#ifndef WIN32 handles[0] = handles[1] = 0; #else readHandle = writeHandle = 0; @@ -243,7 +243,7 @@ void Pipe::closeRead() { terminated = true; -#ifdef NOT_WIN +#ifndef WIN32 if(handles[0]) ::close(handles[0]); handles[0] = 0; @@ -261,7 +261,7 @@ void Pipe::closeWrite() { terminated = true; -#ifdef NOT_WIN +#ifndef WIN32 if(handles[1]) ::close(handles[1]); handles[1] = 0; @@ -280,7 +280,7 @@ */ int Pipe::waitForData (int sec, int usec) { -#ifdef NOT_WIN +#ifndef WIN32 #if HAVE_PIPE struct timeval tv; Modified: trunk/myserver/src/base/process/fork_server.cpp =================================================================== --- trunk/myserver/src/base/process/fork_server.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/process/fork_server.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -15,13 +15,12 @@ along with this program. If not, see . */ - #include #include #include #include -#ifdef NOT_WIN +#ifndef WIN32 #include #include #endif @@ -146,7 +145,7 @@ */ int ForkServer::handleRequest (SocketPair *serverSock) { -#ifdef NOT_WIN +#ifndef WIN32 int ret, flags, stdIn = -1, stdOut = -1, stdErr = -1; int gid, uid; int stdInPort = 0; @@ -252,7 +251,7 @@ */ int ForkServer::forkServerLoop (SocketPair *socket) { -#ifdef NOT_WIN +#ifndef WIN32 for (;;) { try @@ -386,7 +385,7 @@ */ int ForkServer::startForkServer () { -#ifdef NOT_WIN +#ifndef WIN32 socket.create (); serverLock.init (); SocketPair inverted; Modified: trunk/myserver/src/base/process/process.cpp =================================================================== --- trunk/myserver/src/base/process/process.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/process/process.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -200,7 +200,7 @@ } #endif -#ifdef NOT_WIN +#ifndef WIN32 pid = fork (); if (pid < 0) // a bad thing happened @@ -304,7 +304,7 @@ return 0; #endif -#ifdef NOT_WIN +#ifndef WIN32 int status = 0; #ifdef PROCESS_ALIVE_USEWAITPID int ret; @@ -406,7 +406,7 @@ pid = 0; return (!ret); #endif -#ifdef NOT_WIN +#ifndef WIN32 ret = kill ((pid_t)pid, SIGKILL); pid = 0; return ret; @@ -418,7 +418,7 @@ */ int Process::setuid (u_long uid) { -#ifdef NOT_WIN +#ifndef WIN32 return ::setuid (uid); #endif return 0; @@ -429,7 +429,7 @@ */ int Process::setgid (u_long gid) { -#ifdef NOT_WIN +#ifndef WIN32 return ::setgid (gid); #endif return 0; @@ -440,7 +440,7 @@ */ int Process::setAdditionalGroups (u_long len, u_long *groups) { -#ifdef NOT_WIN +#ifndef WIN32 #if HAVE_SETGROUPS u_long i; Modified: trunk/myserver/src/base/safetime/safetime.cpp =================================================================== --- trunk/myserver/src/base/safetime/safetime.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/safetime/safetime.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 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 @@ -24,7 +24,7 @@ #include #include #include -#ifdef NOT_WIN +#ifndef WIN32 #include #endif } Modified: trunk/myserver/src/base/socket/socket.cpp =================================================================== --- trunk/myserver/src/base/socket/socket.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/socket/socket.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -174,8 +174,7 @@ return -1; #ifdef WIN32 return ::bind((SOCKET)socketHandle,(const struct sockaddr*)sa,namelen); -#endif -#ifdef NOT_WIN +#else return ::bind((int)socketHandle,(const struct sockaddr*)sa,namelen); #endif } @@ -187,8 +186,7 @@ { #ifdef WIN32 return ::listen(socketHandle,max); -#endif -#ifdef NOT_WIN +#else return ::listen((int)socketHandle,max); #endif } @@ -198,20 +196,15 @@ */ Socket Socket::accept(MYSERVER_SOCKADDR* sa, int* sockaddrlen) { -#ifdef NOT_WIN - socklen_t connectSize; - int acceptHandle; -#endif - Socket s; #ifdef WIN32 FileHandle h = (FileHandle)::accept(socketHandle,(struct sockaddr*)sa, sockaddrlen); s.setHandle(h); -#endif - -#ifdef NOT_WIN +#else + socklen_t connectSize; + int acceptHandle; connectSize = (socklen_t) *sockaddrlen; acceptHandle = ::accept((int)socketHandle, (struct sockaddr *)sa, @@ -236,9 +229,7 @@ } else return 0; -#endif - -#ifdef NOT_WIN +#else if(socketHandle) { int ret = ::close((int)socketHandle); @@ -257,8 +248,7 @@ { #ifdef WIN32 HOSTENT *he = ::gethostbyaddr(addr,len,type); -#endif -#ifdef NOT_WIN +#else struct hostent * he = ::gethostbyaddr(addr,len,type); #endif return he; @@ -279,9 +269,7 @@ { #ifdef WIN32 return ::shutdown(socketHandle,how); -#endif - -#ifdef NOT_WIN +#else return ::shutdown((int)socketHandle,how); #endif } @@ -351,8 +339,7 @@ { #ifdef WIN32 ia.S_un.S_addr = *((u_long FAR*) (localhe->h_addr_list[i])); -#endif -#ifdef NOT_WIN +#else ia.s_addr = *((u_long *) (localhe->h_addr_list[i])); #endif stream << ( (i != 0) ? ", " : "") << inet_ntoa(ia); @@ -457,8 +444,7 @@ { #ifdef WIN32 return ::ioctlsocket(socketHandle, cmd, argp); -#endif -#ifdef NOT_WIN +#else int int_argp = 0; int ret = ::ioctl((int)socketHandle, cmd, &int_argp); *argp = int_argp; @@ -609,18 +595,17 @@ int Socket::connect(MYSERVER_SOCKADDR* sa, int na) { if ( sa == NULL || (sa->ss_family != AF_INET && sa->ss_family != AF_INET6) ) - return 1;//Andu: TODO our error code or what? + return -1; if ( (sa->ss_family == AF_INET && na != sizeof(sockaddr_in)) #if HAVE_IPV6 || (sa->ss_family == AF_INET6 && na != sizeof(sockaddr_in6)) #endif ) - return 1;//Andu: TODO our error code or what? + return -1; #ifdef WIN32 return ::connect((SOCKET)socketHandle,(const sockaddr *)sa, na); -#endif -#ifdef NOT_WIN +#else return ::connect((int)socketHandle,(const sockaddr *)sa,na); #endif } @@ -657,9 +642,7 @@ return -1; else return err; - -#endif -#ifdef NOT_WIN +#else err = ::recv((int)socketHandle, buffer, len, flags); if ( err < 0 && errno == EAGAIN && isNonBlocking) @@ -727,7 +710,7 @@ /*! *Returns the hostname. */ -int Socket::gethostname(char *name,int namelen) +int Socket::gethostname(char *name, int namelen) { return ::gethostname(name,namelen); } @@ -735,16 +718,14 @@ /*! *Returns the sockname. */ -int Socket::getsockname(MYSERVER_SOCKADDR *ad,int *namelen) +int Socket::getsockname(MYSERVER_SOCKADDR *ad, int *namelen) { #ifdef WIN32 - return ::getsockname(socketHandle,(sockaddr *)ad,namelen); -#endif -#ifdef NOT_WIN + return ::getsockname(socketHandle,(sockaddr *)ad,namelen); +#else socklen_t len =(socklen_t) *namelen; int ret = ::getsockname((int)socketHandle, (struct sockaddr *)ad, &len); *namelen = (int)len; - return ret; #endif } Modified: trunk/myserver/src/base/socket/ssl_socket.cpp =================================================================== --- trunk/myserver/src/base/socket/ssl_socket.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/socket/ssl_socket.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 2006, 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 @@ -78,9 +78,7 @@ #ifdef WIN32 return ::shutdown(socketHandle, how); -#endif - -#ifdef NOT_WIN +#else return ::shutdown((int)socketHandle, how); #endif } Modified: trunk/myserver/src/base/socket_pair/socket_pair.cpp =================================================================== --- trunk/myserver/src/base/socket_pair/socket_pair.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/socket_pair/socket_pair.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -20,7 +20,7 @@ #include #include -#ifdef NOT_WIN +#ifndef WIN32 extern "C" { #include #include Modified: trunk/myserver/src/base/string/stringutils.cpp =================================================================== --- trunk/myserver/src/base/string/stringutils.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/string/stringutils.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -24,7 +24,7 @@ #include #include #include -#ifdef NOT_WIN +#ifndef WIN32 #include #endif } @@ -478,7 +478,7 @@ out[19] = asct[18]; out[20] = ' '; -#ifdef NOT_WIN +#ifndef WIN32 extern long timezone; offset = -timezone; #else @@ -896,7 +896,7 @@ return strcmp(a.c_str(), b); } -#ifdef NOT_WIN +#ifndef WIN32 char* strupr(char * s) { unsigned int len = strlen(s); Modified: trunk/myserver/src/base/thread/thread.cpp =================================================================== --- trunk/myserver/src/base/thread/thread.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/thread/thread.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 2006, 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 @@ -50,8 +50,7 @@ { #ifdef WIN32 Sleep(time/1000); -#endif -#ifdef NOT_WIN +#else usleep(time); #endif Modified: trunk/myserver/src/base/utility.cpp =================================================================== --- trunk/myserver/src/base/utility.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/base/utility.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. +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 @@ -170,7 +170,7 @@ return currentPath ? 0 : 1; #endif -#ifdef NOT_WIN +#ifndef WIN32 int size = 16; char *ret = 0; currentPath = new char[size]; @@ -204,8 +204,10 @@ int getdefaultwd(string& out) { char *wd = getdefaultwd(0, 0); + if(wd == 0) return -1; + out.assign(wd); return 0; } @@ -256,7 +258,7 @@ #ifdef WIN32 return _chdir(dir); #endif -#ifdef NOT_WIN +#ifndef WIN32 return chdir(dir); #endif } @@ -274,7 +276,7 @@ if(ret) return 0; #endif -#ifdef NOT_WIN +#ifndef WIN32 cout << "\033[31;1m"; return 0; #endif @@ -294,8 +296,7 @@ FOREGROUND_BLUE); if(ret) return 0; -#endif -#ifdef NOT_WIN +#else cout << "\033[0m"; return 0; #endif Modified: trunk/myserver/src/connections_scheduler/listen_threads.cpp =================================================================== --- trunk/myserver/src/connections_scheduler/listen_threads.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/connections_scheduler/listen_threads.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 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 @@ -26,7 +26,7 @@ //#include #include #endif -#ifdef NOT_WIN +#ifndef WIN32 #include #include #include @@ -110,7 +110,7 @@ ((sockaddr_in*)(&sockServerSocketIPv4))->sin_port = htons((u_short)port); -#ifdef NOT_WIN +#ifndef WIN32 /* *Under the unix environment the application needs some time before * create a new socket for the same address. @@ -167,7 +167,7 @@ ((sockaddr_in6*)(&sockServerSocketIPv6))->sin6_addr = in6addr_any; ((sockaddr_in6*)(&sockServerSocketIPv6))->sin6_port = htons((u_short)port); -#ifdef NOT_WIN +#ifndef WIN32 /* *Under the unix environment the application needs some time before * create a new socket for the same address. Modified: trunk/myserver/src/filter/console.cpp =================================================================== --- trunk/myserver/src/filter/console.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/filter/console.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -41,7 +41,7 @@ bg_colors["white"] = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE; bg_colors["reset"] = 0; #endif -#ifdef NOT_WIN +#ifndef WIN32 fg_colors["black"] = "\033[30m"; fg_colors["red"] = "\033[31m"; fg_colors["green"] = "\033[32m"; @@ -154,8 +154,7 @@ } h = GetStdHandle (nStdHandle); SetConsoleTextAttribute (attrs, h); -#endif -#ifdef NOT_WIN +#else if (fg_colors.count (fg_color) && bg_colors.count (bg_color)) { *fd << fg_colors[fg_color].c_str () << bg_colors[bg_color].c_str (); Modified: trunk/myserver/src/filter/gzip/gzip.cpp =================================================================== --- trunk/myserver/src/filter/gzip/gzip.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/filter/gzip/gzip.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. +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 @@ -24,7 +24,7 @@ #include #include #endif -#ifdef NOT_WIN +#ifndef WIN32 #include #include #endif Modified: trunk/myserver/src/filter/gzip/gzip_decompress.cpp =================================================================== --- trunk/myserver/src/filter/gzip/gzip_decompress.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/filter/gzip/gzip_decompress.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. +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 @@ -23,7 +23,7 @@ #include #include #endif -#ifdef NOT_WIN +#ifndef WIN32 #include #include #endif Modified: trunk/myserver/src/http_handler/http_dir/http_dir.cpp =================================================================== --- trunk/myserver/src/http_handler/http_dir/http_dir.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/http_handler/http_dir/http_dir.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -30,7 +30,7 @@ #include #endif -#ifdef NOT_WIN +#ifndef WIN32 #include #include #endif @@ -38,7 +38,7 @@ #include #include -#ifdef NOT_WIN +#ifndef WIN32 #endif #include Modified: trunk/myserver/src/http_handler/http_file/http_file.cpp =================================================================== --- trunk/myserver/src/http_handler/http_file/http_file.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/http_handler/http_file/http_file.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -32,9 +32,7 @@ #ifdef WIN32 #include #include -#endif - -#ifdef NOT_WIN +#else #include #include #endif Modified: trunk/myserver/src/http_handler/isapi/isapi.cpp =================================================================== --- trunk/myserver/src/http_handler/isapi/isapi.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/http_handler/isapi/isapi.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. +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 @@ -744,10 +744,6 @@ /*! *ISAPI works only on the windows architecture. */ -#ifdef NOT_WIN - return td->http->raiseHTTPError(501); -#endif - #ifdef WIN32 DWORD Ret; EXTENSION_CONTROL_BLOCK ExtCtrlBlk; Modified: trunk/myserver/src/myserver.cpp =================================================================== --- trunk/myserver/src/myserver.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/myserver.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -30,7 +30,7 @@ #include #endif -#ifdef NOT_WIN +#ifndef WIN32 #include #include #include @@ -58,7 +58,7 @@ char **argv; void registerSignals(); -#ifdef NOT_WIN +#ifndef WIN32 void Sig_Quit(int signal) { Server::getInstance()->logWriteln("Exiting..."); @@ -88,7 +88,7 @@ void registerSignals() { -#ifdef NOT_WIN +#ifndef WIN32 struct sigaction sig1, sig2, sig3; struct sigaction sa; @@ -433,7 +433,7 @@ #ifdef ARGP struct argp_input input; #endif -#ifdef NOT_WIN +#ifndef WIN32 pid_t pid; pid_t sid; #endif Modified: trunk/myserver/src/plugin/plugins_manager.cpp =================================================================== --- trunk/myserver/src/plugin/plugins_manager.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/plugin/plugins_manager.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -200,8 +200,7 @@ libname.append(pinfo->getName()); #ifdef WIN32 libname.append(".dll"); -#endif -#ifdef NOT_WIN +#else libname.append(".so"); #endif if(pinfo->isEnabled()) Modified: trunk/myserver/src/protocol/control/control_header.cpp =================================================================== --- trunk/myserver/src/protocol/control/control_header.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/protocol/control/control_header.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -26,7 +26,7 @@ #include #include #endif -#ifdef NOT_WIN +#ifndef WIN32 #include #include #endif Modified: trunk/myserver/src/protocol/control/control_protocol.cpp =================================================================== --- trunk/myserver/src/protocol/control/control_protocol.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/protocol/control/control_protocol.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -33,7 +33,7 @@ #include #include #endif -#ifdef NOT_WIN +#ifndef WIN32 #include #include #endif Modified: trunk/myserver/src/protocol/ftp/ftp.cpp =================================================================== --- trunk/myserver/src/protocol/ftp/ftp.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/protocol/ftp/ftp.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1799,7 +1799,7 @@ char nlinkStr[12]; memset(nlinkStr, 0, sizeof(char)*12); -#ifdef NOT_WIN +#ifndef WIN32 nlink_t nlink = 1; nlink = fd.getStatStruct()->st_nlink; sprintf(nlinkStr, "%lu", (u_long) nlink); @@ -1896,7 +1896,7 @@ char nlinkStr[12]; memset(nlinkStr, 0, sizeof(char)*12); -#ifdef NOT_WIN +#ifndef WIN32 nlink_t nlink = 1; nlink = fd.getStatStruct()->st_nlink; sprintf(nlinkStr, "%lu", (u_long) nlink); Modified: trunk/myserver/src/protocol/http/http.cpp =================================================================== --- trunk/myserver/src/protocol/http/http.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/protocol/http/http.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -54,7 +54,7 @@ #include #endif -#ifdef NOT_WIN +#ifndef WIN32 #include #include #endif Modified: trunk/myserver/src/protocol/http/http_data_read.cpp =================================================================== --- trunk/myserver/src/protocol/http/http_data_read.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/protocol/http/http_data_read.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -37,9 +37,7 @@ #ifdef WIN32 #include #include -#endif - -#ifdef NOT_WIN +#else #include #include #endif Modified: trunk/myserver/src/protocol/http/http_headers.cpp =================================================================== --- trunk/myserver/src/protocol/http/http_headers.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/protocol/http/http_headers.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -31,8 +31,7 @@ #ifdef WIN32 #include #include -#endif -#ifdef NOT_WIN +#else #include #include #endif Modified: trunk/myserver/src/protocol/http/http_thread_context.cpp =================================================================== --- trunk/myserver/src/protocol/http/http_thread_context.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/protocol/http/http_thread_context.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. +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 @@ -24,8 +24,7 @@ #ifdef WIN32 #include #include -#endif -#ifdef NOT_WIN +#else #include #include #endif Modified: trunk/myserver/src/protocol/https/https.cpp =================================================================== --- trunk/myserver/src/protocol/https/https.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/protocol/https/https.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. +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 @@ -24,7 +24,7 @@ #include #include #endif -#ifdef NOT_WIN +#ifndef WIN32 #include #include #endif Modified: trunk/myserver/src/server/clients_thread.cpp =================================================================== --- trunk/myserver/src/server/clients_thread.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/server/clients_thread.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 2006, 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 @@ -29,7 +29,7 @@ #include #include -#ifdef NOT_WIN +#ifndef WIN32 extern "C" { #include #include @@ -128,7 +128,7 @@ #endif { -#ifdef NOT_WIN +#ifndef WIN32 /* Block SigTerm, SigInt, and SigPipe in threads. */ sigset_t sigmask; sigemptyset(&sigmask); Modified: trunk/myserver/src/server/server.cpp =================================================================== --- trunk/myserver/src/server/server.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/src/server/server.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -37,8 +37,7 @@ { #ifdef WIN32 #include -#endif -#ifdef NOT_WIN +#else #include #include #include @@ -683,9 +682,7 @@ */ _flushall(); system("cls"); -#endif -#ifdef NOT_WIN - +#else /* *Under an UNIX environment, clearing the screen *can be done in a similar method Modified: trunk/myserver/stdafx.h =================================================================== --- trunk/myserver/stdafx.h 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/stdafx.h 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 2005, 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 2 of the License, or @@ -31,10 +31,7 @@ #include #endif -/* If we are not windows, assume *nix */ -#ifndef WIN32 -#define NOT_WIN -#endif + extern "C" { #include #include @@ -43,7 +40,8 @@ #include #include #include -#ifdef NOT_WIN + +#ifndef WIN32 #include #endif } @@ -58,7 +56,6 @@ } #endif - #ifndef MAX_PATH #ifdef PATH_MAX #define MAX_PATH PATH_MAX Modified: trunk/myserver/tests/test_file_stream.cpp =================================================================== --- trunk/myserver/tests/test_file_stream.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/tests/test_file_stream.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer - Copyright (C) 2008 Free Software Foundation, Inc. + 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 @@ -57,8 +57,7 @@ #ifdef WIN32 message.assign ("thisisaverylongmessage\r\n"); message2.assign ("thisisanothermessage\r\n"); -#endif -#ifdef NOT_WIN +#else message.assign ("thisisaverylongmessage\n"); message2.assign ("thisisanothermessage\n"); #endif Modified: trunk/myserver/tests/test_homedir.cpp =================================================================== --- trunk/myserver/tests/test_homedir.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/tests/test_homedir.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer - Copyright (C) 2008 Free Software Foundation, Inc. + 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 @@ -52,8 +52,7 @@ #ifdef WIN32 /* Try to get home dir for Administrator under Windows. */ username.assign("Administrator"); -#endif -#ifdef NOT_WIN +#else /* Under systems different than Windows, "root" should be present, * if it doesn't handle this differently. */ username.assign("root"); Modified: trunk/myserver/tests/test_log_manager.cpp =================================================================== --- trunk/myserver/tests/test_log_manager.cpp 2009-04-02 08:31:32 UTC (rev 3045) +++ trunk/myserver/tests/test_log_manager.cpp 2009-04-02 09:21:41 UTC (rev 3046) @@ -1,6 +1,6 @@ /* MyServer - Copyright (C) 2008 Free Software Foundation, Inc. + 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 @@ -18,7 +18,7 @@ #include #include -#ifdef NOT_WIN +#ifndef WIN32 #include #include #endif @@ -600,7 +600,7 @@ void testChown () { -#ifdef NOT_WIN +#ifndef WIN32 list filters; lm->add (this, "test", "file://foo", filters, 0); From MAILER-DAEMON Fri Apr 03 04:26:30 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LpejO-0001h9-CH for mharc-myserver-commit@gnu.org; Fri, 03 Apr 2009 04:26:30 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LpejM-0001gw-WC for myserver-commit@gnu.org; Fri, 03 Apr 2009 04:26:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LpejL-0001gO-U3 for myserver-commit@gnu.org; Fri, 03 Apr 2009 04:26:28 -0400 Received: from [199.232.76.173] (port=59352 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LpejL-0001gF-Ov for myserver-commit@gnu.org; Fri, 03 Apr 2009 04:26:27 -0400 Received: from savannah.gnu.org ([199.232.41.3]:36344 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LpejL-0007nc-BR for myserver-commit@gnu.org; Fri, 03 Apr 2009 04:26:27 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LpejJ-0004Kk-Q4 for myserver-commit@gnu.org; Fri, 03 Apr 2009 08:26:25 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LpejJ-0004Ka-5V for myserver-commit@gnu.org; Fri, 03 Apr 2009 08:26:25 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Fri, 03 Apr 2009 08:26:25 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3047] Code refactoring: the `base64Utils' global instance was removed and some methods were renamed. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2009 08:26:29 -0000 Revision: 3047 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3047 Author: gscrivano Date: 2009-04-03 08:26:24 +0000 (Fri, 03 Apr 2009) Log Message: ----------- Code refactoring: the `base64Utils' global instance was removed and some methods were renamed. Modified Paths: -------------- trunk/myserver/include/base/base64/mime_utils.h trunk/myserver/src/base/base64/mime_utils.cpp trunk/myserver/src/protocol/http/http_headers.cpp trunk/myserver/tests/test_base64.cpp Modified: trunk/myserver/include/base/base64/mime_utils.h =================================================================== --- trunk/myserver/include/base/base64/mime_utils.h 2009-04-02 09:21:41 UTC (rev 3046) +++ trunk/myserver/include/base/base64/mime_utils.h 2009-04-03 08:26:24 UTC (rev 3047) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 2007, 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 @@ -20,8 +20,6 @@ #ifndef MIMEUTILS_H #define MIMEUTILS_H -char* MimeDecodeMailHeaderField(char *s); - class CBase64Utils { private: @@ -30,23 +28,22 @@ int GetLastError() {return ErrorCode;}; CBase64Utils(); ~CBase64Utils(); - char* Decode(const char *in, int *bufsize); - char* Encode(const char *in, int bufsize); + char* decode(const char *in, int *bufsize); + char* encode(const char *in, int bufsize); + char* mimeDecodeMailHeaderField(char *s); }; class CQPUtils { private: - char* ExpandBuffer(char *buffer, int UsedSize, int *BufSize, int SingleChar = 1); + char* expandBuffer(char *buffer, int UsedSize, int *BufSize, int SingleChar = 1); int ErrorCode; public: - int GetLastError() {return ErrorCode;}; - char* Encode(char*in); - char* Decode(char*in); + int getLastError() {return ErrorCode;}; + char* encode(char*in); + char* decode(char*in); CQPUtils(); ~CQPUtils(); }; -extern class CBase64Utils base64Utils; #endif - Modified: trunk/myserver/src/base/base64/mime_utils.cpp =================================================================== --- trunk/myserver/src/base/base64/mime_utils.cpp 2009-04-02 09:21:41 UTC (rev 3046) +++ trunk/myserver/src/base/base64/mime_utils.cpp 2009-04-03 08:26:24 UTC (rev 3047) @@ -59,10 +59,6 @@ delete [] cs; return result; } -/*! - *Unique instance of this class - */ -CBase64Utils base64Utils; const char base64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; #define SKIP '\202' @@ -182,7 +178,7 @@ -char* MimeDecodeMailHeaderField(char *s) +char* CBase64Utils::mimeDecodeMailHeaderField(char *s) { if (s == NULL) return s; @@ -234,7 +230,7 @@ s1 += pos; if (strlen(s1) < 4) return s; s1 += 3; - decodedText = qp.Decode(s1); + decodedText = qp.decode(s1); } if (strupos(s1, (char*) "?B?") > 0) { @@ -245,7 +241,7 @@ if (strlen(s1) < 4) return s; s1 += 3; sLen = static_cast(strlen(s1)); - decodedText = bu.Decode(s1, &sLen); + decodedText = bu.decode(s1, &sLen); } alloclen =static_cast(strlen(decodedText)) + 1; if (start != NULL) alloclen +=static_cast(strlen(start)); @@ -280,7 +276,7 @@ /*! *Decode a string using the Base64 codification */ -char* CBase64Utils::Encode(const char *input, int bufsize) +char* CBase64Utils::encode(const char *input, int bufsize) { int alsize = ((bufsize * 4) / 3); char *finalresult = (char*)calloc(alsize + ((alsize / 76) * 2) + @@ -391,7 +387,7 @@ /*! *Decode a Base64 coded string. */ -char* CBase64Utils::Decode(const char *input, int *bufsize) +char* CBase64Utils::decode(const char *input, int *bufsize) { int std = 0, count = 1, resultlen = 0; char *finalresult = (char*)calloc(*bufsize + sizeof(char), sizeof(char)); @@ -470,7 +466,7 @@ { } -char* CQPUtils::Decode(char *input) +char* CQPUtils::decode(char *input) { char *s = input; char *finalresult = (char*)calloc(strlen(input) + sizeof(char), @@ -532,7 +528,7 @@ -char* CQPUtils::ExpandBuffer(char *buffer, int UsedSize, int *BufSize, +char* CQPUtils::expandBuffer(char *buffer, int UsedSize, int *BufSize, int Singlechar) { int AddVal; @@ -547,7 +543,7 @@ } -char* CQPUtils::Encode(char *input) +char* CQPUtils::encode(char *input) { int BufSize = static_cast(strlen(input) + BufAdd); int UsedSize = 0; @@ -565,14 +561,14 @@ char mids[3]; if (LineLen >= MaxLineLength - 4) { - finalresult = ExpandBuffer(finalresult, UsedSize, &BufSize, 0); + finalresult = expandBuffer(finalresult, UsedSize, &BufSize, 0); *(fresult++) = '='; *(fresult++) = '\r'; *(fresult++) = '\n'; UsedSize += 3; LineLen = 0; } - finalresult = ExpandBuffer(finalresult, UsedSize, &BufSize, 0); + finalresult = expandBuffer(finalresult, UsedSize, &BufSize, 0); #ifdef WIN32 itoa(mid, mids, 16); #else @@ -590,14 +586,14 @@ { if (LineLen >= MaxLineLength - 4) { - finalresult = ExpandBuffer(finalresult, UsedSize, &BufSize, 0); + finalresult = expandBuffer(finalresult, UsedSize, &BufSize, 0); *(fresult++) = '='; *(fresult++) = '\r'; *(fresult++) = '\n'; UsedSize += 3; LineLen = 0; } - finalresult = ExpandBuffer(finalresult, UsedSize, &BufSize); + finalresult = expandBuffer(finalresult, UsedSize, &BufSize); UsedSize++; LineLen++; *(fresult++) = *(s++); Modified: trunk/myserver/src/protocol/http/http_headers.cpp =================================================================== --- trunk/myserver/src/protocol/http/http_headers.cpp 2009-04-02 09:21:41 UTC (rev 3046) +++ trunk/myserver/src/protocol/http/http_headers.cpp 2009-04-03 08:26:24 UTC (rev 3047) @@ -836,8 +836,9 @@ const char* lsecondaryBuffer; const char* lsecondaryBufferOr; char login[32]; - char password[32]; - + char password[32]; + CBase64Utils base64Utils; + if(len == -1) return 400; @@ -851,7 +852,7 @@ if (len <= 1) return 400; - lsecondaryBuffer = base64Utils.Decode(base64,&len); + lsecondaryBuffer = base64Utils.decode(base64, &len); lsecondaryBufferOr = lsecondaryBuffer; for(i = 0; (*lsecondaryBuffer != ':') && (i < 32);i++) Modified: trunk/myserver/tests/test_base64.cpp =================================================================== --- trunk/myserver/tests/test_base64.cpp 2009-04-02 09:21:41 UTC (rev 3046) +++ trunk/myserver/tests/test_base64.cpp 2009-04-03 08:26:24 UTC (rev 3047) @@ -1,6 +1,6 @@ /* MyServer - Copyright (C) 2008 Free Software Foundation, Inc. + 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 @@ -51,17 +51,16 @@ { int len = 0; char* input = (char*) "Hello world!\n"; - char* encoded = base64->Encode(input, 13); + char* encoded = base64->encode(input, 13); len = strlen(encoded); - char* decoded = base64->Decode(encoded, &len); + char* decoded = base64->decode(encoded, &len); CPPUNIT_ASSERT_EQUAL(strlen(input), strlen(decoded)); for (unsigned int i = 0; i < strlen(decoded); i++) CPPUNIT_ASSERT_EQUAL(input[i], decoded[i]); - } }; From MAILER-DAEMON Sat Apr 04 06:13:13 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lq2sD-0003qp-3e for mharc-myserver-commit@gnu.org; Sat, 04 Apr 2009 06:13:13 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lq2sB-0003qk-Ph for myserver-commit@gnu.org; Sat, 04 Apr 2009 06:13:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lq2sB-0003qY-CZ for myserver-commit@gnu.org; Sat, 04 Apr 2009 06:13:11 -0400 Received: from [199.232.76.173] (port=41744 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lq2sB-0003qQ-50 for myserver-commit@gnu.org; Sat, 04 Apr 2009 06:13:11 -0400 Received: from savannah.gnu.org ([199.232.41.3]:46762 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lq2sA-0006SI-Sf for myserver-commit@gnu.org; Sat, 04 Apr 2009 06:13:11 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lq2sA-0006bm-B0 for myserver-commit@gnu.org; Sat, 04 Apr 2009 10:13:10 +0000 Received: from andu by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lq2s9-0006bT-Mg for myserver-commit@gnu.org; Sat, 04 Apr 2009 10:13:10 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: andu To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Alexandru IANCU Message-Id: Date: Sat, 04 Apr 2009 10:13:09 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3048] bug fixes:ftp directory handling and files rights, cleaned code: removed some warnings X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Apr 2009 10:13:11 -0000 Revision: 3048 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3048 Author: andu Date: 2009-04-04 10:13:09 +0000 (Sat, 04 Apr 2009) Log Message: ----------- bug fixes:ftp directory handling and files rights, cleaned code: removed some warnings Modified Paths: -------------- trunk/myserver/src/base/process/process.cpp trunk/myserver/src/conf/security/xml_validator.cpp trunk/myserver/src/plugin/plugin_info.cpp trunk/myserver/src/plugin/plugins_manager.cpp trunk/myserver/src/protocol/control/control_protocol.cpp trunk/myserver/src/protocol/ftp/ftp.cpp trunk/myserver/src/protocol/http/http.cpp trunk/myserver/tests/test_log_manager.cpp trunk/myserver/tests/test_pipe.cpp Modified: trunk/myserver/src/base/process/process.cpp =================================================================== --- trunk/myserver/src/base/process/process.cpp 2009-04-03 08:26:24 UTC (rev 3047) +++ trunk/myserver/src/base/process/process.cpp 2009-04-04 10:13:09 UTC (rev 3048) @@ -153,7 +153,6 @@ */ int Process::exec(StartProcInfo* spi, bool waitEnd) { - int ret = 0; pid = 0; #ifdef WIN32 STARTUPINFO si; Modified: trunk/myserver/src/conf/security/xml_validator.cpp =================================================================== --- trunk/myserver/src/conf/security/xml_validator.cpp 2009-04-03 08:26:24 UTC (rev 3047) +++ trunk/myserver/src/conf/security/xml_validator.cpp 2009-04-04 10:13:09 UTC (rev 3048) @@ -70,7 +70,7 @@ secName = st->getHashedData ("SECURITY_FILE_NAME", MYSERVER_VHOST_CONF | MYSERVER_SERVER_CONF, ".security.xml"); - return cache->getParser (*(st->getResource ()), *(st->getSysDirectory ()), false, secName); + return cache->getParser (*(st->getDirectory ()), *(st->getSysDirectory ()), false, secName); } /*! Modified: trunk/myserver/src/plugin/plugin_info.cpp =================================================================== --- trunk/myserver/src/plugin/plugin_info.cpp 2009-04-03 08:26:24 UTC (rev 3047) +++ trunk/myserver/src/plugin/plugin_info.cpp 2009-04-04 10:13:09 UTC (rev 3048) @@ -119,6 +119,7 @@ int PluginInfo::setMyServerMinVersion(int v) { this->msMinVersion = v; + return this->msMinVersion; } /*! @@ -127,6 +128,7 @@ int PluginInfo::setMyServerMaxVersion(int v) { this->msMaxVersion = v; + return this->msMaxVersion; } /*! @@ -185,6 +187,7 @@ if(this->plugin) delete this->plugin; this->plugin = NULL; + return NULL; } /*! Modified: trunk/myserver/src/plugin/plugins_manager.cpp =================================================================== --- trunk/myserver/src/plugin/plugins_manager.cpp 2009-04-03 08:26:24 UTC (rev 3047) +++ trunk/myserver/src/plugin/plugins_manager.cpp 2009-04-04 10:13:09 UTC (rev 3048) @@ -416,7 +416,6 @@ HashMap* >::Iterator depIt = pinfo->begin(); - bool goodVersions = true; string msversion(MYSERVER_VERSION); int i = msversion.find("-",0); Modified: trunk/myserver/src/protocol/control/control_protocol.cpp =================================================================== --- trunk/myserver/src/protocol/control/control_protocol.cpp 2009-04-03 08:26:24 UTC (rev 3047) +++ trunk/myserver/src/protocol/control/control_protocol.cpp 2009-04-04 10:13:09 UTC (rev 3048) @@ -583,7 +583,6 @@ { string time; ostringstream out; - ThreadID id = Thread::threadID(); /* *Check that the verbosity is at least 1. */ @@ -607,7 +606,6 @@ int bs1, ControlHeader& header) { string time; - ThreadID id = Thread::threadID(); getRFC822GMTTime(time, 32); #ifdef HAVE_SNPRINTF Modified: trunk/myserver/src/protocol/ftp/ftp.cpp =================================================================== --- trunk/myserver/src/protocol/ftp/ftp.cpp 2009-04-03 08:26:24 UTC (rev 3047) +++ trunk/myserver/src/protocol/ftp/ftp.cpp 2009-04-04 10:13:09 UTC (rev 3048) @@ -579,7 +579,7 @@ int asockInLen = 0; Socket asock; if ( pFtpUserData->m_pDataConnection->socket->dataOnRead(timeoutvalue, 0) == 1 ) - { + { asockInLen = sizeof(sockaddr_in); asock = pFtpUserData->m_pDataConnection->socket->accept(&asockIn, &asockInLen); if ( asock.getHandle() == (FileHandle)INVALID_SOCKET ) @@ -1497,7 +1497,7 @@ } /////////////////////////////////////// if ( FilesUtility::isDirectory(sOutPath) && - (sOutPath[sOutPath.length() - 1] != '/' || sOutPath[sOutPath.length() - 1] != '\\') ) + (sOutPath[sOutPath.length() - 1] != '/' && sOutPath[sOutPath.length() - 1] != '\\') ) sOutPath.append("/"); return true; } @@ -2399,8 +2399,11 @@ { if ( sPath.empty() ) return 0; - std::string sDir, sFileName; - FilesUtility::splitPath(sPath, sDir, sFileName); + std::string sDir(""), sFileName(""); + if ( !FilesUtility::isDirectory(sPath.c_str()) ) + FilesUtility::splitPath(sPath, sDir, sFileName); + else + sDir = sPath; SecurityToken st; string user; Modified: trunk/myserver/src/protocol/http/http.cpp =================================================================== --- trunk/myserver/src/protocol/http/http.cpp 2009-04-03 08:26:24 UTC (rev 3047) +++ trunk/myserver/src/protocol/http/http.cpp 2009-04-04 10:13:09 UTC (rev 3048) @@ -798,7 +798,6 @@ */ string filename; const char *cgiManager; - int mimecmd; int ret; string directory; string file; Modified: trunk/myserver/tests/test_log_manager.cpp =================================================================== --- trunk/myserver/tests/test_log_manager.cpp 2009-04-03 08:26:24 UTC (rev 3047) +++ trunk/myserver/tests/test_log_manager.cpp 2009-04-04 10:13:09 UTC (rev 3048) @@ -541,7 +541,6 @@ void testGetLogStreamSharedByTheSameObject () { list filters; - AnObject anObject; list l; LogStream* ls; LogStream* ls1; Modified: trunk/myserver/tests/test_pipe.cpp =================================================================== --- trunk/myserver/tests/test_pipe.cpp 2009-04-03 08:26:24 UTC (rev 3047) +++ trunk/myserver/tests/test_pipe.cpp 2009-04-04 10:13:09 UTC (rev 3048) @@ -91,9 +91,7 @@ void testWaitForData() { char outBuff[256]; - char inBuff[256]; u_long nbw; - u_long nbr; strcpy(outBuff, "MyServer is a powerful and easy to configure web server"); From MAILER-DAEMON Sat Apr 04 07:32:43 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lq479-0000FB-3q for mharc-myserver-commit@gnu.org; Sat, 04 Apr 2009 07:32:43 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lq478-0000DH-3J for myserver-commit@gnu.org; Sat, 04 Apr 2009 07:32:42 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lq476-0000BZ-Jz for myserver-commit@gnu.org; Sat, 04 Apr 2009 07:32:41 -0400 Received: from [199.232.76.173] (port=46645 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lq476-0000BC-Dm for myserver-commit@gnu.org; Sat, 04 Apr 2009 07:32:40 -0400 Received: from savannah.gnu.org ([199.232.41.3]:37431 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lq476-0005Rd-2K for myserver-commit@gnu.org; Sat, 04 Apr 2009 07:32:40 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lq475-0004EW-Jk for myserver-commit@gnu.org; Sat, 04 Apr 2009 11:32:39 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lq475-0004ES-79 for myserver-commit@gnu.org; Sat, 04 Apr 2009 11:32:39 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Sat, 04 Apr 2009 11:32:39 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3049] Added documentation about connections timeout. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Apr 2009 11:32:42 -0000 Revision: 3049 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3049 Author: gscrivano Date: 2009-04-04 11:32:38 +0000 (Sat, 04 Apr 2009) Log Message: ----------- Added documentation about connections timeout. Modified Paths: -------------- trunk/myserver/documentation/basic_configuration.texi Modified: trunk/myserver/documentation/basic_configuration.texi =================================================================== --- trunk/myserver/documentation/basic_configuration.texi 2009-04-04 10:13:09 UTC (rev 3048) +++ trunk/myserver/documentation/basic_configuration.texi 2009-04-04 11:32:38 UTC (rev 3049) @@ -60,3 +60,19 @@ Files saved on the primary memory are not persistent between reboots, introducing another level of security as temporary data will not be saved on the server. + +@section Connections timeout +Protocols like FTP or HTTP/1.1 support keep-alive connections, in +other words the connection is kept alive between requests to avoid a +different connection to the server on every request. +MyServer performances are not affected by the number of active +connections but if they are not controlled, they can reach the maximum +number of allowed connections without give the possibility to new +connections that really want to request a resource to be +estabilished. +Active connections are closed after a fixed amount of time has passed +without any activity. +The amount of time, before an inactive connection is closed, is +configured trought the @code{server.connection_timeout} value defined +in the global configuration file. This value is specified in +seconds. From MAILER-DAEMON Tue Apr 07 12:41:54 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LrEN0-0004ND-B3 for mharc-myserver-commit@gnu.org; Tue, 07 Apr 2009 12:41:54 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LrEMx-0004Ma-TH for myserver-commit@gnu.org; Tue, 07 Apr 2009 12:41:51 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LrEMw-0004MB-1i for myserver-commit@gnu.org; Tue, 07 Apr 2009 12:41:50 -0400 Received: from [199.232.76.173] (port=59189 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LrEMv-0004M8-VA for myserver-commit@gnu.org; Tue, 07 Apr 2009 12:41:49 -0400 Received: from savannah.gnu.org ([199.232.41.3]:41322 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LrEMv-0007Lk-4B for myserver-commit@gnu.org; Tue, 07 Apr 2009 12:41:49 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LrEMu-0002VV-D8 for myserver-commit@gnu.org; Tue, 07 Apr 2009 16:41:48 +0000 Received: from dperrone by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LrEMu-0002VR-2n for myserver-commit@gnu.org; Tue, 07 Apr 2009 16:41:48 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: dperrone To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Daniele Perrone Message-Id: Date: Tue, 07 Apr 2009 16:41:48 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3050] myserver-get: added xml config file and support, and license. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Apr 2009 16:41:52 -0000 Revision: 3050 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3050 Author: dperrone Date: 2009-04-07 16:41:47 +0000 (Tue, 07 Apr 2009) Log Message: ----------- myserver-get: added xml config file and support, and license. Modified Paths: -------------- trunk/misc/myserver-get/myserver-get.py trunk/misc/myserver-get/myserverGetLib/config.py trunk/misc/myserver-get/myserverGetLib/console.py trunk/misc/myserver-get/myserverGetLib/error.py trunk/misc/myserver-get/myserverGetLib/general.py trunk/misc/myserver-get/myserverGetLib/local.py trunk/misc/myserver-get/myserverGetLib/remote.py trunk/misc/myserver-get/myserverGetLib/remoteGenericUrl.py Added Paths: ----------- trunk/misc/myserver-get/myserver-get.xml Modified: trunk/misc/myserver-get/myserver-get.py =================================================================== --- trunk/misc/myserver-get/myserver-get.py 2009-04-04 11:32:38 UTC (rev 3049) +++ trunk/misc/myserver-get/myserver-get.py 2009-04-07 16:41:47 UTC (rev 3050) @@ -1,3 +1,19 @@ +# MyServer +# Copyright (C) 2009 The MyServer Team +# 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 . + + from myserverGetLib.general import MyServerGet import sys import getopt @@ -10,7 +26,7 @@ def main(argv): myserverGet = MyServerGet() command = "" - + myserverGetLib.config.loadConfig() commands = {"":usage, "update":myserverGet.update, "search":myserverGet.search,"install":myserverGet.install,"source":myserverGet.source,"source-auto":myserverGet.sourceAuto,"remove":myserverGet.remove} Added: trunk/misc/myserver-get/myserver-get.xml =================================================================== --- trunk/misc/myserver-get/myserver-get.xml (rev 0) +++ trunk/misc/myserver-get/myserver-get.xml 2009-04-07 16:41:47 UTC (rev 3050) @@ -0,0 +1,20 @@ + + + repositories.xml + + + list + + + myserver-get- + + + -plugin-list.xml + + + ../../myserver/binaries/plugins + + 0.9 + + /home/dany/srcprojects/myserver/myserver + \ No newline at end of file Modified: trunk/misc/myserver-get/myserverGetLib/config.py =================================================================== --- trunk/misc/myserver-get/myserverGetLib/config.py 2009-04-04 11:32:38 UTC (rev 3049) +++ trunk/misc/myserver-get/myserverGetLib/config.py 2009-04-07 16:41:47 UTC (rev 3050) @@ -1,4 +1,20 @@ +# MyServer +# Copyright (C) 2009 The MyServer Team +# 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 . + + CNFG_FILE = "myserver-get.xml" REP_LIST_FILE = "repositories.xml" @@ -19,3 +35,34 @@ arch = "" +def loadConfig(file = CNFG_FILE): + import xml.dom.minidom + xmlCnfg = xml.dom.minidom.parse(file) + + elements = xmlCnfg.getElementsByTagName("REP_LIST_FILE") + if len(elements)==1: + REP_LIST_FILE = elements[0].firstChild.data + + elements = xmlCnfg.getElementsByTagName("PLUGIN_LIST_FILES_DIR") + if len(elements)==1: + PLUGIN_LIST_FILES_DIR = elements[0].firstChild.data + + elements = xmlCnfg.getElementsByTagName("PLUGIN_LIST_PREFIX") + if len(elements)==1: + PLUGIN_LIST_PREFIX = elements[0].firstChild.data + + elements = xmlCnfg.getElementsByTagName("PLUGIN_LIST_SUFFIX") + if len(elements)==1: + PLUGIN_LIST_SUFFIX = elements[0].firstChild.data + + elements = xmlCnfg.getElementsByTagName("MYSERVER_PLUGIN_DIR") + if len(elements)==1: + MYSERVER_PLUGIN_DIR = elements[0].firstChild.data + + elements = xmlCnfg.getElementsByTagName("MYSERVER_VERSION") + if len(elements)==1: + MYSERVER_VERSION = elements[0].firstChild.data + + elements = xmlCnfg.getElementsByTagName("MSHEADERS") + if len(elements)==1: + MSHEADERS = elements[0].firstChild.data \ No newline at end of file Modified: trunk/misc/myserver-get/myserverGetLib/console.py =================================================================== --- trunk/misc/myserver-get/myserverGetLib/console.py 2009-04-04 11:32:38 UTC (rev 3049) +++ trunk/misc/myserver-get/myserverGetLib/console.py 2009-04-07 16:41:47 UTC (rev 3050) @@ -1,3 +1,18 @@ +# MyServer +# Copyright (C) 2009 The MyServer Team +# 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 . + import sys def write(arg): Modified: trunk/misc/myserver-get/myserverGetLib/error.py =================================================================== --- trunk/misc/myserver-get/myserverGetLib/error.py 2009-04-04 11:32:38 UTC (rev 3049) +++ trunk/misc/myserver-get/myserverGetLib/error.py 2009-04-07 16:41:47 UTC (rev 3050) @@ -1,3 +1,17 @@ +# MyServer +# Copyright (C) 2009 The MyServer Team +# 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 . class Error(Exception): Modified: trunk/misc/myserver-get/myserverGetLib/general.py =================================================================== --- trunk/misc/myserver-get/myserverGetLib/general.py 2009-04-04 11:32:38 UTC (rev 3049) +++ trunk/misc/myserver-get/myserverGetLib/general.py 2009-04-07 16:41:47 UTC (rev 3050) @@ -1,3 +1,18 @@ +# MyServer +# Copyright (C) 2009 The MyServer Team +# 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 . + import xml.dom.minidom import local import config @@ -2,3 +17,2 @@ import remote -import remoteSvn import remoteGenericUrl Modified: trunk/misc/myserver-get/myserverGetLib/local.py =================================================================== --- trunk/misc/myserver-get/myserverGetLib/local.py 2009-04-04 11:32:38 UTC (rev 3049) +++ trunk/misc/myserver-get/myserverGetLib/local.py 2009-04-07 16:41:47 UTC (rev 3050) @@ -1,3 +1,18 @@ +# MyServer +# Copyright (C) 2009 The MyServer Team +# 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 . + import xml.dom.minidom import error import config Modified: trunk/misc/myserver-get/myserverGetLib/remote.py =================================================================== --- trunk/misc/myserver-get/myserverGetLib/remote.py 2009-04-04 11:32:38 UTC (rev 3049) +++ trunk/misc/myserver-get/myserverGetLib/remote.py 2009-04-07 16:41:47 UTC (rev 3050) @@ -1,3 +1,18 @@ +# MyServer +# Copyright (C) 2009 The MyServer Team +# 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 . + import string class Repository: Modified: trunk/misc/myserver-get/myserverGetLib/remoteGenericUrl.py =================================================================== --- trunk/misc/myserver-get/myserverGetLib/remoteGenericUrl.py 2009-04-04 11:32:38 UTC (rev 3049) +++ trunk/misc/myserver-get/myserverGetLib/remoteGenericUrl.py 2009-04-07 16:41:47 UTC (rev 3050) @@ -1,3 +1,18 @@ +# MyServer +# Copyright (C) 2009 The MyServer Team +# 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 . + import local import error import xml.dom.minidom From MAILER-DAEMON Sun Apr 12 16:43:04 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lt6W8-0008KD-DX for mharc-myserver-commit@gnu.org; Sun, 12 Apr 2009 16:43:04 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lt6W6-0008Hy-Ml for myserver-commit@gnu.org; Sun, 12 Apr 2009 16:43:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lt6W6-0008HF-5u for myserver-commit@gnu.org; Sun, 12 Apr 2009 16:43:02 -0400 Received: from [199.232.76.173] (port=52592 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lt6W6-0008H4-0h for myserver-commit@gnu.org; Sun, 12 Apr 2009 16:43:02 -0400 Received: from savannah.gnu.org ([199.232.41.3]:55311 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lt6W5-0004zh-OH for myserver-commit@gnu.org; Sun, 12 Apr 2009 16:43:01 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lt6W5-0003P2-8G for myserver-commit@gnu.org; Sun, 12 Apr 2009 20:43:01 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lt6W4-0003Oy-Vk for myserver-commit@gnu.org; Sun, 12 Apr 2009 20:43:01 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Sun, 12 Apr 2009 20:43:01 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3051] Copy the right default configuration files when they are missing. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Apr 2009 20:43:03 -0000 Revision: 3051 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3051 Author: gscrivano Date: 2009-04-12 20:43:00 +0000 (Sun, 12 Apr 2009) Log Message: ----------- Copy the right default configuration files when they are missing. Modified Paths: -------------- trunk/myserver/src/server/server.cpp Modified: trunk/myserver/src/server/server.cpp =================================================================== --- trunk/myserver/src/server/server.cpp 2009-04-07 16:41:47 UTC (rev 3050) +++ trunk/myserver/src/server/server.cpp 2009-04-12 20:43:00 UTC (rev 3051) @@ -194,23 +194,29 @@ File inputF; File outputF; int ret; - string sSource(fileName); + string sSource (fileName); + sSource = sSource.substr (0, sSource.length () - 3); - sSource.append(".default"); - ret = inputF.openFile(sSource, File::MYSERVER_OPEN_READ - | File::MYSERVER_OPEN_IFEXISTS); +#ifdef WIN32 + sSource.append ("default.windows.xml"); +#else + sSource.append ("default.xml"); +#endif + + ret = inputF.openFile (sSource, File::MYSERVER_OPEN_READ + | File::MYSERVER_OPEN_IFEXISTS); if (ret) return -1; - ret = outputF.openFile(fileName, File::MYSERVER_OPEN_WRITE - | File::MYSERVER_OPEN_ALWAYS); + ret = outputF.openFile (fileName, File::MYSERVER_OPEN_WRITE + | File::MYSERVER_OPEN_ALWAYS); if (ret) return -1; - FilesUtility::copyFile(inputF, outputF); + FilesUtility::copyFile (inputF, outputF); - inputF.close(); - outputF.close(); + inputF.close (); + outputF.close (); return 0; } From MAILER-DAEMON Mon Apr 13 10:34:51 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LtNFK-0004Up-TR for mharc-myserver-commit@gnu.org; Mon, 13 Apr 2009 10:34:50 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LtNFH-0004Rn-T7 for myserver-commit@gnu.org; Mon, 13 Apr 2009 10:34:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LtNFG-0004PP-Ac for myserver-commit@gnu.org; Mon, 13 Apr 2009 10:34:47 -0400 Received: from [199.232.76.173] (port=53455 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LtNFG-0004P6-0u for myserver-commit@gnu.org; Mon, 13 Apr 2009 10:34:46 -0400 Received: from savannah.gnu.org ([199.232.41.3]:40908 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LtNFF-00085P-KY for myserver-commit@gnu.org; Mon, 13 Apr 2009 10:34:45 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LtNFF-0001JS-4w for myserver-commit@gnu.org; Mon, 13 Apr 2009 14:34:45 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LtNFE-0001JO-Rh for myserver-commit@gnu.org; Mon, 13 Apr 2009 14:34:45 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Mon, 13 Apr 2009 14:34:44 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3052] Fixed Windows compiling issues. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Apr 2009 14:34:49 -0000 Revision: 3052 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3052 Author: gscrivano Date: 2009-04-13 14:34:44 +0000 (Mon, 13 Apr 2009) Log Message: ----------- Fixed Windows compiling issues. Modified Paths: -------------- trunk/myserver/include/base/socket/socket.h trunk/myserver/include/base/socket_pair/socket_pair.h trunk/myserver/src/base/process/process.cpp trunk/myserver/src/base/process/process_server_manager.cpp trunk/myserver/src/base/socket_pair/socket_pair.cpp trunk/myserver/src/connections_scheduler/connections_scheduler.cpp trunk/myserver/src/filter/console.cpp trunk/myserver/src/http_handler/isapi/isapi.cpp trunk/myserver/src/http_handler/wincgi/wincgi.cpp Modified: trunk/myserver/include/base/socket/socket.h =================================================================== --- trunk/myserver/include/base/socket/socket.h 2009-04-12 20:43:00 UTC (rev 3051) +++ trunk/myserver/include/base/socket/socket.h 2009-04-13 14:34:44 UTC (rev 3052) @@ -82,6 +82,7 @@ Socket(); Socket(Socket*); Socket(FileHandle); + Socket accept(MYSERVER_SOCKADDR*, int*); int setsockopt(int,int, const char*,int); Modified: trunk/myserver/include/base/socket_pair/socket_pair.h =================================================================== --- trunk/myserver/include/base/socket_pair/socket_pair.h 2009-04-12 20:43:00 UTC (rev 3051) +++ trunk/myserver/include/base/socket_pair/socket_pair.h 2009-04-13 14:34:44 UTC (rev 3052) @@ -32,8 +32,13 @@ public: SocketPair (); int create (); +#ifdef WIN32 + SOCKET getFirstHandle (); + SOCKET getSecondHandle (); +#else FileHandle getFirstHandle (); FileHandle getSecondHandle (); +#endif void inverted (SocketPair&); virtual int close (); void closeFirstHandle (); @@ -44,6 +49,10 @@ int writeHandle (FileHandle); protected: +#ifdef WIN32 + SOCKET handles[2]; +#else FileHandle handles[2]; +#endif }; #endif Modified: trunk/myserver/src/base/process/process.cpp =================================================================== --- trunk/myserver/src/base/process/process.cpp 2009-04-12 20:43:00 UTC (rev 3051) +++ trunk/myserver/src/base/process/process.cpp 2009-04-13 14:34:44 UTC (rev 3052) @@ -171,8 +171,8 @@ cwd = spi->cwd.length() ? (char*)spi->cwd.c_str() : 0; ZeroMemory( &pi, sizeof(pi) ); - ret = CreateProcess(NULL, (char*)spi->cmdLine.c_str(), NULL, NULL, TRUE,0, - spi->envString, cwd, &si, &pi); + BOOL ret = CreateProcess(NULL, (char*)spi->cmdLine.c_str(), NULL, NULL, TRUE,0, + spi->envString, cwd, &si, &pi); if (!ret) return (-1); Modified: trunk/myserver/src/base/process/process_server_manager.cpp =================================================================== --- trunk/myserver/src/base/process/process_server_manager.cpp 2009-04-12 20:43:00 UTC (rev 3051) +++ trunk/myserver/src/base/process/process_server_manager.cpp 2009-04-13 14:34:44 UTC (rev 3052) @@ -515,7 +515,7 @@ socklen_t nLength = sizeof(MYSERVER_SOCKADDRIN); if (server->socket.getHandle()) - getsockname(server->socket.getHandle(), (sockaddr *)&serverSock, &nLength); + server->socket.getsockname ((MYSERVER_SOCKADDR*)&serverSock, (int*)&nLength); if(!serverSock.ss_family || serverSock.ss_family == AF_INET || !server->isLocal) { Modified: trunk/myserver/src/base/socket_pair/socket_pair.cpp =================================================================== --- trunk/myserver/src/base/socket_pair/socket_pair.cpp 2009-04-12 20:43:00 UTC (rev 3051) +++ trunk/myserver/src/base/socket_pair/socket_pair.cpp 2009-04-13 14:34:44 UTC (rev 3052) @@ -98,40 +98,40 @@ addr.sin_addr.s_addr = htonl (0x7f000001); addr.sin_port = 0; - e = bind(listener, (const struct sockaddr*) &addr, sizeof(addr)); + e = ::bind(listener, (const struct sockaddr*) &addr, sizeof(addr)); if (e == SOCKET_ERROR) { - close(listener); + closesocket (listener); return -1; } - e = getsockname(listener, (struct sockaddr*) &addr, &addrlen); + e = ::getsockname(listener, (struct sockaddr*) &addr, &addrlen); if (e == SOCKET_ERROR) { - close (listener); + closesocket (listener); return -1; } do { - if (listen (listener, 1) == SOCKET_ERROR) + if (::listen (listener, 1) == SOCKET_ERROR) break; - if ((handles[0] = socket (AF_INET, type, 0)) == INVALID_SOCKET) + if ((handles[0] = ::socket (AF_INET, type, 0)) == INVALID_SOCKET) break; - if (connect(handles[0], (const struct sockaddr*) &addr, sizeof (addr)) == SOCKET_ERROR) + if (::connect(handles[0], (const struct sockaddr*) &addr, sizeof (addr)) == SOCKET_ERROR) break; - if ((handles[1] = accept (listener, NULL, NULL)) == INVALID_SOCKET) + if ((handles[1] = ::accept (listener, NULL, NULL)) == INVALID_SOCKET) break; socketHandle = handles[0]; - close (listener); + closesocket (listener); return 0; } while (0); - close (listener); - close (handles[0]); - close (handles[1]); + closesocket (listener); + closesocket (handles[0]); + closesocket (handles[1]); return -1; #endif @@ -142,7 +142,11 @@ /*! *Get the first handle used by the socket pair. */ +#ifdef WIN32 +SOCKET SocketPair::getFirstHandle () +#else FileHandle SocketPair::getFirstHandle () +#endif { return handles[0]; } @@ -150,7 +154,11 @@ /*! *Get the second handle used by the socket pair. */ +#ifdef WIN32 +SOCKET SocketPair::getSecondHandle () +#else FileHandle SocketPair::getSecondHandle () +#endif { return handles[1]; } @@ -186,7 +194,7 @@ */ void SocketPair::closeFirstHandle () { - Socket sock (handles[0]); + Socket sock ((FileHandle)handles[0]); sock.close (); } @@ -195,7 +203,7 @@ */ void SocketPair::closeSecondHandle () { - Socket sock (handles[1]); + Socket sock ((FileHandle)handles[1]); sock.close (); } @@ -205,10 +213,10 @@ */ void SocketPair::setNonBlocking (bool notBlocking) { - Socket sock0 (handles[0]); + Socket sock0 ((FileHandle)handles[0]); sock0.setNonBlocking (notBlocking); - Socket sock1 (handles[1]); + Socket sock1 ((FileHandle)handles[1]); sock1.setNonBlocking (notBlocking); } Modified: trunk/myserver/src/connections_scheduler/connections_scheduler.cpp =================================================================== --- trunk/myserver/src/connections_scheduler/connections_scheduler.cpp 2009-04-12 20:43:00 UTC (rev 3051) +++ trunk/myserver/src/connections_scheduler/connections_scheduler.cpp 2009-04-13 14:34:44 UTC (rev 3052) @@ -408,7 +408,7 @@ if(lock) { u_long nbw; - Socket sock (dispatcherArg.socketPair.getSecondHandle ()); + Socket sock ((FileHandle)dispatcherArg.socketPair.getSecondHandle ()); eventsSocketMutex.lock(); sock.write("c", 1, &nbw); @@ -482,8 +482,8 @@ readySemaphore->unlock(); } - Socket sockR (dispatcherArg.socketPair.getFirstHandle ()); - Socket sockW (dispatcherArg.socketPair.getSecondHandle ()); + Socket sockR ((FileHandle)dispatcherArg.socketPair.getFirstHandle ()); + Socket sockW ((FileHandle)dispatcherArg.socketPair.getSecondHandle ()); eventsSocketMutex.lock(); sockW.write("r", 1, &nbw); Modified: trunk/myserver/src/filter/console.cpp =================================================================== --- trunk/myserver/src/filter/console.cpp 2009-04-12 20:43:00 UTC (rev 3051) +++ trunk/myserver/src/filter/console.cpp 2009-04-13 14:34:44 UTC (rev 3052) @@ -153,7 +153,7 @@ nStdHandle = STD_ERROR_HANDLE; } h = GetStdHandle (nStdHandle); - SetConsoleTextAttribute (attrs, h); + SetConsoleTextAttribute (h, attrs); #else if (fg_colors.count (fg_color) && bg_colors.count (bg_color)) { Modified: trunk/myserver/src/http_handler/isapi/isapi.cpp =================================================================== --- trunk/myserver/src/http_handler/isapi/isapi.cpp 2009-04-12 20:43:00 UTC (rev 3051) +++ trunk/myserver/src/http_handler/isapi/isapi.cpp 2009-04-13 14:34:44 UTC (rev 3052) @@ -715,7 +715,8 @@ if(valLen + 30 < maxLen) valLen += sprintf(&ValStr[valLen], "SERVER_ADMIN:%s\n", - Server::getInstance()->getServerAdmin()); + td->securityToken.getHashedData ("server.admin", MYSERVER_VHOST_CONF | + MYSERVER_SERVER_CONF, "")); else if(valLen + 30 < maxLen) return 0; Modified: trunk/myserver/src/http_handler/wincgi/wincgi.cpp =================================================================== --- trunk/myserver/src/http_handler/wincgi/wincgi.cpp 2009-04-12 20:43:00 UTC (rev 3051) +++ trunk/myserver/src/http_handler/wincgi/wincgi.cpp 2009-04-13 14:34:44 UTC (rev 3052) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. +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 @@ -159,7 +159,9 @@ strcpy(buffer, "CGI Version=CGI/1.3a WIN\r\n"); DataFileHandle.writeToFile(buffer,26,&nbr); - *td->secondaryBuffer << "Server Admin=" << Server::getInstance()->getServerAdmin() << "\r\n"; + *td->secondaryBuffer << "Server Admin=" << + td->securityToken.getHashedData ("server.admin", MYSERVER_VHOST_CONF | + MYSERVER_SERVER_CONF, "")<< "\r\n"; DataFileHandle.writeToFile(buffer,td->secondaryBuffer->getLength(),&nbr); { @@ -304,7 +306,7 @@ spi.cmdLine.append(dataFilePath); spi.cwd.assign(pathname); spi.envString = 0; - if (proc.execAndWait (&spi, timeout)) + if (proc.exec (&spi, true)) { ostringstream msg; msg << "WinCGI: Error executing process " << scriptpath; From MAILER-DAEMON Sun Apr 19 10:20:48 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LvXt1-0005DF-U1 for mharc-myserver-commit@gnu.org; Sun, 19 Apr 2009 10:20:47 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LvXt0-0005Cq-IK for myserver-commit@gnu.org; Sun, 19 Apr 2009 10:20:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LvXsz-0005CF-2U for myserver-commit@gnu.org; Sun, 19 Apr 2009 10:20:45 -0400 Received: from [199.232.76.173] (port=33433 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LvXsy-0005C9-UY for myserver-commit@gnu.org; Sun, 19 Apr 2009 10:20:44 -0400 Received: from savannah.gnu.org ([199.232.41.3]:57215 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LvXsx-0000ED-Uq for myserver-commit@gnu.org; Sun, 19 Apr 2009 10:20:44 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LvXst-00076a-FJ for myserver-commit@gnu.org; Sun, 19 Apr 2009 14:20:40 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LvXsp-00075Y-Ag for myserver-commit@gnu.org; Sun, 19 Apr 2009 14:20:37 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Sun, 19 Apr 2009 14:20:35 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3053] Detect the mingw32 build target automatically. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Apr 2009 14:20:46 -0000 Revision: 3053 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3053 Author: gscrivano Date: 2009-04-19 14:20:31 +0000 (Sun, 19 Apr 2009) Log Message: ----------- Detect the mingw32 build target automatically. Modified Paths: -------------- trunk/myserver/configure.in trunk/myserver/include/base/regex/myserver_regex.h trunk/myserver/include/connection/connection.h trunk/myserver/src/base/base64/mime_utils.cpp trunk/myserver/src/base/file/files_utility.cpp trunk/myserver/stdafx.h Modified: trunk/myserver/configure.in =================================================================== --- trunk/myserver/configure.in 2009-04-13 14:34:44 UTC (rev 3052) +++ trunk/myserver/configure.in 2009-04-19 14:20:31 UTC (rev 3053) @@ -64,8 +64,6 @@ AC_ARG_ENABLE([ipv6], [ --enable-ipv6 Build with IPv6 support], enable_ipv6="yes", enable_ipv6="") -AC_ARG_ENABLE([mingw32], [ --enable-mingw32 Enable mingw32], enable_mingw32="yes", enable_mingw32="") - root_bindir='${root_prefix}/bin' root_sbindir='${root_prefix}/sbin' root_sysconfdir='${root_prefix}/etc' @@ -98,15 +96,44 @@ AC_CHECK_FUNCS(snprintf, AC_DEFINE(SNPRINTF, 1, [Define if the snprintf function is present]) ) -dnl Looking for pthreads -GNOME_PTHREAD_CHECK -if test x$PTHREAD_LIB = x -a "x$enable_mingw32" != "xyes"; then - AC_MSG_ERROR([ -*** This system appears to have no posix threads -*** Threads are required for MyServer -]) -fi +case "${host}" in + *-*-mingw32*) + LDFLAGS="$LDFLAGS -lwsock32 -lgdi32 -lole32 -luuid -luserenv" + ;; + *) + dnl Looking for pthreads + GNOME_PTHREAD_CHECK + if test x$PTHREAD_LIB = x; then + AC_MSG_ERROR([ + *** This system appears to have no posix threads + *** Threads are required for MyServer + ]) + fi + + dnl Looking for dl + AC_SEARCH_LIBS([dlopen], [dl c], have_dl=yes) + + if test x$have_dl == xyes; then + AC_DEFINE(HAVE_DL, 1, [LibDL support, define to 1 to enable]) + MAKE_MSCGI=yes + else + AC_MSG_WARN([ + *** dlLIB not found + *** MSCGI support will not function + ]) + DL_LIB="" + MAKE_MSCGI=no + fi + + + ;; + +esac + +AC_SUBST(DL_LIB) + + if test x$PTHREAD_LIB != x; then AC_DEFINE(HAVE_PTHREAD, 1, [POSIX threads required for MyServer in a non-windows environment]) fi @@ -120,22 +147,17 @@ fi AC_SUBST(XNET_LIB) -AC_CHECK_LIB(event, event_add, have_event=yes) +AC_SEARCH_LIBS([event_add], [event event_core event_extra], have_event=yes) +AC_CHECK_LIB([event], [event_add], have_event=yes) if test x$have_event = xyes; then - AC_CHECK_HEADER(event.h,, - [ - AC_MSG_WARN([event.h not found which is part of libevent.]) - ]) EVENT_LIB="-levent" else EVENT_LIB="" - if test "x$enable_mingw32" != "xyes"; then - AC_MSG_ERROR([ + AC_MSG_ERROR([ *** This system appears to have no libevent *** Libevent is required by MyServer ]) - fi fi AC_SUBST(EVENT_LIB) @@ -150,34 +172,7 @@ [AC_MSG_RESULT(no) AC_DEFINE(socklen_t, int, need to define this where socklen_t is not present)]) -dnl Looking for dl -AC_CHECK_LIB(dl ,dlopen, have_dl=yes) -AC_CHECK_LIB(c ,dlopen, have_dl=yes; no_dl_ld=yes) -if test x$have_dl != xyes; then - - if test "x$enable_mingw32" != "xyes"; then - AC_MSG_WARN([ -*** dlLIB not found -*** MSCGI support will not function - ]) - fi - - DL_LIB="" - MAKE_MSCGI=no -else - AC_DEFINE(HAVE_DL, 1, [LibDL support, define to 1 to enable]) - DL_LIB="-ldl" - MAKE_MSCGI=yes -fi -if test x$no_dl_ld = xyes; then - DL_LIB="" -fi - - -AC_SUBST(DL_LIB) - - # Libidn checks # ------------- AC_CHECK_HEADER(idna.h,, @@ -301,9 +296,7 @@ CPPUNIT_LDFLAGS="-lcppunit" fi -if test "x$enable_mingw32" = "xyes"; then - LDFLAGS="$LDFLAGS -levent_extra -levent_core -lws2_32 -lgdi32 -lrx -luserenv -lole32 -luuid -ly" -fi +LDFLAGS="$LDFLAGS $LIBS" AC_SUBST(CFLAGS) AC_SUBST(CXFLAGS) Modified: trunk/myserver/include/base/regex/myserver_regex.h =================================================================== --- trunk/myserver/include/base/regex/myserver_regex.h 2009-04-13 14:34:44 UTC (rev 3052) +++ trunk/myserver/include/base/regex/myserver_regex.h 2009-04-19 14:20:31 UTC (rev 3053) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. +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 @@ -21,10 +21,6 @@ #include "stdafx.h" -#ifdef WIN32 -#define REGEX -#endif - #ifndef _VC extern "C" { @@ -32,9 +28,7 @@ #include -#ifdef WIN32 -#include -#elif REGEX +#ifdef REGEX #include #else typedef void* regmatch_t; Modified: trunk/myserver/include/connection/connection.h =================================================================== --- trunk/myserver/include/connection/connection.h 2009-04-13 14:34:44 UTC (rev 3052) +++ trunk/myserver/include/connection/connection.h 2009-04-19 14:20:31 UTC (rev 3053) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. +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 @@ -22,7 +22,6 @@ extern "C" { #include -#include } #include Modified: trunk/myserver/src/base/base64/mime_utils.cpp =================================================================== --- trunk/myserver/src/base/base64/mime_utils.cpp 2009-04-13 14:34:44 UTC (rev 3052) +++ trunk/myserver/src/base/base64/mime_utils.cpp 2009-04-19 14:20:31 UTC (rev 3053) @@ -19,15 +19,16 @@ #include #include #include + extern "C" { -#ifndef WIN32 #include -#include -#endif - #include #include + +#ifndef WIN32 +#include +#endif } #define strupos(x, y) (strustr(x, y) != NULL ? strustr(x, y) - x : -1) //char version @@ -569,11 +570,9 @@ LineLen = 0; } finalresult = expandBuffer(finalresult, UsedSize, &BufSize, 0); -#ifdef WIN32 - itoa(mid, mids, 16); -#else + snprintf(mids, 3, "%X", mid); -#endif + strupr(mids); *(fresult++) = '='; *(fresult++) = mids[0]; Modified: trunk/myserver/src/base/file/files_utility.cpp =================================================================== --- trunk/myserver/src/base/file/files_utility.cpp 2009-04-13 14:34:44 UTC (rev 3052) +++ trunk/myserver/src/base/file/files_utility.cpp 2009-04-19 14:20:31 UTC (rev 3053) @@ -21,12 +21,17 @@ #include #include +extern "C" +{ +#include +} + #ifndef WIN32 -extern "C" { +extern "C" +{ #include #include #include -#include #include #include #include Modified: trunk/myserver/stdafx.h =================================================================== --- trunk/myserver/stdafx.h 2009-04-13 14:34:44 UTC (rev 3052) +++ trunk/myserver/stdafx.h 2009-04-19 14:20:31 UTC (rev 3053) @@ -31,31 +31,30 @@ #include #endif +#ifdef WIN32 +extern "C" +{ +#include +#include +#include +} +#endif + extern "C" { +#include #include #include -#include -#include -#include #include #include #ifndef WIN32 +#include +#include #include #endif } -#ifdef WIN32 -extern "C" -{ -#include -#include -#include -#include -} -#endif - #ifndef MAX_PATH #ifdef PATH_MAX #define MAX_PATH PATH_MAX From MAILER-DAEMON Mon Apr 20 15:20:36 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lvz2i-0006Sq-Fk for mharc-myserver-commit@gnu.org; Mon, 20 Apr 2009 15:20:36 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lvz2g-0006SG-F8 for myserver-commit@gnu.org; Mon, 20 Apr 2009 15:20:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lvz2f-0006S2-AF for myserver-commit@gnu.org; Mon, 20 Apr 2009 15:20:34 -0400 Received: from [199.232.76.173] (port=59750 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lvz2f-0006Rz-6i for myserver-commit@gnu.org; Mon, 20 Apr 2009 15:20:33 -0400 Received: from savannah.gnu.org ([199.232.41.3]:32858 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lvz2e-000692-Qq for myserver-commit@gnu.org; Mon, 20 Apr 2009 15:20:32 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lvz2d-0005Z8-Cr for myserver-commit@gnu.org; Mon, 20 Apr 2009 19:20:31 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lvz2b-0005Wl-Jq for myserver-commit@gnu.org; Mon, 20 Apr 2009 19:20:30 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Mon, 20 Apr 2009 19:20:29 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3054] Enable usage of the TRE regexp library if available. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Apr 2009 19:20:35 -0000 Revision: 3054 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3054 Author: gscrivano Date: 2009-04-20 19:20:26 +0000 (Mon, 20 Apr 2009) Log Message: ----------- Enable usage of the TRE regexp library if available. Modified Paths: -------------- trunk/myserver/configure.in trunk/myserver/include/base/regex/myserver_regex.h Modified: trunk/myserver/configure.in =================================================================== --- trunk/myserver/configure.in 2009-04-19 14:20:31 UTC (rev 3053) +++ trunk/myserver/configure.in 2009-04-20 19:20:26 UTC (rev 3054) @@ -83,9 +83,9 @@ AC_CHECK_HEADER([sys/sendfile.h], AC_DEFINE(SENDFILE, 1, [Define if the sendfile syscall is present])) +AC_CHECK_HEADER([tre/regex.h], AC_DEFINE(REGEX_TRE, 1, [Define if the tre regex library is present])) +AC_SEARCH_LIBS([regcomp], [c tre], AC_DEFINE(REGEX, 1, [Define if the regex library is present])) -AC_CHECK_FUNCS(regcomp, AC_DEFINE(REGEX, 1, [Define if the regex library is present]) ) - AC_CHECK_FUNCS(gettimeofday, AC_DEFINE(GETTIMEOFDAY, 1, [Define if the gettimeofday function is present]) ) AC_CHECK_FUNCS(setgroups, AC_DEFINE(SETGROUPS, 1, [Define if the setgroups function is present]) ) Modified: trunk/myserver/include/base/regex/myserver_regex.h =================================================================== --- trunk/myserver/include/base/regex/myserver_regex.h 2009-04-19 14:20:31 UTC (rev 3053) +++ trunk/myserver/include/base/regex/myserver_regex.h 2009-04-20 19:20:26 UTC (rev 3054) @@ -28,7 +28,9 @@ #include -#ifdef REGEX +#if REGEX_TRE +#include +#elif REGEX #include #else typedef void* regmatch_t; From MAILER-DAEMON Thu Apr 23 17:20:55 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lx6Ln-0004RE-8F for mharc-myserver-commit@gnu.org; Thu, 23 Apr 2009 17:20:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lx6Ll-0004Qs-74 for myserver-commit@gnu.org; Thu, 23 Apr 2009 17:20:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lx6Lj-0004QQ-Ny for myserver-commit@gnu.org; Thu, 23 Apr 2009 17:20:52 -0400 Received: from [199.232.76.173] (port=45675 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lx6Lj-0004QN-Jf for myserver-commit@gnu.org; Thu, 23 Apr 2009 17:20:51 -0400 Received: from savannah.gnu.org ([199.232.41.3]:45521 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lx6Lj-0003Mx-A9 for myserver-commit@gnu.org; Thu, 23 Apr 2009 17:20:51 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lx6Li-0007wf-E0 for myserver-commit@gnu.org; Thu, 23 Apr 2009 21:20:50 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lx6Lh-0007vW-7H for myserver-commit@gnu.org; Thu, 23 Apr 2009 21:20:49 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Thu, 23 Apr 2009 21:20:49 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3055] Do not use a special syntax to define values for log colours. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Apr 2009 21:20:53 -0000 Revision: 3055 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3055 Author: gscrivano Date: 2009-04-23 21:20:47 +0000 (Thu, 23 Apr 2009) Log Message: ----------- Do not use a special syntax to define values for log colours. Modified Paths: -------------- trunk/myserver/binaries/myserver.default.windows.xml trunk/myserver/binaries/myserver.default.xml trunk/myserver/documentation/log_management.texi trunk/myserver/src/server/server.cpp Modified: trunk/myserver/binaries/myserver.default.windows.xml =================================================================== --- trunk/myserver/binaries/myserver.default.windows.xml 2009-04-20 19:20:26 UTC (rev 3054) +++ trunk/myserver/binaries/myserver.default.windows.xml 2009-04-23 21:20:47 UTC (rev 3055) @@ -50,10 +50,16 @@ - - + + + + + + + + + Modified: trunk/myserver/binaries/myserver.default.xml =================================================================== --- trunk/myserver/binaries/myserver.default.xml 2009-04-20 19:20:26 UTC (rev 3054) +++ trunk/myserver/binaries/myserver.default.xml 2009-04-23 21:20:47 UTC (rev 3055) @@ -50,10 +50,16 @@ - - + + + + + + + + + Modified: trunk/myserver/documentation/log_management.texi =================================================================== --- trunk/myserver/documentation/log_management.texi 2009-04-20 19:20:26 UTC (rev 3054) +++ trunk/myserver/documentation/log_management.texi 2009-04-23 21:20:47 UTC (rev 3055) @@ -104,8 +104,14 @@ editing the @file{myserver.xml} configuration file and adding the following code: @example - + + + + + + + + @end example Allowed values for colors are @code{black}, @code{red}, @code{green}, @code{yellow}, @code{blue}, @code{magenta}, @code{cyan} and @@ -113,5 +119,5 @@ respectively the foreground attribute and the background one, while the three prefixes, @code{info}, @code{warning} and @code{error} represent kinds of logging messages managed by MyServer. -If the @code{CONSOLE_COLORS} information is missing or it is partially +If the console colours information is missing or it is partially provided, MyServer will use default values. Modified: trunk/myserver/src/server/server.cpp =================================================================== --- trunk/myserver/src/server/server.cpp 2009-04-20 19:20:26 UTC (rev 3054) +++ trunk/myserver/src/server/server.cpp 2009-04-23 21:20:47 UTC (rev 3055) @@ -1006,12 +1006,16 @@ { string fg (*it + "_fg"); string bg (*it + "_bg"); - data = configurationFileManager.getAttr ("CONSOLE_COLORS", fg.c_str ()); + + string fullFg ("log_color." + *it + "_fg"); + string fullBg ("log_color." + *it + "_bg"); + data = getHashedData (fullFg.c_str ()); if (data) { consoleColors[fg] = string (data); } - data = configurationFileManager.getAttr ("CONSOLE_COLORS", bg.c_str ()); + + data = getHashedData (fullBg.c_str ()); if (data) { consoleColors[bg] = string (data); From MAILER-DAEMON Thu Apr 23 17:21:06 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lx6Ly-0004U3-BW for mharc-myserver-commit@gnu.org; Thu, 23 Apr 2009 17:21:06 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lx6Lx-0004Tm-7E for myserver-commit@gnu.org; Thu, 23 Apr 2009 17:21:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lx6Lw-0004TR-Pu for myserver-commit@gnu.org; Thu, 23 Apr 2009 17:21:04 -0400 Received: from [199.232.76.173] (port=45683 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lx6Lw-0004TM-Js for myserver-commit@gnu.org; Thu, 23 Apr 2009 17:21:04 -0400 Received: from savannah.gnu.org ([199.232.41.3]:45524 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lx6Lw-0003Pa-Cy for myserver-commit@gnu.org; Thu, 23 Apr 2009 17:21:04 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lx6Lv-0007zJ-1Z for myserver-commit@gnu.org; Thu, 23 Apr 2009 21:21:03 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lx6Lt-0007z5-Ul for myserver-commit@gnu.org; Thu, 23 Apr 2009 21:21:02 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Thu, 23 Apr 2009 21:21:01 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3056] The default connections timeout value is changed to 3 minutes. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Apr 2009 21:21:05 -0000 Revision: 3056 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3056 Author: gscrivano Date: 2009-04-23 21:21:00 +0000 (Thu, 23 Apr 2009) Log Message: ----------- The default connections timeout value is changed to 3 minutes. Modified Paths: -------------- trunk/myserver/binaries/myserver.default.windows.xml trunk/myserver/binaries/myserver.default.xml trunk/myserver/src/server/server.cpp Modified: trunk/myserver/binaries/myserver.default.windows.xml =================================================================== --- trunk/myserver/binaries/myserver.default.windows.xml 2009-04-23 21:20:47 UTC (rev 3055) +++ trunk/myserver/binaries/myserver.default.windows.xml 2009-04-23 21:21:00 UTC (rev 3056) @@ -37,7 +37,7 @@ SECONDS THE CONNECTION WITH THE CLIENT IS CLOSED. SET THIS TO 0 IF YOU DON'T WANT USE KEEP-ALIVE CONNECTIONS --> - + Modified: trunk/myserver/binaries/myserver.default.xml =================================================================== --- trunk/myserver/binaries/myserver.default.xml 2009-04-23 21:20:47 UTC (rev 3055) +++ trunk/myserver/binaries/myserver.default.xml 2009-04-23 21:21:00 UTC (rev 3056) @@ -37,7 +37,7 @@ SECONDS THE CONNECTION WITH THE CLIENT IS CLOSED. SET THIS TO 0 IF YOU DON'T WANT USE KEEP-ALIVE CONNECTIONS --> - + Modified: trunk/myserver/src/server/server.cpp =================================================================== --- trunk/myserver/src/server/server.cpp 2009-04-23 21:20:47 UTC (rev 3055) +++ trunk/myserver/src/server/server.cpp 2009-04-23 21:21:00 UTC (rev 3056) @@ -985,7 +985,7 @@ nMaxThreads = 50; currentThreadID = 0; freeThreads = 0; - connectionTimeout = MYSERVER_SEC(25); + connectionTimeout = MYSERVER_SEC (180); endServer = false; verbosity = 1; purgeThreadsThreshold = 1; From MAILER-DAEMON Mon Apr 27 08:43:36 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LyQBM-0005Yf-Mn for mharc-myserver-commit@gnu.org; Mon, 27 Apr 2009 08:43:36 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LyQBL-0005YX-09 for myserver-commit@gnu.org; Mon, 27 Apr 2009 08:43:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LyQBK-0005YK-7U for myserver-commit@gnu.org; Mon, 27 Apr 2009 08:43:34 -0400 Received: from [199.232.76.173] (port=37634 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LyQBK-0005YH-2K for myserver-commit@gnu.org; Mon, 27 Apr 2009 08:43:34 -0400 Received: from savannah.gnu.org ([199.232.41.3]:54280 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LyQBJ-0004ae-IP for myserver-commit@gnu.org; Mon, 27 Apr 2009 08:43:33 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LyQBJ-0002G3-0X for myserver-commit@gnu.org; Mon, 27 Apr 2009 12:43:33 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LyQBI-0002Fz-KO for myserver-commit@gnu.org; Mon, 27 Apr 2009 12:43:32 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Mon, 27 Apr 2009 12:43:32 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3057] Unix domain sockets implementation wrapping the `Socket' functionalities and related test cases. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2009 12:43:35 -0000 Revision: 3057 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3057 Author: gscrivano Date: 2009-04-27 12:43:32 +0000 (Mon, 27 Apr 2009) Log Message: ----------- Unix domain sockets implementation wrapping the `Socket' functionalities and related test cases. The Unix domain sockets are implemented in the `UnixSocket' class. Modified Paths: -------------- trunk/myserver/configure.in trunk/myserver/include/base/Makefile.am trunk/myserver/src/base/Makefile.am trunk/myserver/src/base/socket/socket.cpp trunk/myserver/tests/Makefile.am Added Paths: ----------- trunk/myserver/include/base/unix_socket/ trunk/myserver/include/base/unix_socket/Makefile.am trunk/myserver/include/base/unix_socket/unix_socket.h trunk/myserver/src/base/unix_socket/ trunk/myserver/src/base/unix_socket/Makefile.am trunk/myserver/src/base/unix_socket/unix_socket.cpp trunk/myserver/tests/test_unix_socket.cpp Modified: trunk/myserver/configure.in =================================================================== --- trunk/myserver/configure.in 2009-04-23 21:21:00 UTC (rev 3056) +++ trunk/myserver/configure.in 2009-04-27 12:43:32 UTC (rev 3057) @@ -370,6 +370,7 @@ include/base/string/Makefile include/base/regex/Makefile include/base/thread/Makefile + include/base/unix_socket/Makefile include/protocol/Makefile include/protocol/ftp/Makefile include/protocol/control/Makefile @@ -420,6 +421,7 @@ src/base/string/Makefile src/base/regex/Makefile src/base/thread/Makefile + src/base/unix_socket/Makefile src/protocol/Makefile src/protocol/ftp/Makefile src/protocol/control/Makefile Modified: trunk/myserver/include/base/Makefile.am =================================================================== --- trunk/myserver/include/base/Makefile.am 2009-04-23 21:21:00 UTC (rev 3056) +++ trunk/myserver/include/base/Makefile.am 2009-04-27 12:43:32 UTC (rev 3057) @@ -1,4 +1,4 @@ baseincludedir=$(includedir)/myserver/include/base baseinclude_HEADERS = utility.h -SUBDIRS = base64 dynamic_lib file files_cache find_data hash_map home_dir md5 mem_buff multicast pipe process regex safetime socket socket_pair ssl string sync thread xml +SUBDIRS = base64 dynamic_lib file files_cache find_data hash_map home_dir md5 mem_buff multicast pipe process regex safetime socket socket_pair ssl string sync thread unix_socket xml Added: trunk/myserver/include/base/unix_socket/Makefile.am =================================================================== --- trunk/myserver/include/base/unix_socket/Makefile.am (rev 0) +++ trunk/myserver/include/base/unix_socket/Makefile.am 2009-04-27 12:43:32 UTC (rev 3057) @@ -0,0 +1,4 @@ +unix_socketincludedir=$(includedir)/myserver/include/base/unix_socket +unix_socketinclude_HEADERS = unix_socket.h +SUBDIRS = + Added: trunk/myserver/include/base/unix_socket/unix_socket.h =================================================================== --- trunk/myserver/include/base/unix_socket/unix_socket.h (rev 0) +++ trunk/myserver/include/base/unix_socket/unix_socket.h 2009-04-27 12:43:32 UTC (rev 3057) @@ -0,0 +1,61 @@ +/* -*- mode: c++ -*- */ +/* +MyServer +Copyright (C) 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 . +*/ + +#ifndef UNIX_SOCKET_H +#define UNIX_SOCKET_H + +#include "stdafx.h" +#include + + +extern "C" +{ +#ifndef WIN32 +#include +#endif +} + + +class UnixSocket: public Socket +{ +public: + UnixSocket (); + int bind(const char *path); + int shutdown (); + int close (); + int connect (const char* path); + Socket accept (); + int socket (); +protected: + +#ifdef AF_UNIX + sockaddr_un addr; +#endif + +private: +#ifdef AF_UNIX + void makeAddrInfo (sockaddr_un *info, const char *path) + { + memset(info, 0, sizeof(struct sockaddr_un)); + info->sun_family = AF_UNIX; + strcpy (info->sun_path, path); + } +#endif +}; + +#endif Modified: trunk/myserver/src/base/Makefile.am =================================================================== --- trunk/myserver/src/base/Makefile.am 2009-04-23 21:21:00 UTC (rev 3056) +++ trunk/myserver/src/base/Makefile.am 2009-04-27 12:43:32 UTC (rev 3057) @@ -1,5 +1,5 @@ lib_LIBRARIES = libbase.a libbase_a_SOURCES = utility.cpp -SUBDIRS = base64 dynamic_lib file files_cache find_data hash_map home_dir md5 mem_buff multicast pipe process regex safetime socket socket_pair ssl string sync thread xml +SUBDIRS = base64 dynamic_lib file files_cache find_data hash_map home_dir md5 mem_buff multicast pipe process regex safetime socket socket_pair ssl string sync thread xml unix_socket INCLUDES = $(all_includes) Modified: trunk/myserver/src/base/socket/socket.cpp =================================================================== --- trunk/myserver/src/base/socket/socket.cpp 2009-04-23 21:21:00 UTC (rev 3056) +++ trunk/myserver/src/base/socket/socket.cpp 2009-04-27 12:43:32 UTC (rev 3057) @@ -97,6 +97,7 @@ } /*! *Create the socket. + *\return 0 on error. */ int Socket::socket(int af, int type, int protocol) { @@ -163,15 +164,16 @@ */ int Socket::bind(MYSERVER_SOCKADDR* sa,int namelen) { - if ( sa == NULL || (sa->ss_family != AF_INET && sa->ss_family != AF_INET6) ) + if ( sa == NULL ) return -1; - if ( (sa->ss_family == AF_INET && namelen != sizeof(sockaddr_in)) + + if ((sa->ss_family == AF_INET && namelen != sizeof(sockaddr_in)) #if HAVE_IPV6 || (sa->ss_family == AF_INET6 && namelen != sizeof(sockaddr_in6)) #endif - ) + ) + return -1; - return -1; #ifdef WIN32 return ::bind((SOCKET)socketHandle,(const struct sockaddr*)sa,namelen); #else @@ -185,9 +187,9 @@ int Socket::listen(int max) { #ifdef WIN32 - return ::listen(socketHandle,max); + return ::listen(socketHandle, max); #else - return ::listen((int)socketHandle,max); + return ::listen((int)socketHandle, max); #endif } @@ -592,10 +594,11 @@ /*! *Connect the socket. */ -int Socket::connect(MYSERVER_SOCKADDR* sa, int na) +int Socket::connect (MYSERVER_SOCKADDR* sa, int na) { - if ( sa == NULL || (sa->ss_family != AF_INET && sa->ss_family != AF_INET6) ) + if ( sa == NULL ) return -1; + if ( (sa->ss_family == AF_INET && na != sizeof(sockaddr_in)) #if HAVE_IPV6 || (sa->ss_family == AF_INET6 && na != sizeof(sockaddr_in6)) Added: trunk/myserver/src/base/unix_socket/Makefile.am =================================================================== --- trunk/myserver/src/base/unix_socket/Makefile.am (rev 0) +++ trunk/myserver/src/base/unix_socket/Makefile.am 2009-04-27 12:43:32 UTC (rev 3057) @@ -0,0 +1,5 @@ +lib_LIBRARIES = libunix_socket.a +libunix_socket_a_SOURCES = unix_socket.cpp +SUBDIRS = +INCLUDES = $(all_includes) + Added: trunk/myserver/src/base/unix_socket/unix_socket.cpp =================================================================== --- trunk/myserver/src/base/unix_socket/unix_socket.cpp (rev 0) +++ trunk/myserver/src/base/unix_socket/unix_socket.cpp 2009-04-27 12:43:32 UTC (rev 3057) @@ -0,0 +1,122 @@ +/* +MyServer +Copyright (C) 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 . +*/ + + +#include "stdafx.h" +#include + +UnixSocket::UnixSocket () +{ + +} + +/*! + *Bind the socket to a file. If the file exists it is removed. + *\param path Path to the file bound by the socket. + *\return 0 on success. + */ +int UnixSocket::bind(const char* path) +{ + if (path == NULL) + return -1; + +#ifdef AF_UNIX + makeAddrInfo (&addr, path); + unlink (path); + + return Socket::bind ((MYSERVER_SOCKADDR*)&addr, sizeof (sockaddr_un)); +#else + return -1; +#endif +} + +/*! + *Shutdown the socket. + *\return 0 on success. + */ +int UnixSocket::shutdown () +{ +#ifdef AF_UNIX + Socket::shutdown (2); + unlink (addr.sun_path); +#else + return -1; +#endif +} + + +/*! + *Free the socket. + *\return 0 on success. + */ +int UnixSocket::close () +{ +#ifdef AF_UNIX + Socket::close (); +#else + return -1; +#endif +} + +/*! + *Open the socket. + *\return the socket handle on success. + */ +int UnixSocket::socket () +{ +#ifdef AF_UNIX + return Socket::socket (AF_UNIX, SOCK_STREAM, 0); +#else + return 0; +#endif +} + +/*! + *Connect to an Unix socket by its path. + *\param path Path to the Unix socket. + *\return 0 on success. + */ +int UnixSocket::connect (const char* path) +{ + if (path == NULL) + return -1; + +#ifdef AF_UNIX + makeAddrInfo (&addr, path); + + return Socket::connect ((MYSERVER_SOCKADDR*)&addr, sizeof (addr)); +#else + return -1; +#endif +} + +/*! + *Accept a new connection. + */ +Socket UnixSocket::accept () +{ + +#ifdef AF_UNIX + sockaddr_un addr; + int len = sizeof (addr); + return Socket::accept ((MYSERVER_SOCKADDR*)&addr, &len); +#else + Socket s; + s.setHandle (0); + return s; +#endif +} Modified: trunk/myserver/tests/Makefile.am =================================================================== --- trunk/myserver/tests/Makefile.am 2009-04-23 21:21:00 UTC (rev 3056) +++ trunk/myserver/tests/Makefile.am 2009-04-27 12:43:32 UTC (rev 3057) @@ -2,5 +2,5 @@ # bin_PROGRAMS = tests_suite -tests_suite_SOURCES = main.cpp test_connection.cpp test_ftp.cpp test_log_manager.cpp test_mime_manager.cpp test_mutex.cpp test_security_domain.cpp test_validator.cpp test_auth_domain.cpp test_connections_scheduler.cpp test_gzip.cpp test_log_stream_factory.cpp test_pipe.cpp test_security_manager.cpp test_validator_factory.cpp test_base64.cpp test_file_stream.cpp test_hashmap.cpp test_md5.cpp test_recursive_mutex.cpp test_semaphore.cpp test_xml.cpp test_cached_file_buffer.cpp test_file_stream_creator.cpp test_homedir.cpp test_mem_buff.cpp test_regex.cpp test_socket_stream_creator.cpp test_cached_file.cpp test_files_utility.cpp test_http_request.cpp test_http_req_security_domain.cpp test_mem_stream.cpp test_safetime.cpp test_thread.cpp test_cached_file_factory.cpp test_filter_chain.cpp test_http_response.cpp test_multicast.cpp test_security_cache.cpp test_security_token.cpp test_socket_pair.cpp test_utility.cpp test_xml_validator.cpp test_ip.cpp test_plugin_info.cpp test_fork_server.cpp +tests_suite_SOURCES = main.cpp test_connection.cpp test_ftp.cpp test_log_manager.cpp test_mime_manager.cpp test_mutex.cpp test_security_domain.cpp test_validator.cpp test_auth_domain.cpp test_connections_scheduler.cpp test_gzip.cpp test_log_stream_factory.cpp test_pipe.cpp test_security_manager.cpp test_validator_factory.cpp test_base64.cpp test_file_stream.cpp test_hashmap.cpp test_md5.cpp test_recursive_mutex.cpp test_semaphore.cpp test_xml.cpp test_cached_file_buffer.cpp test_file_stream_creator.cpp test_homedir.cpp test_mem_buff.cpp test_regex.cpp test_socket_stream_creator.cpp test_cached_file.cpp test_files_utility.cpp test_http_request.cpp test_http_req_security_domain.cpp test_mem_stream.cpp test_safetime.cpp test_thread.cpp test_cached_file_factory.cpp test_filter_chain.cpp test_http_response.cpp test_multicast.cpp test_security_cache.cpp test_security_token.cpp test_socket_pair.cpp test_unix_socket.cpp test_utility.cpp test_xml_validator.cpp test_ip.cpp test_plugin_info.cpp test_fork_server.cpp tests_suite_LDADD = ../src/libmyserver.a $(CPPUNIT_LDFLAGS) $(PTHREAD_LIB) $(IDN_LIB) $(XNET_LIB) $(EVENT_LIB) $(DL_LIB) $(SSL_LIB) $(ZLIB_LIB) $(XML_LIBS) $(LDFLAGS) Added: trunk/myserver/tests/test_unix_socket.cpp =================================================================== --- trunk/myserver/tests/test_unix_socket.cpp (rev 0) +++ trunk/myserver/tests/test_unix_socket.cpp 2009-04-27 12:43:32 UTC (rev 3057) @@ -0,0 +1,147 @@ +/* + MyServer + Copyright (C) 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 . + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifdef AF_UNIX + +#define TEST_STRING "Hello World!" + +struct UnixSocketServerType +{ + bool result; + UnixSocket *socket; +}; + +void* test_unix_socket_server (void* pParam) +{ + UnixSocketServerType *server = (UnixSocketServerType*)pParam; + server->result = false; + + Socket client = server->socket->accept (); + + if (client.getHandle () == 0) + return NULL; + + char buffer [256]; + if (client.recv(buffer, 256, 0, MYSERVER_SEC (1)) == 0) + { + client.close (); + return NULL; + } + + + server->result = !strcmpi (buffer, TEST_STRING); + + client.close (); + return NULL; +} + + + +class TestUnixSocket : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( TestUnixSocket ); + CPPUNIT_TEST( testBind ); + CPPUNIT_TEST( testClient ); + CPPUNIT_TEST_SUITE_END(); + + UnixSocket *sock; +public: + + void setUp () + { + sock = new UnixSocket (); + } + + void tearDown () + { + delete sock; + } + + void testBind () + { + int ret; + string path; + FilesUtility::temporaryFileName(0, path); + + + CPPUNIT_ASSERT (sock->socket ()); + + //FIXME: find a better place inside FilesUtility. + struct stat F_Stats; + ret = stat(path.c_str (), &F_Stats); + CPPUNIT_ASSERT (ret); + ///////////////////////////////////////////////// + + CPPUNIT_ASSERT_EQUAL (sock->bind (path.c_str ()), 0); + + ret = stat(path.c_str (), &F_Stats); + CPPUNIT_ASSERT_EQUAL (ret, 0); + + CPPUNIT_ASSERT_EQUAL (sock->shutdown (), 0); + + CPPUNIT_ASSERT_EQUAL (sock->close (), 0); + + ret = stat(path.c_str (), &F_Stats); + CPPUNIT_ASSERT (ret); + } + + void testClient () + { + ThreadID tid; + UnixSocketServerType data; + data.socket = sock; + data.result = false; + + int ret; + string path; + FilesUtility::temporaryFileName (0, path); + sock->socket (); + sock->bind (path.c_str ()); + CPPUNIT_ASSERT_EQUAL (sock->listen (1), 0); + + int res = Thread::create (&tid, test_unix_socket_server, &data); + + UnixSocket client; + client.socket (); + CPPUNIT_ASSERT_EQUAL (client.connect (path.c_str ()), 0); + int length = strlen (TEST_STRING) + 1; + CPPUNIT_ASSERT_EQUAL (client.send (TEST_STRING, length, 0), length); + + Thread::join (tid); + + client.shutdown (); + client.close (); + + CPPUNIT_ASSERT_EQUAL (data.result, true); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION( TestUnixSocket ); + +#endif From MAILER-DAEMON Mon Apr 27 17:33:03 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LyYRi-0007JA-LE for mharc-myserver-commit@gnu.org; Mon, 27 Apr 2009 17:33:02 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LyYRf-0007F8-93 for myserver-commit@gnu.org; Mon, 27 Apr 2009 17:32:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LyYRe-0007DJ-7N for myserver-commit@gnu.org; Mon, 27 Apr 2009 17:32:58 -0400 Received: from [199.232.76.173] (port=40054 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LyYRd-0007Cq-MF for myserver-commit@gnu.org; Mon, 27 Apr 2009 17:32:57 -0400 Received: from savannah.gnu.org ([199.232.41.3]:53771 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LyYRd-0002jy-AY for myserver-commit@gnu.org; Mon, 27 Apr 2009 17:32:57 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LyYRc-0005XE-Ru for myserver-commit@gnu.org; Mon, 27 Apr 2009 21:32:56 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LyYRc-0005XA-Ip for myserver-commit@gnu.org; Mon, 27 Apr 2009 21:32:56 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Mon, 27 Apr 2009 21:32:56 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3058] The `UnixSocket' class is able to migrate file descriptors. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2009 21:32:59 -0000 Revision: 3058 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3058 Author: gscrivano Date: 2009-04-27 21:32:56 +0000 (Mon, 27 Apr 2009) Log Message: ----------- The `UnixSocket' class is able to migrate file descriptors. Modified Paths: -------------- trunk/myserver/include/base/unix_socket/unix_socket.h trunk/myserver/include/base/utility.h trunk/myserver/src/base/socket_pair/socket_pair.cpp trunk/myserver/src/base/unix_socket/unix_socket.cpp trunk/myserver/src/base/utility.cpp Modified: trunk/myserver/include/base/unix_socket/unix_socket.h =================================================================== --- trunk/myserver/include/base/unix_socket/unix_socket.h 2009-04-27 12:43:32 UTC (rev 3057) +++ trunk/myserver/include/base/unix_socket/unix_socket.h 2009-04-27 21:32:56 UTC (rev 3058) @@ -47,6 +47,9 @@ sockaddr_un addr; #endif + int readHandle (FileHandle* fd); + int writeHandle (FileHandle fd); + private: #ifdef AF_UNIX void makeAddrInfo (sockaddr_un *info, const char *path) Modified: trunk/myserver/include/base/utility.h =================================================================== --- trunk/myserver/include/base/utility.h 2009-04-27 12:43:32 UTC (rev 3057) +++ trunk/myserver/include/base/utility.h 2009-04-27 21:32:56 UTC (rev 3058) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2003, 2004, 2006, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 2006, 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 @@ -55,5 +55,7 @@ int setcwd(const char * cwd); int freecwdBuffer(); +int readFileHandle (FileHandle s, FileHandle* fd); +int writeFileHandle (FileHandle s, FileHandle fd); #endif Modified: trunk/myserver/src/base/socket_pair/socket_pair.cpp =================================================================== --- trunk/myserver/src/base/socket_pair/socket_pair.cpp 2009-04-27 12:43:32 UTC (rev 3057) +++ trunk/myserver/src/base/socket_pair/socket_pair.cpp 2009-04-27 21:32:56 UTC (rev 3058) @@ -227,32 +227,7 @@ */ int SocketPair::readHandle (FileHandle* fd) { -#ifdef WIN32 - return -1; -#else - struct msghdr mh; - struct cmsghdr cmh[2]; - struct iovec iov; - int ret; - char tbuf[4]; - mh.msg_name = 0; - mh.msg_namelen = 0; - mh.msg_iov = &iov; - mh.msg_iovlen = 1; - mh.msg_control = (caddr_t)&cmh[0]; - mh.msg_controllen = sizeof (cmh[0]) * 2; - iov.iov_base = tbuf; - iov.iov_len = 4; - cmh[0].cmsg_len = sizeof (cmh[0]) + sizeof(int); - ret = recvmsg (handles[0], &mh, 0); - - if (ret < 0) - return ret; - - *fd = *(FileHandle *)&cmh[1]; - - return 0; -#endif + return readFileHandle (handles[0], fd); } /*! @@ -262,27 +237,5 @@ */ int SocketPair::writeHandle (FileHandle fd) { -#ifdef WIN32 - return -1; -#else - struct msghdr mh; - struct cmsghdr cmh[2]; - struct iovec iov; - char tbuf[4]; - memset (&mh,0,sizeof (mh)); - mh.msg_name = 0; - mh.msg_namelen = 0; - mh.msg_iov = &iov; - mh.msg_iovlen = 1; - mh.msg_control = (caddr_t)&cmh[0]; - mh.msg_controllen = sizeof (cmh[0]) + sizeof (int); - mh.msg_flags = 0; - iov.iov_base = tbuf; - iov.iov_len = 4; - cmh[0].cmsg_level = SOL_SOCKET; - cmh[0].cmsg_type = SCM_RIGHTS; - cmh[0].cmsg_len = sizeof(cmh[0]) + sizeof(int); - *(int *)&cmh[1] = fd; - return sendmsg (handles[0], &mh, 0); -#endif + return writeFileHandle (handles[0], fd); } Modified: trunk/myserver/src/base/unix_socket/unix_socket.cpp =================================================================== --- trunk/myserver/src/base/unix_socket/unix_socket.cpp 2009-04-27 12:43:32 UTC (rev 3057) +++ trunk/myserver/src/base/unix_socket/unix_socket.cpp 2009-04-27 21:32:56 UTC (rev 3058) @@ -18,6 +18,7 @@ #include "stdafx.h" #include +#include UnixSocket::UnixSocket () { @@ -120,3 +121,24 @@ return s; #endif } + + +/*! + *Read a file handle on the socket pair. + *\param fd The file descriptor to read. + *\return 0 on success. + */ +int UnixSocket::readHandle (FileHandle* fd) +{ + return readFileHandle (getHandle (), fd); +} + +/*! + *Transmit a file descriptor on the socket. + *\param fd The file descriptor to transmit. + *\return 0 on success. + */ +int UnixSocket::writeHandle (FileHandle fd) +{ + return writeFileHandle (getHandle (), fd); +} Modified: trunk/myserver/src/base/utility.cpp =================================================================== --- trunk/myserver/src/base/utility.cpp 2009-04-27 12:43:32 UTC (rev 3057) +++ trunk/myserver/src/base/utility.cpp 2009-04-27 21:32:56 UTC (rev 3058) @@ -318,3 +318,72 @@ return (tval.tv_sec * 1000) + (tval.tv_usec / 1000); #endif } + +/*! + *Read a file handle from a socket. + *\param s Socket handle to read from. + *\param File handle received. + *\return 0 on success. + */ +int readFileHandle (FileHandle s, FileHandle* fd) +{ +#ifdef WIN32 + return -1; +#else + struct msghdr mh; + struct cmsghdr cmh[2]; + struct iovec iov; + int ret; + char tbuf[4]; + mh.msg_name = 0; + mh.msg_namelen = 0; + mh.msg_iov = &iov; + mh.msg_iovlen = 1; + mh.msg_control = (caddr_t)&cmh[0]; + mh.msg_controllen = sizeof (cmh[0]) * 2; + iov.iov_base = tbuf; + iov.iov_len = 4; + cmh[0].cmsg_len = sizeof (cmh[0]) + sizeof(int); + ret = recvmsg (s, &mh, 0); + + if (ret < 0) + return ret; + + *fd = *(FileHandle *)&cmh[1]; + + return 0; +#endif +} + +/*! + *Write a file handle to a socket. + *\param s Socket handle to write to. + *\param File handle received. + *\return 0 on success. + */ +int writeFileHandle (FileHandle s, FileHandle fd) +{ +#ifdef WIN32 + return -1; +#else + struct msghdr mh; + struct cmsghdr cmh[2]; + struct iovec iov; + char tbuf[4]; + memset (&mh,0,sizeof (mh)); + mh.msg_name = 0; + mh.msg_namelen = 0; + mh.msg_iov = &iov; + mh.msg_iovlen = 1; + mh.msg_control = (caddr_t)&cmh[0]; + mh.msg_controllen = sizeof (cmh[0]) + sizeof (int); + mh.msg_flags = 0; + iov.iov_base = tbuf; + iov.iov_len = 4; + cmh[0].cmsg_level = SOL_SOCKET; + cmh[0].cmsg_type = SCM_RIGHTS; + cmh[0].cmsg_len = sizeof(cmh[0]) + sizeof(int); + *(int *)&cmh[1] = fd; + return sendmsg (s, &mh, 0); +#endif +} From MAILER-DAEMON Mon Apr 27 18:02:37 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LyYuL-0002u5-3N for mharc-myserver-commit@gnu.org; Mon, 27 Apr 2009 18:02:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LyYuJ-0002tA-BB for myserver-commit@gnu.org; Mon, 27 Apr 2009 18:02:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LyYuI-0002sq-Mt for myserver-commit@gnu.org; Mon, 27 Apr 2009 18:02:34 -0400 Received: from [199.232.76.173] (port=57366 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LyYuI-0002sg-9t for myserver-commit@gnu.org; Mon, 27 Apr 2009 18:02:34 -0400 Received: from savannah.gnu.org ([199.232.41.3]:47881 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LyYuH-0005R0-JY for myserver-commit@gnu.org; Mon, 27 Apr 2009 18:02:33 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LyYuG-0005HT-T2 for myserver-commit@gnu.org; Mon, 27 Apr 2009 22:02:33 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LyYuG-0005Gf-H9 for myserver-commit@gnu.org; Mon, 27 Apr 2009 22:02:32 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Mon, 27 Apr 2009 22:02:32 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3059] Removed readFd/writeFd helper functions from `ForkServer'. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2009 22:02:35 -0000 Revision: 3059 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3059 Author: gscrivano Date: 2009-04-27 22:02:32 +0000 (Mon, 27 Apr 2009) Log Message: ----------- Removed readFd/writeFd helper functions from `ForkServer'. Modified Paths: -------------- trunk/myserver/include/base/process/fork_server.h trunk/myserver/src/base/process/fork_server.cpp Modified: trunk/myserver/include/base/process/fork_server.h =================================================================== --- trunk/myserver/include/base/process/fork_server.h 2009-04-27 21:32:56 UTC (rev 3058) +++ trunk/myserver/include/base/process/fork_server.h 2009-04-27 22:02:32 UTC (rev 3059) @@ -45,9 +45,6 @@ int readInt (SocketPair *sock, int *dest); int readString (SocketPair *sock, char **out); - int writeFd (SocketPair *socket, FileHandle fd); - int readFd (SocketPair *sock, FileHandle *fd); - int handleRequest (SocketPair *serverSock); int forkServerLoop (SocketPair *socket); Modified: trunk/myserver/src/base/process/fork_server.cpp =================================================================== --- trunk/myserver/src/base/process/fork_server.cpp 2009-04-27 21:32:56 UTC (rev 3058) +++ trunk/myserver/src/base/process/fork_server.cpp 2009-04-27 22:02:32 UTC (rev 3059) @@ -26,28 +26,26 @@ #endif /*! - *Read a file descriptor from the specified socket. - *\param socket Socket to use. - *\param fd File handle to write. + *Write a string to the socket. + *The string length is sent before the content. + * + *\param socket Socket where write. + *\param str string to write. + *\param len string length. */ -int ForkServer::writeFd (SocketPair *socket, FileHandle fd) +int ForkServer::writeString (SocketPair *socket, const char* str, int len) { - if (socket->writeHandle (fd)) - return 1; + u_long nbw; - return 0; -} + if (str == NULL) + len = 0; -/*! - *Write a file descriptor on the specified socket. - *\param socket Socket to use. - *\param fd Pointer to the file handle that is read. - */ -int ForkServer::readFd (SocketPair *socket, FileHandle *fd) -{ - if (socket->readHandle (fd)) + if (socket->write ((const char*)&len, 4, &nbw)) return 1; + if (len && socket->write (str, len, &nbw)) + return 1; + return 0; } @@ -66,30 +64,7 @@ return 0; } -/*! - *Write a string to the socket. - *The string length is sent before the content. - * - *\param socket Socket where write. - *\param str string to write. - *\param len string length. - */ -int ForkServer::writeString (SocketPair *socket, const char* str, int len) -{ - u_long nbw; - if (str == NULL) - len = 0; - - if (socket->write ((const char*)&len, 4, &nbw)) - return 1; - - if (len && socket->write (str, len, &nbw)) - return 1; - - return 0; -} - /*! *Read an integer from the socket. * @@ -157,14 +132,14 @@ readInt (serverSock, &flags); if (flags & FLAG_USE_IN) - readFd (serverSock, &stdIn); + serverSock->readHandle (&stdIn); if (flags & FLAG_USE_OUT) - readFd (serverSock, &stdOut); + serverSock->readHandle (&stdOut); if (flags & FLAG_USE_ERR) - readFd (serverSock, &stdErr); - + serverSock->readHandle (&stdErr); + readInt (serverSock, &gid); readInt (serverSock, &uid); @@ -319,13 +294,13 @@ writeInt (&socket, flags); if (flags & FLAG_USE_IN) - writeFd (&socket, spi->stdIn); + socket.writeHandle (spi->stdIn); if (flags & FLAG_USE_OUT) - writeFd (&socket, spi->stdOut); + socket.writeHandle (spi->stdOut); if (flags & FLAG_USE_ERR) - writeFd (&socket, spi->stdError); + socket.writeHandle (spi->stdError); writeInt (&socket, spi->gid); writeInt (&socket, spi->uid); From MAILER-DAEMON Tue Apr 28 06:07:54 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LykEE-0004I4-Is for mharc-myserver-commit@gnu.org; Tue, 28 Apr 2009 06:07:54 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LykEC-0004HE-O9 for myserver-commit@gnu.org; Tue, 28 Apr 2009 06:07:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LykEB-0004Gf-QR for myserver-commit@gnu.org; Tue, 28 Apr 2009 06:07:52 -0400 Received: from [199.232.76.173] (port=51074 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LykEB-0004GY-KX for myserver-commit@gnu.org; Tue, 28 Apr 2009 06:07:51 -0400 Received: from savannah.gnu.org ([199.232.41.3]:43202 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LykEB-0002Bd-11 for myserver-commit@gnu.org; Tue, 28 Apr 2009 06:07:51 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LykEA-0008Kn-In for myserver-commit@gnu.org; Tue, 28 Apr 2009 10:07:50 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LykEA-0008Kh-AS for myserver-commit@gnu.org; Tue, 28 Apr 2009 10:07:50 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Tue, 28 Apr 2009 10:07:50 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3060] Now the `ForkServer' class uses an Unix domain socket for the communication with the MyServer main process . X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2009 10:07:53 -0000 Revision: 3060 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3060 Author: gscrivano Date: 2009-04-28 10:07:49 +0000 (Tue, 28 Apr 2009) Log Message: ----------- Now the `ForkServer' class uses an Unix domain socket for the communication with the MyServer main process. It is more fault tolerant than the previous single socket pair used to multiplex all requests. Modified Paths: -------------- trunk/myserver/include/base/process/fork_server.h trunk/myserver/src/base/process/fork_server.cpp Modified: trunk/myserver/include/base/process/fork_server.h =================================================================== --- trunk/myserver/include/base/process/fork_server.h 2009-04-27 22:02:32 UTC (rev 3059) +++ trunk/myserver/include/base/process/fork_server.h 2009-04-28 10:07:49 UTC (rev 3060) @@ -17,9 +17,7 @@ #include -#include -#include -#include +#include #ifndef FORK_SERVER_H #define FORK_SERVER_H @@ -34,19 +32,19 @@ const static int FLAG_USE_ERR = 4; const static int FLAG_STDIN_SOCKET = 8; - ForkServer () {initialized = false; serverLock.init ();} - ~ForkServer () {serverLock.destroy ();} + ForkServer () {initialized = false;} + ~ForkServer () {} void killServer (); int startForkServer (); - int writeInt (SocketPair *socket, int num); - int writeString (SocketPair *socket, const char* str, int len); - int readInt (SocketPair *sock, int *dest); - int readString (SocketPair *sock, char **out); + int writeInt (Socket *socket, int num); + int writeString (Socket *socket, const char* str, int len); + int readInt (Socket *sock, int *dest); + int readString (Socket *sock, char **out); - int handleRequest (SocketPair *serverSock); - int forkServerLoop (SocketPair *socket); + int handleRequest (Socket *serverSock); + int forkServerLoop (UnixSocket *socket); int executeProcess (StartProcInfo *spi, int flags, int *pid, int *port, @@ -57,10 +55,10 @@ int generateListenerSocket (Socket &socket, u_short *port); private: + string socketPath; + UnixSocket socket; - SocketPair socket; - Mutex serverLock; u_short port; bool initialized; }; Modified: trunk/myserver/src/base/process/fork_server.cpp =================================================================== --- trunk/myserver/src/base/process/fork_server.cpp 2009-04-27 22:02:32 UTC (rev 3059) +++ trunk/myserver/src/base/process/fork_server.cpp 2009-04-28 10:07:49 UTC (rev 3060) @@ -16,15 +16,16 @@ */ #include -#include -#include -#include +#include +#include #ifndef WIN32 +extern "C" +{ #include #include +} #endif - /*! *Write a string to the socket. *The string length is sent before the content. @@ -33,7 +34,7 @@ *\param str string to write. *\param len string length. */ -int ForkServer::writeString (SocketPair *socket, const char* str, int len) +int ForkServer::writeString (Socket *socket, const char* str, int len) { u_long nbw; @@ -54,7 +55,7 @@ *\param socket Socket to use. *\param num Integer to write. */ -int ForkServer::writeInt (SocketPair *socket, int num) +int ForkServer::writeInt (Socket *socket, int num) { u_long nbw; @@ -64,7 +65,6 @@ return 0; } - /*! *Read an integer from the socket. * @@ -72,7 +72,7 @@ *\param dest integer where write *\return 0 on success. */ -int ForkServer::readInt (SocketPair *sock, int *dest) +int ForkServer::readInt (Socket *sock, int *dest) { u_long nbr; @@ -93,7 +93,7 @@ *\param out destination buffer pointer. *\return 0 on success. */ -int ForkServer::readString (SocketPair *sock, char **out) +int ForkServer::readString (Socket *sock, char **out) { int len; u_long nbr; @@ -118,7 +118,7 @@ /*! *Handle a request on the socket. */ -int ForkServer::handleRequest (SocketPair *serverSock) +int ForkServer::handleRequest (Socket *sock) { #ifndef WIN32 int ret, flags, stdIn = -1, stdOut = -1, stdErr = -1; @@ -129,29 +129,28 @@ char *arg; char *env; - readInt (serverSock, &flags); + readInt (sock, &flags); if (flags & FLAG_USE_IN) - serverSock->readHandle (&stdIn); + readFileHandle (sock->getHandle (), &stdIn); if (flags & FLAG_USE_OUT) - serverSock->readHandle (&stdOut); + readFileHandle (sock->getHandle (), &stdOut); if (flags & FLAG_USE_ERR) - serverSock->readHandle (&stdErr); + readFileHandle (sock->getHandle (), &stdErr); - readInt (serverSock, &gid); - readInt (serverSock, &uid); + readInt (sock, &gid); + readInt (sock, &uid); - readString (serverSock, &exec); - readString (serverSock, &cwd); + readString (sock, &exec); + readString (sock, &cwd); - readString (serverSock, &arg); + readString (sock, &arg); string argS (arg); - - readString (serverSock, &env); + readString (sock, &env); Socket socketIn; @@ -164,8 +163,8 @@ delete [] exec; delete [] cwd; delete [] arg; - writeInt (serverSock, -1); - writeInt (serverSock, -1); + writeInt (sock, -1); + writeInt (sock, -1); return -1; } stdInPort = (int) stdInPortS; @@ -189,14 +188,14 @@ spi.arg.assign (arg); spi.cwd.assign (cwd); - FileHandle handlesToClose[] = {serverSock->getFirstHandle (), 0}; + FileHandle handlesToClose[] = {0}; spi.handlesToClose = handlesToClose; Process pi; int pid = pi.exec (&spi, false); - writeInt (serverSock, pid); - writeInt (serverSock, stdInPort); + writeInt (sock, pid); + writeInt (sock, stdInPort); delete [] exec; delete [] cwd; @@ -221,32 +220,38 @@ *Entry point for the fork server. *Listen for new connections on the specified socket. * - *\param socket Socket where wait for new connections. + *\param serverSocket Socket where wait for new connections. *\return 0 on success. */ -int ForkServer::forkServerLoop (SocketPair *socket) +int ForkServer::forkServerLoop (UnixSocket *serverSocket) { #ifndef WIN32 for (;;) { try { + Socket socket = serverSocket->accept (); + char command; u_long nbr; - MYSERVER_SOCKADDR_STORAGE sockaddr; - int len = sizeof (sockaddr); - if (socket->read (&command, 1, &nbr)) - continue; - + if (socket.read (&command, 1, &nbr)) + { + socket.close (); + continue; + } switch (command) { case 'e': //exit process + socket.close (); + serverSocket->shutdown (); + serverSocket->close (); exit (0); return 0; case 'r': - if (handleRequest (socket)) + if (handleRequest (&socket)) { + socket.close (); continue; } } @@ -255,6 +260,8 @@ in _any_ case. */ catch(...) { + serverSocket->close (); + socket.close (); perror ("fork server died."); exit (1); } @@ -285,46 +292,44 @@ int len = 0; const char * env = (const char *) spi->envString; - serverLock.lock (); - try { - socket.write ("r", 1, &nbw); + UnixSocket sock; + sock.socket (); + sock.connect (socketPath.c_str ()); + sock.write ("r", 1, &nbw); - writeInt (&socket, flags); + writeInt (&sock, flags); if (flags & FLAG_USE_IN) - socket.writeHandle (spi->stdIn); + writeFileHandle (sock.getHandle (), spi->stdIn); if (flags & FLAG_USE_OUT) - socket.writeHandle (spi->stdOut); + writeFileHandle (sock.getHandle (), spi->stdOut); if (flags & FLAG_USE_ERR) - socket.writeHandle (spi->stdError); + writeFileHandle (sock.getHandle (), spi->stdError); - writeInt (&socket, spi->gid); - writeInt (&socket, spi->uid); + writeInt (&sock, spi->gid); + writeInt (&sock, spi->uid); - writeString (&socket, spi->cmd.c_str (), spi->cmd.length ()); - writeString (&socket, spi->cwd.c_str (), spi->cwd.length ()); - writeString (&socket, spi->arg.c_str (), spi->arg.length ()); + writeString (&sock, spi->cmd.c_str (), spi->cmd.length ()); + writeString (&sock, spi->cwd.c_str (), spi->cwd.length ()); + writeString (&sock, spi->arg.c_str (), spi->arg.length ()); if (env) for (len = 0; env[len] != '\0' || env[len + 1] != '\0' ; len++); - writeString (&socket, env, len); + writeString (&sock, env, len); - readInt (&socket, pid); - readInt (&socket, port); + readInt (&sock, pid); + readInt (&sock, port); } catch (exception &e) { - serverLock.unlock (); throw e; } - serverLock.unlock (); - if (waitEnd) { return waitpid (*pid, NULL, 0); @@ -341,16 +346,11 @@ void ForkServer::killServer () { u_long nbw; - - serverLock.lock (); - - socket.write ("e", 1, &nbw); - - serverLock.unlock (); - - serverLock.destroy (); - - socket.close (); + UnixSocket s; + s.socket (); + s.connect (socketPath.c_str ()); + s.write ("e", 1, &nbw); + s.close (); } /*! @@ -361,24 +361,24 @@ int ForkServer::startForkServer () { #ifndef WIN32 - socket.create (); - serverLock.init (); - SocketPair inverted; - socket.inverted (inverted); + FilesUtility::temporaryFileName(0, socketPath); switch (fork ()) { case -1: return -1; case 0: + socket.socket (); + socket.bind (socketPath.c_str ()); + socket.listen (SOMAXCONN); + initialized = true; - socket.closeFirstHandle (); - forkServerLoop (&inverted); + + forkServerLoop (&socket); exit (1); break; default: - socket.closeSecondHandle (); initialized = true; break; } From MAILER-DAEMON Tue Apr 28 06:07:58 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LykEI-0004K4-QN for mharc-myserver-commit@gnu.org; Tue, 28 Apr 2009 06:07:58 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LykEH-0004JY-Fg for myserver-commit@gnu.org; Tue, 28 Apr 2009 06:07:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LykEG-0004J7-Pl for myserver-commit@gnu.org; Tue, 28 Apr 2009 06:07:57 -0400 Received: from [199.232.76.173] (port=51075 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LykEG-0004Iz-Gf for myserver-commit@gnu.org; Tue, 28 Apr 2009 06:07:56 -0400 Received: from savannah.gnu.org ([199.232.41.3]:43207 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LykEG-0002DL-4s for myserver-commit@gnu.org; Tue, 28 Apr 2009 06:07:56 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LykEF-0008Li-L2 for myserver-commit@gnu.org; Tue, 28 Apr 2009 10:07:55 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LykEF-0008Le-Ca for myserver-commit@gnu.org; Tue, 28 Apr 2009 10:07:55 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Tue, 28 Apr 2009 10:07:55 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3061] Code refactoring, some methods were renamed and file are copied by blocks of 4Kb. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2009 10:07:57 -0000 Revision: 3061 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3061 Author: gscrivano Date: 2009-04-28 10:07:55 +0000 (Tue, 28 Apr 2009) Log Message: ----------- Code refactoring, some methods were renamed and file are copied by blocks of 4Kb. Modified Paths: -------------- trunk/myserver/include/base/file/files_utility.h trunk/myserver/src/base/file/files_utility.cpp trunk/myserver/src/protocol/ftp/ftp.cpp Modified: trunk/myserver/include/base/file/files_utility.h =================================================================== --- trunk/myserver/include/base/file/files_utility.h 2009-04-28 10:07:49 UTC (rev 3060) +++ trunk/myserver/include/base/file/files_utility.h 2009-04-28 10:07:55 UTC (rev 3061) @@ -1,7 +1,7 @@ /* -*- mode: c++ -*- */ /* MyServer -Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 2006, 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 @@ -92,13 +92,14 @@ static void getFilename(const char* path, char* filename); static void getFilename(string const &path, string& filename); - static int simpleMakeDirectory(const char *path); - static int deleteDirectory(const char *path); - static int simpleMakeDirectory(string const &path) - { return simpleMakeDirectory(path.c_str()); } - static int deleteDirectory(string const &path) - { return deleteDirectory(path.c_str()); } + static int rmdir (const char *path); + static int rmdir (string const &path) + { return rmdir (path.c_str()); } + static int mkdir (const char *path); + static int mkdir (string const &path) + { return mkdir (path.c_str()); } + static void temporaryFileName(u_long tid, string &out); static void resetTmpPath(); Modified: trunk/myserver/src/base/file/files_utility.cpp =================================================================== --- trunk/myserver/src/base/file/files_utility.cpp 2009-04-28 10:07:49 UTC (rev 3060) +++ trunk/myserver/src/base/file/files_utility.cpp 2009-04-28 10:07:55 UTC (rev 3061) @@ -212,14 +212,14 @@ */ int FilesUtility::copyFile(File src, File dest) { - char buffer[512]; + char buffer[4096]; u_long nbr, nbw; int ret; for (;;) { - ret = src.read(buffer, 512, &nbr); + ret = src.read(buffer, 4096, &nbr); if (ret) return -1; @@ -747,12 +747,12 @@ *Return non-zero on errors. *\param path The path to the directory to create. */ -int FilesUtility::simpleMakeDirectory(const char *path) +int FilesUtility::mkdir (const char *path) { #ifdef WIN32 return CreateDirectory(path, NULL)?0:-1; #else - return mkdir(path, S_IRUSR | S_IWUSR); + return ::mkdir(path, S_IRUSR | S_IWUSR); #endif } @@ -762,12 +762,12 @@ *Return non-zero on errors. *\param path The directory to remove. */ -int FilesUtility::deleteDirectory(const char *path) +int FilesUtility::rmdir (const char *path) { #ifdef WIN32 return RemoveDirectory(path)?0:-1; #else - return rmdir(path); + return ::rmdir(path); #endif } @@ -803,20 +803,20 @@ /*! - *Create an unique temporary file name. This function doesn't create the - *file or open it but generates only its name. + *Create an unique temporary file name. This function doesn't create + *or open the file but generates only its name. *\param tid Caller thread id. *\param out Output string. */ -void FilesUtility::temporaryFileName(u_long tid, string &out) +void FilesUtility::temporaryFileName (u_long tid, string &out) { ostringstream stream; static u_long counter = 1; counter++; - if(tmpPath.length() == 0) - tmpPath.assign(getdefaultwd(0, 0)); + if (tmpPath.length () == 0) + tmpPath.assign (getdefaultwd (0, 0)); stream << tmpPath << "/myserver_" << counter << "_" << tid << ".tmp"; - out.assign(stream.str()); + out.assign (stream.str ()); } Modified: trunk/myserver/src/protocol/ftp/ftp.cpp =================================================================== --- trunk/myserver/src/protocol/ftp/ftp.cpp 2009-04-28 10:07:49 UTC (rev 3060) +++ trunk/myserver/src/protocol/ftp/ftp.cpp 2009-04-28 10:07:55 UTC (rev 3061) @@ -2286,7 +2286,7 @@ ftp_reply(550); return; } - if ( FilesUtility::simpleMakeDirectory(sLocalPath) == 0 ) + if ( FilesUtility::mkdir (sLocalPath) == 0 ) ftp_reply(250); else ftp_reply(501); @@ -2320,7 +2320,7 @@ ftp_reply(550); return; } - if ( FilesUtility::deleteDirectory(sLocalPath) == 0 ) + if ( FilesUtility::rmdir (sLocalPath) == 0 ) ftp_reply(250); else ftp_reply(501); From MAILER-DAEMON Thu Apr 30 18:52:55 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lzf7f-0000Fc-GN for mharc-myserver-commit@gnu.org; Thu, 30 Apr 2009 18:52:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lzf7d-0000FA-SI for myserver-commit@gnu.org; Thu, 30 Apr 2009 18:52:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lzf7d-0000Ew-Gt for myserver-commit@gnu.org; Thu, 30 Apr 2009 18:52:53 -0400 Received: from [199.232.76.173] (port=34573 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lzf7d-0000Es-7v for myserver-commit@gnu.org; Thu, 30 Apr 2009 18:52:53 -0400 Received: from savannah.gnu.org ([199.232.41.3]:44560 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lzf7c-0001KF-CB for myserver-commit@gnu.org; Thu, 30 Apr 2009 18:52:52 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lzf7b-0007gs-Ob for myserver-commit@gnu.org; Thu, 30 Apr 2009 22:52:51 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lzf7b-0007go-I6 for myserver-commit@gnu.org; Thu, 30 Apr 2009 22:52:51 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Thu, 30 Apr 2009 22:52:51 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3062] Solve compiling problems under WIN32 with sockets classes. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2009 22:52:54 -0000 Revision: 3062 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3062 Author: gscrivano Date: 2009-04-30 22:52:51 +0000 (Thu, 30 Apr 2009) Log Message: ----------- Solve compiling problems under WIN32 with sockets classes. Modified Paths: -------------- trunk/myserver/include/base/unix_socket/unix_socket.h trunk/myserver/src/base/socket_pair/socket_pair.cpp Modified: trunk/myserver/include/base/unix_socket/unix_socket.h =================================================================== --- trunk/myserver/include/base/unix_socket/unix_socket.h 2009-04-28 10:07:55 UTC (rev 3061) +++ trunk/myserver/include/base/unix_socket/unix_socket.h 2009-04-30 22:52:51 UTC (rev 3062) @@ -25,7 +25,9 @@ extern "C" { -#ifndef WIN32 +#ifdef WIN32 +#undef AF_UNIX //This shouldn't happen, but better be sure. +#else #include #endif } Modified: trunk/myserver/src/base/socket_pair/socket_pair.cpp =================================================================== --- trunk/myserver/src/base/socket_pair/socket_pair.cpp 2009-04-28 10:07:55 UTC (rev 3061) +++ trunk/myserver/src/base/socket_pair/socket_pair.cpp 2009-04-30 22:52:51 UTC (rev 3062) @@ -227,7 +227,7 @@ */ int SocketPair::readHandle (FileHandle* fd) { - return readFileHandle (handles[0], fd); + return readFileHandle ((FileHandle)handles[0], fd); } /*! @@ -237,5 +237,5 @@ */ int SocketPair::writeHandle (FileHandle fd) { - return writeFileHandle (handles[0], fd); + return writeFileHandle ((FileHandle)handles[0], fd); } From MAILER-DAEMON Thu Apr 30 18:53:01 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lzf7l-0000G8-MP for mharc-myserver-commit@gnu.org; Thu, 30 Apr 2009 18:53:01 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lzf7k-0000G3-HW for myserver-commit@gnu.org; Thu, 30 Apr 2009 18:53:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lzf7i-0000Fp-TQ for myserver-commit@gnu.org; Thu, 30 Apr 2009 18:52:59 -0400 Received: from [199.232.76.173] (port=34576 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lzf7i-0000Fm-Nn for myserver-commit@gnu.org; Thu, 30 Apr 2009 18:52:58 -0400 Received: from savannah.gnu.org ([199.232.41.3]:44562 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lzf7i-0001LE-9J for myserver-commit@gnu.org; Thu, 30 Apr 2009 18:52:58 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lzf7h-0007kY-Oe for myserver-commit@gnu.org; Thu, 30 Apr 2009 22:52:57 +0000 Received: from gscrivano by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lzf7h-0007kU-Gq for myserver-commit@gnu.org; Thu, 30 Apr 2009 22:52:57 +0000 MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ Errors-To: gscrivano To: myserver-commit@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Giuseppe Scrivano Message-Id: Date: Thu, 30 Apr 2009 22:52:57 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [myserver-commit] [3063] The new SocketHandle type was added. X-BeenThere: myserver-commit@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: myserver-commit.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2009 22:53:01 -0000 Revision: 3063 http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3063 Author: gscrivano Date: 2009-04-30 22:52:57 +0000 (Thu, 30 Apr 2009) Log Message: ----------- The new SocketHandle type was added. Modified Paths: -------------- trunk/myserver/include/base/process/process_server_manager.h trunk/myserver/include/base/socket/socket.h trunk/myserver/include/base/socket_pair/socket_pair.h trunk/myserver/include/base/unix_socket/unix_socket.h trunk/myserver/include/base/utility.h trunk/myserver/include/connections_scheduler/connections_scheduler.h trunk/myserver/include/filter/stream.h trunk/myserver/src/base/socket/socket.cpp trunk/myserver/src/base/socket_pair/socket_pair.cpp trunk/myserver/src/base/unix_socket/unix_socket.cpp trunk/myserver/src/base/utility.cpp trunk/myserver/src/connections_scheduler/connections_scheduler.cpp trunk/myserver/src/filter/stream.cpp Modified: trunk/myserver/include/base/process/process_server_manager.h =================================================================== --- trunk/myserver/include/base/process/process_server_manager.h 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/include/base/process/process_server_manager.h 2009-04-30 22:52:57 UTC (rev 3063) @@ -42,7 +42,7 @@ union { unsigned long fileHandle; - SOCKET sock; + SocketHandle sock; unsigned int value; }DESCRIPTOR; Modified: trunk/myserver/include/base/socket/socket.h =================================================================== --- trunk/myserver/include/base/socket/socket.h 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/include/base/socket/socket.h 2009-04-30 22:52:57 UTC (rev 3063) @@ -46,11 +46,17 @@ #include } -#define SOCKET int #define INVALID_SOCKET -1 #define SD_BOTH SHUT_RDWR #endif +#ifdef WIN32 +typedef SOCKET SocketHandle; +#else +typedef int SocketHandle; +#endif + + #ifdef INET6_ADDRSTRLEN #define MAX_IP_STRING_LEN INET6_ADDRSTRLEN #else @@ -71,8 +77,8 @@ Socket* getServerSocket(); static void stopBlockingOperations(bool); - virtual FileHandle getHandle(); - void setHandle(FileHandle); + virtual Handle getHandle(); + void setHandle(SocketHandle); static MYSERVER_HOSTENT *gethostbyaddr(char* addr, int len, int type); static MYSERVER_HOSTENT *gethostbyname(const char*); static int gethostname(char*, int); @@ -81,7 +87,7 @@ int listen(int); Socket(); Socket(Socket*); - Socket(FileHandle); + Socket(SocketHandle); Socket accept(MYSERVER_SOCKADDR*, int*); int setsockopt(int,int, const char*,int); @@ -111,11 +117,7 @@ virtual int write(const char* buffer, u_long len, u_long *nbw); protected: -#ifdef WIN32 - SOCKET socketHandle; -#else - FileHandle socketHandle; -#endif + SocketHandle socketHandle; /*! Pointer to the socket that has accepted this connection. */ Socket *serverSocket; Modified: trunk/myserver/include/base/socket_pair/socket_pair.h =================================================================== --- trunk/myserver/include/base/socket_pair/socket_pair.h 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/include/base/socket_pair/socket_pair.h 2009-04-30 22:52:57 UTC (rev 3063) @@ -32,27 +32,19 @@ public: SocketPair (); int create (); -#ifdef WIN32 - SOCKET getFirstHandle (); - SOCKET getSecondHandle (); -#else - FileHandle getFirstHandle (); - FileHandle getSecondHandle (); -#endif + SocketHandle getFirstHandle (); + SocketHandle getSecondHandle (); + void inverted (SocketPair&); virtual int close (); void closeFirstHandle (); void closeSecondHandle (); void setNonBlocking (bool blocking); - int readHandle (FileHandle*); - int writeHandle (FileHandle); + int readHandle (Handle*); + int writeHandle (Handle); protected: -#ifdef WIN32 - SOCKET handles[2]; -#else - FileHandle handles[2]; -#endif + SocketHandle handles[2]; }; #endif Modified: trunk/myserver/include/base/unix_socket/unix_socket.h =================================================================== --- trunk/myserver/include/base/unix_socket/unix_socket.h 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/include/base/unix_socket/unix_socket.h 2009-04-30 22:52:57 UTC (rev 3063) @@ -49,8 +49,8 @@ sockaddr_un addr; #endif - int readHandle (FileHandle* fd); - int writeHandle (FileHandle fd); + int readHandle (Handle* fd); + int writeHandle (Handle fd); private: #ifdef AF_UNIX Modified: trunk/myserver/include/base/utility.h =================================================================== --- trunk/myserver/include/base/utility.h 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/include/base/utility.h 2009-04-30 22:52:57 UTC (rev 3063) @@ -55,7 +55,7 @@ int setcwd(const char * cwd); int freecwdBuffer(); -int readFileHandle (FileHandle s, FileHandle* fd); -int writeFileHandle (FileHandle s, FileHandle fd); +int readFileHandle (SocketHandle s, Handle* fd); +int writeFileHandle (SocketHandle s, Handle fd); #endif Modified: trunk/myserver/include/connections_scheduler/connections_scheduler.h =================================================================== --- trunk/myserver/include/connections_scheduler/connections_scheduler.h 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/include/connections_scheduler/connections_scheduler.h 2009-04-30 22:52:57 UTC (rev 3063) @@ -102,7 +102,7 @@ u_long getNumTotalConnections(); - void newData(short event, FileHandle handle); + void newData(short event, SocketHandle handle); private: Server* server; @@ -116,7 +116,7 @@ Mutex eventsMutex; Mutex eventsSocketMutex; queue *ready; - HashMap connections; + HashMap connections; list listeners; u_long currentPriority; u_long currentPriorityDone; Modified: trunk/myserver/include/filter/stream.h =================================================================== --- trunk/myserver/include/filter/stream.h 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/include/filter/stream.h 2009-04-30 22:52:57 UTC (rev 3063) @@ -22,8 +22,14 @@ #include "stdafx.h" #ifdef WIN32 -typedef void* FileHandle; +typedef void* Handle; #else +typedef int Handle; +#endif + +#ifdef WIN32 +typedef HANDLE FileHandle; +#else typedef int FileHandle; #endif @@ -36,7 +42,7 @@ virtual int read(char* buffer, u_long len, u_long*); virtual int write(const char* buffer, u_long len, u_long*); virtual int flush(u_long*); - virtual FileHandle getHandle(); + virtual Handle getHandle(); virtual int close(); Stream(); /*! Avoid direct instances of this class. */ Modified: trunk/myserver/src/base/socket/socket.cpp =================================================================== --- trunk/myserver/src/base/socket/socket.cpp 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/src/base/socket/socket.cpp 2009-04-30 22:52:57 UTC (rev 3063) @@ -59,21 +59,17 @@ /*! *Returns the socket handle */ -FileHandle Socket::getHandle() +Handle Socket::getHandle() { - return (FileHandle) socketHandle; + return (Handle) socketHandle; } /*! *Set the handle for the socket */ -void Socket::setHandle(FileHandle h) +void Socket::setHandle(SocketHandle h) { -#ifdef WIN32 - socketHandle = (SOCKET) h; -#else socketHandle = h; -#endif } /*! @@ -112,7 +108,7 @@ /*! *Set the base/socket/socket.handle. */ -Socket::Socket(FileHandle handle) +Socket::Socket(SocketHandle handle) { throttlingRate = 0; setHandle (handle); @@ -200,19 +196,12 @@ { Socket s; -#ifdef WIN32 - FileHandle h = (FileHandle)::accept(socketHandle,(struct sockaddr*)sa, - sockaddrlen); - s.setHandle(h); -#else socklen_t connectSize; - int acceptHandle; connectSize = (socklen_t) *sockaddrlen; - acceptHandle = ::accept((int)socketHandle, (struct sockaddr *)sa, - (socklen_t*)&connectSize); + SocketHandle acceptHandle = ::accept((int)socketHandle, (struct sockaddr *)sa, + (socklen_t*)&connectSize); s.setHandle(acceptHandle); -#endif return s; } Modified: trunk/myserver/src/base/socket_pair/socket_pair.cpp =================================================================== --- trunk/myserver/src/base/socket_pair/socket_pair.cpp 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/src/base/socket_pair/socket_pair.cpp 2009-04-30 22:52:57 UTC (rev 3063) @@ -142,11 +142,7 @@ /*! *Get the first handle used by the socket pair. */ -#ifdef WIN32 -SOCKET SocketPair::getFirstHandle () -#else -FileHandle SocketPair::getFirstHandle () -#endif +SocketHandle SocketPair::getFirstHandle () { return handles[0]; } @@ -154,11 +150,7 @@ /*! *Get the second handle used by the socket pair. */ -#ifdef WIN32 -SOCKET SocketPair::getSecondHandle () -#else -FileHandle SocketPair::getSecondHandle () -#endif +SocketHandle SocketPair::getSecondHandle () { return handles[1]; } @@ -194,7 +186,7 @@ */ void SocketPair::closeFirstHandle () { - Socket sock ((FileHandle)handles[0]); + Socket sock (handles[0]); sock.close (); } @@ -203,7 +195,7 @@ */ void SocketPair::closeSecondHandle () { - Socket sock ((FileHandle)handles[1]); + Socket sock (handles[1]); sock.close (); } @@ -213,10 +205,10 @@ */ void SocketPair::setNonBlocking (bool notBlocking) { - Socket sock0 ((FileHandle)handles[0]); + Socket sock0 (handles[0]); sock0.setNonBlocking (notBlocking); - Socket sock1 ((FileHandle)handles[1]); + Socket sock1 (handles[1]); sock1.setNonBlocking (notBlocking); } @@ -225,9 +217,9 @@ *\param fd The file descriptor to read. *\return 0 on success. */ -int SocketPair::readHandle (FileHandle* fd) +int SocketPair::readHandle (Handle* fd) { - return readFileHandle ((FileHandle)handles[0], fd); + return readFileHandle (handles[0], fd); } /*! @@ -235,7 +227,7 @@ *\param fd The file descriptor to transmit. *\return 0 on success. */ -int SocketPair::writeHandle (FileHandle fd) +int SocketPair::writeHandle (Handle fd) { - return writeFileHandle ((FileHandle)handles[0], fd); + return writeFileHandle (handles[0], fd); } Modified: trunk/myserver/src/base/unix_socket/unix_socket.cpp =================================================================== --- trunk/myserver/src/base/unix_socket/unix_socket.cpp 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/src/base/unix_socket/unix_socket.cpp 2009-04-30 22:52:57 UTC (rev 3063) @@ -128,9 +128,9 @@ *\param fd The file descriptor to read. *\return 0 on success. */ -int UnixSocket::readHandle (FileHandle* fd) +int UnixSocket::readHandle (Handle* fd) { - return readFileHandle (getHandle (), fd); + return readFileHandle (socketHandle, fd); } /*! @@ -138,7 +138,7 @@ *\param fd The file descriptor to transmit. *\return 0 on success. */ -int UnixSocket::writeHandle (FileHandle fd) +int UnixSocket::writeHandle (Handle fd) { - return writeFileHandle (getHandle (), fd); + return writeFileHandle (socketHandle, fd); } Modified: trunk/myserver/src/base/utility.cpp =================================================================== --- trunk/myserver/src/base/utility.cpp 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/src/base/utility.cpp 2009-04-30 22:52:57 UTC (rev 3063) @@ -325,7 +325,7 @@ *\param File handle received. *\return 0 on success. */ -int readFileHandle (FileHandle s, FileHandle* fd) +int readFileHandle (SocketHandle s, Handle* fd) { #ifdef WIN32 return -1; @@ -361,7 +361,7 @@ *\param File handle received. *\return 0 on success. */ -int writeFileHandle (FileHandle s, FileHandle fd) +int writeFileHandle (SocketHandle s, Handle fd) { #ifdef WIN32 return -1; Modified: trunk/myserver/src/connections_scheduler/connections_scheduler.cpp =================================================================== --- trunk/myserver/src/connections_scheduler/connections_scheduler.cpp 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/src/connections_scheduler/connections_scheduler.cpp 2009-04-30 22:52:57 UTC (rev 3063) @@ -68,13 +68,13 @@ ConnectionsScheduler::DispatcherArg* arg = (ConnectionsScheduler::DispatcherArg*) param; if(!arg->terminate && arg->scheduler) - arg->scheduler->newData(event, (FileHandle)fd); + arg->scheduler->newData(event, fd); } -void ConnectionsScheduler::newData(short event, FileHandle handle) +void ConnectionsScheduler::newData(short event, SocketHandle handle) { - ConnectionPtr connection = connections.get(handle); + ConnectionPtr connection = connections.get (handle); if(connection == NULL || server == NULL) return; @@ -100,7 +100,7 @@ u_long nbr; if (event == EV_READ || event == EV_TIMEOUT) { - Socket sock ((FileHandle) da->socketPair.getFirstHandle ()); + Socket sock (da->socketPair.getFirstHandle ()); while (da->socketPair.bytesToRead()) { @@ -111,15 +111,15 @@ /* *Schedule a new connection. *The 'c' command is followed by: - *FileHandle -> Socket to monitor for new data. + *SocketHandle -> Socket to monitor for new data. *ConnectionPtr -> Related Connection. *timeval -> Timeout. */ - FileHandle handle; + SocketHandle handle; ConnectionPtr c; timeval tv = {10, 0}; - da->socketPair.read ((char*)&handle, sizeof(FileHandle), &nbr); + da->socketPair.read ((char*)&handle, sizeof(SocketHandle), &nbr); da->socketPair.read ((char*)&c, sizeof(ConnectionPtr), &nbr); da->socketPair.read ((char*)&tv, sizeof(timeval), &nbr); @@ -152,8 +152,7 @@ asockInLen = sizeof (asockIn); asock = s->serverSocket->accept (&asockIn, &asockInLen); - if (s->server && - asock.getHandle() != (FileHandle)INVALID_SOCKET) + if (s->server && (SocketHandle)asock.getHandle() != INVALID_SOCKET) { s->server->addConnection (asock, &asockIn); } @@ -186,7 +185,7 @@ event_add(&(arg->ev), &tv); u_long nbw; - Socket sock ((FileHandle)dispatcherArg.socketPair.getSecondHandle ()); + Socket sock (dispatcherArg.socketPair.getSecondHandle ()); eventsSocketMutex.lock(); sock.write("l", 1, &nbw); @@ -386,7 +385,7 @@ void ConnectionsScheduler::addWaitingConnectionImpl(ConnectionPtr c, int lock) { static timeval tv = {10, 0}; - FileHandle handle = c->socket ? c->socket->getHandle() : NULL; + SocketHandle handle = c->socket ? (SocketHandle) c->socket->getHandle() : NULL; if(server) tv.tv_sec = server->getTimeout() / 1000; @@ -408,11 +407,11 @@ if(lock) { u_long nbw; - Socket sock ((FileHandle)dispatcherArg.socketPair.getSecondHandle ()); + Socket sock (dispatcherArg.socketPair.getSecondHandle ()); eventsSocketMutex.lock(); sock.write("c", 1, &nbw); - sock.write((char*)&handle, sizeof(FileHandle), &nbw); + sock.write((char*)&handle, sizeof(SocketHandle), &nbw); sock.write((char*)&c, sizeof(ConnectionPtr), &nbw); sock.write((char*)&tv, sizeof(timeval), &nbw); eventsSocketMutex.unlock(); @@ -482,8 +481,8 @@ readySemaphore->unlock(); } - Socket sockR ((FileHandle)dispatcherArg.socketPair.getFirstHandle ()); - Socket sockW ((FileHandle)dispatcherArg.socketPair.getSecondHandle ()); + Socket sockR (dispatcherArg.socketPair.getFirstHandle ()); + Socket sockW (dispatcherArg.socketPair.getSecondHandle ()); eventsSocketMutex.lock(); sockW.write("r", 1, &nbw); @@ -525,7 +524,7 @@ connectionsMutex.lock(); - HashMap::Iterator it = connections.begin(); + HashMap::Iterator it = connections.begin(); for(; it != connections.end(); it++) out.push_back(*it); @@ -547,7 +546,7 @@ { connectionsMutex.lock(); if(connection->socket) - connections.remove(connection->socket->getHandle()); + connections.remove((SocketHandle)connection->socket->getHandle()); connectionsMutex.unlock(); delete connection; } @@ -563,7 +562,7 @@ { connectionsMutex.lock(); - HashMap::Iterator it = connections.begin(); + HashMap::Iterator it = connections.begin(); for(; it != connections.end(); it++) { ConnectionPtr c = *it; @@ -601,7 +600,7 @@ try { - for(HashMap::Iterator it = connections.begin(); + for(HashMap::Iterator it = connections.begin(); it != connections.end() && !ret; it++) { Modified: trunk/myserver/src/filter/stream.cpp =================================================================== --- trunk/myserver/src/filter/stream.cpp 2009-04-30 22:52:51 UTC (rev 3062) +++ trunk/myserver/src/filter/stream.cpp 2009-04-30 22:52:57 UTC (rev 3063) @@ -1,6 +1,6 @@ /* MyServer -Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc. +Copyright (C) 2002, 2003, 2004, 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 @@ -70,7 +70,7 @@ /*! *Get the file handle. */ -FileHandle Stream::getHandle() +Handle Stream::getHandle() { return 0; }