*** empty log message ***

svn path=/trunk/boinc/; revision=5261
This commit is contained in:
Rom Walton 2005-02-01 00:54:06 +00:00
parent 60a503f955
commit e442d3ce7e
22 changed files with 356 additions and 130 deletions

View File

@ -23643,3 +23643,36 @@ David 31 Jan 2005
main.C,h
win/
win_service.cpp
Rom 31 Jan 2005
- Implement log files for the BOINC Manager
- Implement call stacks, and memory leak detection for the BOINC Manager
on Windows
- Implement log rotation for both the core client and manager
- Implement stderr and stdout redirects with the core client
- Make the manager start the core client with IO redirection enabled
- Cleanup some more memory leaks in the BOINC Manager
- Enabled the STL use of the debug heap on Windows
client/
client_state.C, .h
cs_cmdline.C
cs_files.C
file_names.h
main.C
client/win/
wingui_mainwindow.cpp
clientgui/
BOINCGUI.cpp, .h
LogBOINC.cpp, .h (Added)
Makefile.am
ViewProjects.cpp
ViewMessages.cpp
ViewResources.cpp
ViewTransfers.cpp
ViewWork.cpp
stdwx.h
lib/
diagnostics.C, .h
win_build/
BOINCGUI.vcproj

View File

@ -105,6 +105,7 @@ CLIENT_STATE::CLIENT_STATE() {
pers_retry_delay_max = PERS_RETRY_DELAY_MAX;
pers_giveup = PERS_GIVEUP;
executing_as_daemon = false;
redirect_io = false;
cpu_sched_last_time = 0;
cpu_sched_work_done_this_period = 0;
must_schedule_cpus = true;

View File

@ -121,6 +121,7 @@ public:
bool network_suspended;
bool executing_as_daemon;
bool size_overflow;
bool redirect_io;
private:
bool client_state_dirty;
@ -231,7 +232,6 @@ public:
// --------------- cs_files.C:
public:
void trunc_stderr_stdout();
bool start_new_file_xfer(PERS_FILE_XFER&);
private:
int make_project_dirs();

View File

@ -44,7 +44,8 @@ static void print_options(char* prog) {
" -update_prefs URL contact a project to update preferences\n"
" -run_cpu_benchmarks run the CPU benchmarks\n"
" -check_all_logins check input from remote users\n"
" -allow_remote_gui_rpc allow remote GUI RPC connections\n",
" -allow_remote_gui_rpc allow remote GUI RPC connections\n"
" -redirectio redirect stdout and stderr to log files\n",
prog
);
}
@ -67,6 +68,8 @@ void CLIENT_STATE::parse_cmdline(int argc, char** argv) {
check_all_logins = true;
} else if (ARG(daemon)) {
executing_as_daemon = true;
} else if (ARG(redirectio)) {
redirect_io = true;
} else if (ARG(return_results_immediately)) {
return_results_immediately = true;
} else if (ARG(skip_cpu_benchmarks)) {

View File

@ -69,26 +69,6 @@ bool CLIENT_STATE::start_new_file_xfer(PERS_FILE_XFER& pfx) {
return true;
}
void CLIENT_STATE::trunc_stderr_stdout() {
double f_size;
fflush(stdout);
fflush(stderr);
// If the stderr.txt or stdout.txt files are too big, reset them
// TODO: should we tell the user we're resetting these?
// TODO: should rotate files, not truncate!!
//
file_size(STDERR_FILE_NAME, f_size);
if (f_size > MAX_STDERR_FILE_SIZE) {
freopen(STDERR_FILE_NAME, "w", stderr);
}
file_size(STDOUT_FILE_NAME, f_size);
if (f_size > MAX_STDOUT_FILE_SIZE) {
freopen(STDOUT_FILE_NAME, "w", stdout);
}
}
// Make a directory for each of the projects in the client state
//
int CLIENT_STATE::make_project_dirs() {

View File

@ -43,9 +43,6 @@ extern int check_unique_instance();
extern void get_sched_request_filename(PROJECT&, char*);
extern void get_sched_reply_filename(PROJECT&, char*);
#define MAX_STDERR_FILE_SIZE 1024*1024
#define MAX_STDOUT_FILE_SIZE 1024*1024
#define PROJECTS_DIR "projects"
#define SLOTS_DIR "slots"
#define STATE_FILE_NEXT "client_state_next.xml"

View File

@ -83,6 +83,9 @@ void show_message(PROJECT *p, char* msg, int priority) {
char event_message[2048];
#endif
// Cycle the log files if we need to
diagnostics_cycle_logs();
strcpy(message, msg);
while (strlen(message)&&message[strlen(message)-1] == '\n') {
message[strlen(message)-1] = 0;
@ -233,14 +236,22 @@ void boinc_init(int argc, char** argv) {
gstate.parse_env_vars();
boinc_init_diagnostics(
BOINC_DIAG_DUMPCALLSTACKENABLED
| BOINC_DIAG_HEAPCHECKENABLED
| BOINC_DIAG_TRACETOSTDERR
#ifdef _WIN32
//| BOINC_DIAG_REDIRECTSTDERR
//| BOINC_DIAG_REDIRECTSTDOUT
#endif
// Initialize the BOINC Diagnostics Framework
int dwDiagnosticsFlags =
BOINC_DIAG_DUMPCALLSTACKENABLED |
BOINC_DIAG_HEAPCHECKENABLED |
BOINC_DIAG_TRACETOSTDOUT;
if (gstate.redirect_io || gstate.executing_as_daemon) {
dwDiagnosticsFlags |=
BOINC_DIAG_REDIRECTSTDERR |
BOINC_DIAG_REDIRECTSTDOUT;
}
diagnostics_init(
dwDiagnosticsFlags,
"stdoutdae",
"stderrdae"
);
retval = check_unique_instance();
@ -376,7 +387,7 @@ int main(int argc, char** argv) {
retval = boinc_main_loop();
}
#else
boinc_main_loop();
retval = boinc_main_loop();
#endif
#ifdef _WIN32

View File

@ -2165,11 +2165,6 @@ void CMainWindow::OnTimer(UINT uEventID) {
while(gstate.do_something(dtime()));
NetCheck(); // check if network connection can be terminated
// TODO: check this after writing a message, not here!!!
if ((counter % 10) == 0) {
gstate.trunc_stderr_stdout();
}
UpdateGUI(&gstate);
// Start the timer again

View File

@ -23,6 +23,7 @@
#include "stdwx.h"
#include "BOINCGUIApp.h"
#include "diagnostics.h"
#include "MainFrame.h"
#include "MainDocument.h"
@ -53,9 +54,31 @@ bool CBOINCGUIApp::OnInit()
m_hIdleDetectionDll = NULL;
#endif
// Enable Trace Masks
//wxLog::AddTraceMask( wxT("Function Start/End") );
// Initialize the BOINC Diagnostics Framework
int dwDiagnosticsFlags =
BOINC_DIAG_DUMPCALLSTACKENABLED |
BOINC_DIAG_HEAPCHECKENABLED |
BOINC_DIAG_MEMORYLEAKCHECKENABLED |
BOINC_DIAG_REDIRECTSTDERR |
BOINC_DIAG_REDIRECTSTDOUT |
BOINC_DIAG_TRACETOSTDOUT;
diagnostics_init(
dwDiagnosticsFlags,
"stdoutgui",
"stderrgui"
);
// Initialize the configuration storage module
m_pConfig = new wxConfig(GetAppName());
wxConfigBase::Set(m_pConfig);
wxASSERT(NULL != m_pConfig);
// Enable Logging and Trace Masks
m_pLog = new wxLogBOINC();
wxLog::SetActiveTarget(m_pLog);
m_pLog->AddTraceMask( wxT("Function Start/End") );
// Enable the in memory virtual file system for
// storing images
@ -64,10 +87,6 @@ bool CBOINCGUIApp::OnInit()
// Enable known image types
wxImage::AddHandler(new wxXPMHandler);
// Commandline parsing is done in wxApp::OnInit()
if (!wxApp::OnInit())
return false;
// Initialize the internationalization module
m_pLocale = new wxLocale();
wxASSERT(NULL != m_pLocale);
@ -77,10 +96,9 @@ bool CBOINCGUIApp::OnInit()
m_pLocale->AddCatalogLookupPathPrefix(wxT("locale"));
m_pLocale->AddCatalog(GetAppName());
// Initialize the configuration storage module
m_pConfig = new wxConfig(GetAppName());
wxConfigBase::Set(m_pConfig);
wxASSERT(NULL != m_pConfig);
// Commandline parsing is done in wxApp::OnInit()
if (!wxApp::OnInit())
return false;
// Initialize the main document
m_pDocument = new CMainDocument();
@ -258,7 +276,7 @@ void CBOINCGUIApp::StartupBOINCCore()
#ifdef __WXMSW__
// Append boinc.exe to the end of the strExecute string and get ready to rock
strExecute += wxT("\\boinc.exe");
strExecute += wxT("\\boinc.exe -redirectio");
PROCESS_INFORMATION pi;
STARTUPINFO si;

View File

@ -25,6 +25,7 @@
#endif
#include "LogBOINC.h"
#include "MainFrame.h"
#include "MainDocument.h"
#ifndef NOTASKBAR
@ -52,8 +53,9 @@ protected:
wxInt32 StartupSystemIdleDetection();
wxInt32 ShutdownSystemIdleDetection();
wxLocale* m_pLocale;
wxConfig* m_pConfig;
wxLocale* m_pLocale;
wxLogBOINC* m_pLog;
CMainFrame* m_pFrame;
CMainDocument* m_pDocument;

40
clientgui/LogBOINC.cpp Normal file
View File

@ -0,0 +1,40 @@
// Berkeley Open Infrastructure for Network Computing
// http://boinc.berkeley.edu
// Copyright (C) 2005 University of California
//
// This is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation;
// either version 2.1 of the License, or (at your option) any later version.
//
// This software 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 Lesser General Public License for more details.
//
// To view the GNU Lesser General Public License visit
// http://www.gnu.org/copyleft/lesser.html
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "LogBOINC.h"
#endif
#include "stdwx.h"
#include "BOINCGUIApp.h"
#include "diagnostics.h"
#include "LogBOINC.h"
wxLogBOINC::wxLogBOINC()
{
m_fp = stdout;
}
void wxLogBOINC::DoLogString(const wxChar *szString, time_t t)
{
diagnostics_cycle_logs();
wxLogStderr::DoLogString(szString, t);
}

40
clientgui/LogBOINC.h Normal file
View File

@ -0,0 +1,40 @@
// Berkeley Open Infrastructure for Network Computing
// http://boinc.berkeley.edu
// Copyright (C) 2005 University of California
//
// This is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation;
// either version 2.1 of the License, or (at your option) any later version.
//
// This software 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 Lesser General Public License for more details.
//
// To view the GNU Lesser General Public License visit
// http://www.gnu.org/copyleft/lesser.html
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef _LOGBOINC_H_
#define _LOGBOINC_H_
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "LogBOINC.cpp"
#endif
class wxLogBOINC : public wxLogStderr
{
DECLARE_NO_COPY_CLASS(wxLogBOINC)
public:
wxLogBOINC();
protected:
virtual void DoLogString(const wxChar *szString, time_t t);
};
#endif

View File

@ -16,6 +16,7 @@ boinc_gui_SOURCES = \
DlgAttachProject.cpp \
DlgConnection.cpp \
DlgOptions.cpp \
LogBOINC.cpp \
MainDocument.cpp \
MainFrame.cpp \
stdwx.cpp \

View File

@ -197,6 +197,8 @@ CViewMessages::CViewMessages(wxNotebook* pNotebook) :
CViewMessages::~CViewMessages()
{
EmptyCache();
if ( m_pMessageInfoAttr )
{
delete m_pMessageInfoAttr;

View File

@ -299,6 +299,7 @@ CViewProjects::CViewProjects(wxNotebook* pNotebook) :
CViewProjects::~CViewProjects()
{
EmptyCache();
}

View File

@ -144,6 +144,7 @@ CViewResources::CViewResources(wxNotebook* pNotebook) :
CViewResources::~CViewResources()
{
EmptyCache();
}

View File

@ -246,6 +246,7 @@ CViewTransfers::CViewTransfers(wxNotebook* pNotebook) :
CViewTransfers::~CViewTransfers()
{
EmptyCache();
}

View File

@ -273,6 +273,7 @@ CViewWork::CViewWork(wxNotebook* pNotebook) :
CViewWork::~CViewWork()
{
EmptyCache();
}

View File

@ -125,6 +125,9 @@
// C++ headers
#ifdef __WXMSW__
#include <xdebug>
#endif
#include <algorithm>
#include <stdexcept>
#include <string>

View File

@ -40,83 +40,36 @@
#include "filesys.h"
#include "util.h"
static int flags;
#define MAX_STDERR_FILE_SIZE 2048*1024
#define MAX_STDOUT_FILE_SIZE 2048*1024
static int flags;
static char stdout_log[256];
static char stdout_archive[256];
static FILE* stdout_file;
static char stderr_log[256];
static char stderr_archive[256];
static FILE* stderr_file;
#ifdef _WIN32
LONG CALLBACK boinc_catch_signal(EXCEPTION_POINTERS *ExceptionInfo);
int __cdecl boinc_message_reporting( int reportType, char *szMsg, int *retVal );
#else
static void boinc_catch_signal(int signal);
//static void boinc_quit(int sig);
#endif
// initialize the diagnostics environment.
// stub function for initializing the diagnostics environment.
//
int boinc_init_diagnostics(int _flags) {
void* lpRetVal;
flags = _flags;
// Archive any old stderr.txt and stdout.txt files, if requested
if ( flags & BOINC_DIAG_ARCHIVESTDERR ) {
boinc_copy(BOINC_DIAG_STDERR, BOINC_DIAG_STDERROLD);
}
if ( flags & BOINC_DIAG_ARCHIVESTDOUT) {
boinc_copy( BOINC_DIAG_STDOUT, BOINC_DIAG_STDOUTOLD );
}
// Redirect stderr and/or stdout streams, if requested
if (flags & BOINC_DIAG_REDIRECTSTDERR ) {
lpRetVal = (void*) freopen(BOINC_DIAG_STDERR, "a", stderr);
if ( NULL == lpRetVal ) {
return ERR_FOPEN;
}
}
if (flags & BOINC_DIAG_REDIRECTSTDERROVERWRITE ) {
lpRetVal = (void*) freopen(BOINC_DIAG_STDERR, "w", stderr);
if ( NULL == lpRetVal ) {
return ERR_FOPEN;
}
}
if (flags & BOINC_DIAG_REDIRECTSTDOUT ) {
lpRetVal = (void*) freopen(BOINC_DIAG_STDOUT, "a", stdout);
if ( NULL == lpRetVal ) {
return ERR_FOPEN;
}
}
if (flags & BOINC_DIAG_REDIRECTSTDOUTOVERWRITE ) {
lpRetVal = (void*) freopen(BOINC_DIAG_STDOUT, "w", stdout);
if ( NULL == lpRetVal ) {
return ERR_FOPEN;
}
}
#if defined(_WIN32) && defined(_DEBUG)
_CrtSetReportHook( boinc_message_reporting );
if (flags & BOINC_DIAG_MEMORYLEAKCHECKENABLED )
SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF );
if (flags & BOINC_DIAG_HEAPCHECKENABLED )
SET_CRT_DEBUG_FIELD( _CRTDBG_CHECK_EVERY_1024_DF );
#endif // defined(_WIN32) && defined(_DEBUG)
// Install unhandled exception filters and signal traps.
if ( BOINC_SUCCESS != boinc_install_signal_handlers() ) {
return ERR_SIGNAL_OP;
}
return BOINC_SUCCESS;
return diagnostics_init( _flags, BOINC_DIAG_STDOUT, BOINC_DIAG_STDERR );
}
@ -149,6 +102,123 @@ int boinc_install_signal_handlers() {
}
// initialize the diagnostics environment.
//
int diagnostics_init(int _flags, char* stdout_prefix, char* stderr_prefix) {
flags = _flags;
snprintf(stdout_log, sizeof(stdout_log), "%s.txt", stdout_prefix);
snprintf(stdout_archive, sizeof(stdout_archive), "%s.old", stdout_prefix);
snprintf(stderr_log, sizeof(stderr_log), "%s.txt", stderr_prefix);
snprintf(stderr_archive, sizeof(stderr_archive), "%s.old", stderr_prefix);
// Check for invalid parameter combinations
if ( ( flags & BOINC_DIAG_REDIRECTSTDERR ) && ( flags & BOINC_DIAG_REDIRECTSTDERROVERWRITE ) ) {
return ERR_INVALID_PARAM;
}
if ( ( flags & BOINC_DIAG_REDIRECTSTDOUT ) && ( flags & BOINC_DIAG_REDIRECTSTDOUTOVERWRITE ) ) {
return ERR_INVALID_PARAM;
}
// Archive any old stderr.txt and stdout.txt files, if requested
if ( flags & BOINC_DIAG_ARCHIVESTDERR ) {
boinc_copy(stderr_log, stderr_archive);
}
if ( flags & BOINC_DIAG_ARCHIVESTDOUT) {
boinc_copy( stdout_log, stdout_archive );
}
// Redirect stderr and/or stdout streams, if requested
if (flags & BOINC_DIAG_REDIRECTSTDERR ) {
stderr_file = freopen(stderr_log, "a", stderr);
if ( NULL == stderr_file ) {
return ERR_FOPEN;
}
}
if (flags & BOINC_DIAG_REDIRECTSTDERROVERWRITE ) {
stderr_file = freopen(stderr_log, "w", stderr);
if ( NULL == stderr_file ) {
return ERR_FOPEN;
}
}
if (flags & BOINC_DIAG_REDIRECTSTDOUT ) {
stdout_file = freopen(stdout_log, "a", stdout);
if ( NULL == stdout_file ) {
return ERR_FOPEN;
}
}
if (flags & BOINC_DIAG_REDIRECTSTDOUTOVERWRITE ) {
stdout_file = freopen(stdout_log, "w", stdout);
if ( NULL == stdout_file ) {
return ERR_FOPEN;
}
}
#if defined(_WIN32) && defined(_DEBUG)
_CrtSetReportHook( boinc_message_reporting );
if (flags & BOINC_DIAG_MEMORYLEAKCHECKENABLED )
SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF );
if (flags & BOINC_DIAG_HEAPCHECKENABLED )
SET_CRT_DEBUG_FIELD( _CRTDBG_CHECK_EVERY_1024_DF );
#endif // defined(_WIN32) && defined(_DEBUG)
// Install unhandled exception filters and signal traps.
if ( BOINC_SUCCESS != boinc_install_signal_handlers() ) {
return ERR_SIGNAL_OP;
}
return BOINC_SUCCESS;
}
// Cycle the log files at regular events.
//
int diagnostics_cycle_logs() {
double f_size;
fflush(stdout);
fflush(stderr);
// If the stderr.txt or stdout.txt files are too big, cycle them
//
if (flags & BOINC_DIAG_REDIRECTSTDERR) {
file_size(stderr_log, f_size);
if (MAX_STDERR_FILE_SIZE < f_size) {
fclose( stderr_file );
boinc_copy(stderr_log, stderr_archive);
stderr_file = freopen( stderr_log, "w", stderr );
if ( NULL == stderr_file ) return ERR_FOPEN;
}
}
if (flags & BOINC_DIAG_REDIRECTSTDOUT) {
file_size(stdout_log, f_size);
if (MAX_STDOUT_FILE_SIZE < f_size) {
fclose( stdout_file );
boinc_copy( stdout_log, stdout_archive );
stdout_file = freopen( stdout_log, "w", stdout );
if ( NULL == stdout_file ) return ERR_FOPEN;
}
}
return BOINC_SUCCESS;
}
#ifdef _WIN32
// Used to unwind the stack and spew the callstack to stderr. Terminate the
@ -495,13 +565,6 @@ void boinc_catch_signal(int signal) {
}
/*
void boinc_quit(int sig) {
signal(SIGQUIT, boinc_quit); // reset signal
time_to_quit = true;
}
*/
#endif
const char *BOINC_RCSID_4967ad204c = "$Id$";

View File

@ -48,10 +48,8 @@
// filenames
//
#define BOINC_DIAG_STDERR "stderr.txt"
#define BOINC_DIAG_STDERROLD "stderr.old"
#define BOINC_DIAG_STDOUT "stdout.txt"
#define BOINC_DIAG_STDOUTOLD "stdout.old"
#define BOINC_DIAG_STDERR "stderr"
#define BOINC_DIAG_STDOUT "stdout"
#ifdef _WIN32
@ -103,8 +101,10 @@ void boinc_info_release(const char *pszFormat, ...);
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
extern void boinc_set_signal_handler(int sig, void(*handler)(int));
extern void boinc_set_signal_handler_force(int sig, void(*handler)(int));
extern void boinc_set_signal_handler(int sig, void(*handler)(int));
extern void boinc_set_signal_handler_force(int sig, void(*handler)(int));
#ifdef __cplusplus
}
#endif // __cplusplus
@ -136,6 +136,9 @@ extern int boinc_init_diagnostics(int flags);
extern int boinc_finish_diag();
extern int boinc_install_signal_handlers();
extern int diagnostics_init(int flags, char* stdout_prefix, char* stderr_prefix);
extern int diagnostics_cycle_logs();
#ifdef __cplusplus
}
#endif

View File

@ -159,6 +159,21 @@
<File
RelativePath="..\clientgui\BOINCTaskCtrl.cpp">
</File>
<File
RelativePath="..\lib\diagnostics.C">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
CompileAs="2"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
CompileAs="2"/>
</FileConfiguration>
</File>
<File
RelativePath="..\clientgui\DlgAbout.cpp">
</File>
@ -217,6 +232,9 @@
CompileAs="2"/>
</FileConfiguration>
</File>
<File
RelativePath="..\clientgui\LogBOINC.cpp">
</File>
<File
RelativePath="..\clientgui\MainDocument.cpp">
</File>
@ -310,6 +328,9 @@
CompileAs="2"/>
</FileConfiguration>
</File>
<File
RelativePath="..\lib\stackwalker_win.cpp">
</File>
<File
RelativePath="..\clientgui\stdwx.cpp">
<FileConfiguration
@ -398,6 +419,9 @@
<File
RelativePath="..\clientgui\BOINCTaskCtrl.h">
</File>
<File
RelativePath="..\lib\diagnostics.h">
</File>
<File
RelativePath="..\clientgui\DlgAbout.h">
</File>
@ -422,6 +446,9 @@
<File
RelativePath="..\lib\gui_rpc_client.h">
</File>
<File
RelativePath="..\clientgui\LogBOINC.h">
</File>
<File
RelativePath="..\clientgui\MainDocument.h">
</File>
@ -446,6 +473,9 @@
<File
RelativePath="..\clientgui\resource.h">
</File>
<File
RelativePath="..\lib\stackwalker_win.h">
</File>
<File
RelativePath="..\clientgui\stdwx.h">
</File>