From 796985472a9f4c6722e8f89c40c42cfbbc13b79d Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Fri, 12 Feb 2010 17:05:32 +0000 Subject: [PATCH] added to config: parameter static_auth_dir_tmp with a path to directory for tmp files (for upload functino) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@572 e52654a7-88a9-db11-a3e9-0013d4bc506e --- content/upload.cpp | 14 +++----------- core/config.cpp | 5 +++-- core/data.h | 6 ++++-- core/log.cpp | 11 +++++++++++ core/log.h | 2 ++ core/postmultiparser.cpp | 4 ++-- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/content/upload.cpp b/content/upload.cpp index a0ccf0f..22ef4b5 100755 --- a/content/upload.cpp +++ b/content/upload.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include "content.h" #include "../core/request.h" #include "../core/data.h" @@ -66,18 +65,11 @@ struct stat sb; } else { - int err = errno; + int err = errno; // !! skasowac takze plik z bazy danych - log << log1 << "Content: can't move the tmp file from: " << tmp_filename; - log << log1 << ", to: " << path; - log << log1 << ", errno: " << err; - - const char * err_msg = strerror(err); - - if( err_msg ) - log << log1 << ": " << err_msg; - + log << log1 << "Content: can't move the tmp file from: " << tmp_filename << ", to: " << path << ", "; + log.SystemErr(err); log << logend; request.status = Error::permission_denied; diff --git a/core/config.cpp b/core/config.cpp index 7a136aa..41c2aea 100755 --- a/core/config.cpp +++ b/core/config.cpp @@ -107,8 +107,9 @@ void Config::AssignValues() else data.log_stdout = false; - data.post_file_max = Int("post_file_max", 8388608); // 8 MB - data.static_auth_dir = Text("static_auth_dir"); + data.post_file_max = Int("post_file_max", 8388608); // 8 MB + data.static_auth_dir = Text("static_auth_dir"); + data.static_auth_dir_tmp = Text("static_auth_dir_tmp"); data.templates_dir = Text("templates_dir"); data.templates_dir_default = Text("templates_dir_default"); diff --git a/core/data.h b/core/data.h index 341c7ce..d5abd40 100755 --- a/core/data.h +++ b/core/data.h @@ -115,6 +115,10 @@ public: // directory for static files (for fastcgi authorizer mode) std::string static_auth_dir; + // temporary dir for static content used by upload function + // should be on the same partition as static_auth_dir + std::string static_auth_dir_tmp; + // default locale: en pl std::string locale_str; @@ -124,8 +128,6 @@ public: // directory with default locale files (those from winix) std::string locale_dir_default; - - // below variables are based on the other config variables // base_url_prefix + base_server diff --git a/core/log.cpp b/core/log.cpp index 6a2eb30..d52bc29 100755 --- a/core/log.cpp +++ b/core/log.cpp @@ -9,6 +9,7 @@ #include "log.h" #include +#include Log::Log() @@ -179,6 +180,16 @@ return *this; } +void Log::SystemErr(int err) +{ + (*this) << "errno: " << err; + + const char * err_msg = strerror(err); + + if( err_msg ) + (*this) << " (" << err_msg << ")"; +} + void Log::SaveLog() { diff --git a/core/log.h b/core/log.h index e1fb948..fc3a2be 100755 --- a/core/log.h +++ b/core/log.h @@ -52,6 +52,8 @@ public: Log & operator<<(double s); Log & operator<<(Manipulators m); + void SystemErr(int err); + void SaveLog(); }; diff --git a/core/postmultiparser.cpp b/core/postmultiparser.cpp index 27ff5e6..26aa0e1 100755 --- a/core/postmultiparser.cpp +++ b/core/postmultiparser.cpp @@ -433,7 +433,7 @@ void PostMultiParser::CreateTmpFile() { char buf[100]; - sprintf(buf, "/tmp/winix_%u_%d_%u", (unsigned)getpid(), tmp_filename_postfix, rand()); + sprintf(buf, "%s/winix_%u_%d_%u", data.static_auth_dir_tmp.c_str(), (unsigned)getpid(), tmp_filename_postfix, rand()); tmp_filename_postfix += 1; tmp_file.open(buf, std::ios_base::binary | std::ios_base::out); @@ -542,7 +542,7 @@ Error PostMultiParser::Parse(FCGX_Stream * in_, PostTable & post_table_, PostFil post_table->clear(); post_file_table->clear(); - if( err != Error::input_too_large ) + if( err != Error::input_too_large && err != Error::cant_create_file ) log << log1 << "PMP: syntax error" << logend; }