myserver-commit
[Top][All Lists]
Advanced

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

[myserver-commit] [2893] Added `FilesUtility::resetTmpPath()' and used a


From: Giuseppe Scrivano
Subject: [myserver-commit] [2893] Added `FilesUtility::resetTmpPath()' and used at `Server' initialization.
Date: Sun, 19 Oct 2008 17:59:25 +0000

Revision: 2893
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2893
Author:   gscrivano
Date:     2008-10-19 17:59:24 +0000 (Sun, 19 Oct 2008)

Log Message:
-----------
Added `FilesUtility::resetTmpPath()' and used at `Server' initialization.  Some 
compiler warnings silented.

Modified Paths:
--------------
    trunk/myserver/include/base/file/files_utility.h
    trunk/myserver/include/conf/security/security_token.h
    trunk/myserver/src/base/file/files_utility.cpp
    trunk/myserver/src/conf/vhost/vhost_manager.cpp
    trunk/myserver/src/http_handler/cgi/cgi.cpp
    trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
    trunk/myserver/src/protocol/http/http.cpp
    trunk/myserver/src/server/server.cpp

Modified: trunk/myserver/include/base/file/files_utility.h
===================================================================
--- trunk/myserver/include/base/file/files_utility.h    2008-10-19 16:31:51 UTC 
(rev 2892)
+++ trunk/myserver/include/base/file/files_utility.h    2008-10-19 17:59:24 UTC 
(rev 2893)
@@ -101,6 +101,7 @@
 
   static void temporaryFileName(u_long tid, string &out);
 
+  static void resetTmpPath();
   static void setTmpPath(string & path){tmpPath.assign(path);}
 private:
        static string tmpPath;

Modified: trunk/myserver/include/conf/security/security_token.h
===================================================================
--- trunk/myserver/include/conf/security/security_token.h       2008-10-19 
16:31:51 UTC (rev 2892)
+++ trunk/myserver/include/conf/security/security_token.h       2008-10-19 
17:59:24 UTC (rev 2893)
@@ -140,7 +140,7 @@
     resource = r;
   }
 
-  int setMask (int m)
+  void setMask (int m)
   {
     mask = m;
   }
@@ -155,12 +155,12 @@
     neededPassword.assign (pw);
   }
 
-  bool setDone (bool d)
+  void setDone (bool d)
   {
     done = d;
   }
 
-  bool setAuthenticated (bool a)
+  void setAuthenticated (bool a)
   {
     authenticated = a;
   }

Modified: trunk/myserver/src/base/file/files_utility.cpp
===================================================================
--- trunk/myserver/src/base/file/files_utility.cpp      2008-10-19 16:31:51 UTC 
(rev 2892)
+++ trunk/myserver/src/base/file/files_utility.cpp      2008-10-19 17:59:24 UTC 
(rev 2893)
@@ -220,18 +220,18 @@
 
 
   for (;;) 
-    {
-       ret = src.readFromFile(buffer, 512, &nbr);
-       if (ret)
-         return -1;
-
-       if (!nbr)
-         break;
-
-       ret = dest.writeToFile(buffer, nbr, &nbw);
-       if (ret)
-         return -1;
-    }
+  {
+    ret = src.readFromFile(buffer, 512, &nbr);
+    if (ret)
+      return -1;
+    
+    if (!nbr)
+      break;
+    
+    ret = dest.writeToFile(buffer, nbr, &nbw);
+    if (ret)
+      return -1;
+  }
   return 0;
 }
 
@@ -777,13 +777,43 @@
 int FilesUtility::deleteDirectory(const char *path)
 {
 #ifdef WIN32
-     return RemoveDirectory(path)?0:-1;
+  return RemoveDirectory(path)?0:-1;
 #else // NOT_WIN
   return rmdir(path);
 #endif
 }
 
+/*!
+ *Set the temporary path to a default one.
+ */
+void FilesUtility::resetTmpPath()
+{
+#ifdef WIN32
+  const char *tmpDir = getenv ("TMPDIR");
+  if (tmpDir)
+    tmpPath.assign (tmpDir);
+  else
+  {
+    TCHAR lpPathBuffer[MAX_PATH];
+    GetTempPath (MAX_PATH, lpPathBuffer);
+    tmpPath.assign (lpPathBuffer);
+  }
+#else
+  const char *tmpDir = getenv ("TMPDIR");
 
+#ifdef P_tmpdir
+  if (tmpDir == NULL)
+    tmpDir = P_tmpdir;
+#endif
+
+  if (tmpDir == NULL)
+    tmpDir = "/tmp";
+
+  tmpPath.assign (tmpDir);
+#endif
+}
+
+
 /*!
  *Create an unique temporary file name.  This function doesn't create the
  *file or open it but generates only its name.
@@ -798,6 +828,6 @@
   if(tmpPath.length() == 0)
     tmpPath.assign(getdefaultwd(0, 0));
 
-  stream << tmpPath << "/tmp_" << counter  << "_" << tid;
+  stream << tmpPath << "/myserver_" << counter  << "_" << tid << ".tmp";
   out.assign(stream.str());
 }

Modified: trunk/myserver/src/conf/vhost/vhost_manager.cpp
===================================================================
--- trunk/myserver/src/conf/vhost/vhost_manager.cpp     2008-10-19 16:31:51 UTC 
(rev 2892)
+++ trunk/myserver/src/conf/vhost/vhost_manager.cpp     2008-10-19 17:59:24 UTC 
(rev 2893)
@@ -25,8 +25,6 @@
  */
 int VhostManager::addVHost(Vhost* vh)
 {
-  Vhost* hostl;
-  
   list<Vhost*>::iterator it;
   
   mutex.lock();

Modified: trunk/myserver/src/http_handler/cgi/cgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/cgi/cgi.cpp 2008-10-19 16:31:51 UTC (rev 
2892)
+++ trunk/myserver/src/http_handler/cgi/cgi.cpp 2008-10-19 17:59:24 UTC (rev 
2893)
@@ -360,7 +360,7 @@
       int aliveProcess = 0;
       u_long ticks = getTicks() - procStartTime;
 
-      if (ticks >= cgiTimeout || 
+      if (ticks >= (u_long)cgiTimeout || 
           stdOutFile.waitForData ((cgiTimeout - ticks) / 1000, (cgiTimeout - 
ticks) % 1000) == 0)
       {
         ostringstream msg;

Modified: trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp 2008-10-19 16:31:51 UTC 
(rev 2892)
+++ trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp 2008-10-19 17:59:24 UTC 
(rev 2893)
@@ -67,8 +67,6 @@
   FiltersChain chain;
   u_long nbw;
 
-  u_long headerSize = 0;
-
   int exit;
   int ret;
 
@@ -77,8 +75,6 @@
   FastCgiServer* server = 0;
   int id;
   ostringstream cmdLine;
-  char *buffer = 0;
-
   string moreArg;
 
   con.useChunks = false;
@@ -242,7 +238,6 @@
   do
   {
     u_long dim;
-    u_long nbw;
     
     if (readHeader (&con, &header, initialTicks, timeout, id))
     {

Modified: trunk/myserver/src/protocol/http/http.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http.cpp   2008-10-19 16:31:51 UTC (rev 
2892)
+++ trunk/myserver/src/protocol/http/http.cpp   2008-10-19 17:59:24 UTC (rev 
2893)
@@ -350,8 +350,6 @@
 int Http::getFilePermissions(string& filename, string& directory, string& 
file, 
                              string &filenamePath, int yetmapped, int* 
permissions)
 {
-  int providedMask;
-
   securityToken.setServer (Server::getInstance ());
   securityToken.setSysDirectory 
((string*)&(td->connection->host->getSystemRoot ()));
 

Modified: trunk/myserver/src/server/server.cpp
===================================================================
--- trunk/myserver/src/server/server.cpp        2008-10-19 16:31:51 UTC (rev 
2892)
+++ trunk/myserver/src/server/server.cpp        2008-10-19 17:59:24 UTC (rev 
2893)
@@ -1119,12 +1119,14 @@
     cachedFiles.initialize(1 << 23);
 
   data = configurationFileManager.getValue("TEMP_DIRECTORY");
-  if(data)
+  if (data)
   {
-    string tmpPath(data);
-    FilesUtility::completePath(tmpPath);
-    FilesUtility::setTmpPath(tmpPath);
+    string tmpPath (data);
+    FilesUtility::completePath (tmpPath);
+    FilesUtility::setTmpPath (tmpPath);
   }
+  else
+    FilesUtility::resetTmpPath ();
 
   data = configurationFileManager.getValue("MAX_FILESCACHE_FILESIZE");
   if(data)






reply via email to

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