From 6b763cd77646ef945b20d83605f9b5edd02f3c48 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Sun, 29 Feb 2004 00:50:05 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=3014 --- api/boinc_diagnostics.C | 422 ++++++++++++++++++++++++++++++++++++++++ api/boinc_diagnostics.h | 134 +++++++++++++ api/boinc_exception.C | 123 ++++++++++++ api/boinc_exception.h | 153 +++++++++++++++ checkin_notes | 13 ++ lib/filesys.C | 5 +- 6 files changed, 849 insertions(+), 1 deletion(-) create mode 100644 api/boinc_diagnostics.C create mode 100644 api/boinc_diagnostics.h create mode 100644 api/boinc_exception.C create mode 100644 api/boinc_exception.h diff --git a/api/boinc_diagnostics.C b/api/boinc_diagnostics.C new file mode 100644 index 0000000000..6cb73814ee --- /dev/null +++ b/api/boinc_diagnostics.C @@ -0,0 +1,422 @@ +// The contents of this file are subject to the BOINC Public License +// Version 1.0 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://boinc.berkeley.edu/license_1.0.txt +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// +// The Initial Developer of the Original Code is the SETI@home project. +// Portions created by the SETI@home project are Copyright (C) 2002 +// University of California at Berkeley. All Rights Reserved. +// +// Contributor(s): +// + +#ifdef _WIN32 +#include +#include "win/Stackwalker.h" +#endif + +#include +#include +#include +#include + +#include "boinc_diagnostics.h" +#include "app_ipc.h" +#include "util.h" + + +// **************************************************************************** +// **************************************************************************** +// +// Externally defined functions used by the diagnostics library +// +// **************************************************************************** +// **************************************************************************** + +extern bool boinc_is_standalone(); +extern bool boinc_is_verbose(); + + +// **************************************************************************** +// **************************************************************************** +// +// Diagnostics Support for Windows 95/98/ME/2000/XP/2003 +// +// **************************************************************************** +// **************************************************************************** + +#ifdef _WIN32 + +// Forward declare implementation specific functions - Windows Platform Only. +LONG CALLBACK boinc_catch_signal(EXCEPTION_POINTERS *ExceptionInfo); +int __cdecl boinc_message_reporting( int reportType, char *szMsg, int *retVal ); + + +// +// Function: boinc_init_diag +// +// Purpose: Used to initialize the diagnostics environment. +// +// Date: 02/05/04 +// +int boinc_init_diag() { + + LPVOID lpErrorTrap = NULL; + + lpErrorTrap = (LPVOID) freopen(STDERR_FILE, "a", stderr); + if ( NULL == lpErrorTrap ) + throw boinc_file_operation_exception(__FILE__, __LINE__, "Failed to reopen stderr for diagnostics redirection"); + +#ifdef _DEBUG + _CrtSetReportHook( boinc_message_reporting ); +#endif + + return BOINC_SUCCESS; +} + + +// +// Function: boinc_finish_diag +// +// Purpose: Used to cleanup the diagnostics environment. +// +// Date: 02/05/04 +// +int boinc_finish_diag() { + return BOINC_SUCCESS; +} + + +// +// Function: boinc_install_signal_handlers +// +// Purpose: Used to setup an unhandled exception filter on Windows +// +// Date: 02/05/04 +// +int boinc_install_signal_handlers() { + + SetUnhandledExceptionFilter( boinc_catch_signal ); + + return BOINC_SUCCESS; +} + +// +// Function: boinc_catch_signal +// +// Purpose: Used to unwind the stack and spew the callstack to stderr. Terminate the +// process afterwards and return the exception code as the exit code. +// +// Date: 02/05/04 +// +LONG CALLBACK boinc_catch_signal(EXCEPTION_POINTERS *pExPtrs) { + + // Snagged from the latest stackwalker code base. This allows us to grab + // callstacks even in a stack overflow scenario + if ( pExPtrs->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW ) + { + static char MyStack[1024*128]; // be sure that we have enought space... + // it assumes that DS and SS are the same!!! (this is the case for Win32) + // change the stack only if the selectors are the same (this is the case for Win32) + //__asm push offset MyStack[1024*128]; + //__asm pop esp; + __asm mov eax,offset MyStack[1024*128]; + __asm mov esp,eax; + } + + PVOID exceptionAddr = pExPtrs->ExceptionRecord->ExceptionAddress; + DWORD exceptionCode = pExPtrs->ExceptionRecord->ExceptionCode; + + LONG lReturnValue = NULL; + char status[256]; + char substatus[256]; + + static long lDetectNestedException = 0; + + // If we've been in this procedure before, something went wrong so we immediately exit + if ( InterlockedIncrement(&lDetectNestedException) > 1 ) { + TerminateProcess( GetCurrentProcess(), BOINC_NESTED_UNHANDLED_EXCEPTION_DETECTED ); + } + + switch ( exceptionCode ) { + case EXCEPTION_ACCESS_VIOLATION: + safe_strncpy( status, "Access Violation", sizeof(status) ); + if ( pExPtrs->ExceptionRecord->NumberParameters == 2 ) { + switch( pExPtrs->ExceptionRecord->ExceptionInformation[0] ) { + case 0: // read attempt + sprintf( substatus, "read attempt to address 0x%8.8X", pExPtrs->ExceptionRecord->ExceptionInformation[1] ); + break; + case 1: // write attempt + sprintf( substatus, "write attempt to address 0x%8.8X", pExPtrs->ExceptionRecord->ExceptionInformation[1] ); + break; + } + } + break; + case EXCEPTION_DATATYPE_MISALIGNMENT: + safe_strncpy( status, "Data Type Misalignment", sizeof(status) ); + break; + case EXCEPTION_BREAKPOINT: + safe_strncpy( status, "Breakpoint Encountered", sizeof(status) ); + break; + case EXCEPTION_SINGLE_STEP: + safe_strncpy( status, "Single Instruction Executed", sizeof(status) ); + break; + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + safe_strncpy( status, "Array Bounds Exceeded", sizeof(status) ); + break; + case EXCEPTION_FLT_DENORMAL_OPERAND: + safe_strncpy( status, "Float Denormal Operand", sizeof(status) ); + break; + case EXCEPTION_FLT_DIVIDE_BY_ZERO: + safe_strncpy( status, "Divide by Zero", sizeof(status) ); + break; + case EXCEPTION_FLT_INEXACT_RESULT: + safe_strncpy( status, "Float Inexact Result", sizeof(status) ); + break; + case EXCEPTION_FLT_INVALID_OPERATION: + safe_strncpy( status, "Float Invalid Operation", sizeof(status) ); + break; + case EXCEPTION_FLT_OVERFLOW: + safe_strncpy( status, "Float Overflow", sizeof(status) ); + break; + case EXCEPTION_FLT_STACK_CHECK: + safe_strncpy( status, "Float Stack Check", sizeof(status) ); + break; + case EXCEPTION_FLT_UNDERFLOW: + safe_strncpy( status, "Float Underflow", sizeof(status) ); + break; + case EXCEPTION_INT_DIVIDE_BY_ZERO: + safe_strncpy( status, "Integer Divide by Zero", sizeof(status) ); + break; + case EXCEPTION_INT_OVERFLOW: + safe_strncpy( status, "Integer Overflow", sizeof(status) ); + break; + case EXCEPTION_PRIV_INSTRUCTION: + safe_strncpy( status, "Privileged Instruction", sizeof(status) ); + break; + case EXCEPTION_IN_PAGE_ERROR: + safe_strncpy( status, "In Page Error", sizeof(status) ); + break; + case EXCEPTION_ILLEGAL_INSTRUCTION: + safe_strncpy( status, "Illegal Instruction", sizeof(status) ); + break; + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + safe_strncpy( status, "Noncontinuable Exception", sizeof(status) ); + break; + case EXCEPTION_STACK_OVERFLOW: + safe_strncpy( status, "Stack Overflow", sizeof(status) ); + break; + case EXCEPTION_INVALID_DISPOSITION: + safe_strncpy( status, "Invalid Disposition", sizeof(status) ); + break; + case EXCEPTION_GUARD_PAGE: + safe_strncpy( status, "Guard Page Violation", sizeof(status) ); + break; + case EXCEPTION_INVALID_HANDLE: + safe_strncpy( status, "Invalid Handle", sizeof(status) ); + break; + case CONTROL_C_EXIT: + safe_strncpy( status, "Ctrl+C Exit", sizeof(status) ); + break; + default: + safe_strncpy( status, "Unknown exception", sizeof(status) ); + break; + } + + fprintf( stderr, "\n***UNHANDLED EXCEPTION****\n" ); + if ( EXCEPTION_ACCESS_VIOLATION == exceptionCode ) { + fprintf( stderr, "Reason: %s (0x%x) at address 0x%p %s\n\n", status, exceptionCode, exceptionAddr, substatus ); + } else { + fprintf( stderr, "Reason: %s (0x%x) at address 0x%p\n\n", status, exceptionCode, exceptionAddr ); + } + fflush( stderr ); + + // Unwind the stack and spew it to stderr + StackwalkFilter( pExPtrs, EXCEPTION_EXECUTE_HANDLER, NULL ); + + fprintf( stderr, "Exiting...\n" ); + fflush( stderr ); + + // Force terminate the app letting BOINC know an unknown exception has occurred. + TerminateProcess( GetCurrentProcess(), pExPtrs->ExceptionRecord->ExceptionCode ); + + // We won't make it to this point, but make the compiler happy anyway. + return 1; +} + + +#ifdef _DEBUG + +// +// Function: boinc_message_reporting +// +// Purpose: Trap ASSERTs and TRACEs from the CRT and spew them to stderr. +// +// Date: 02/05/04 +// +int __cdecl boinc_message_reporting( int reportType, char *szMsg, int *retVal ){ + (*retVal) = 0; + + switch(reportType){ + + case _CRT_WARN: + case _CRT_ERROR: + OutputDebugString(szMsg); // Reports string to the debugger output window + fprintf( stderr, "%s", szMsg ); + fflush( stderr ); + break; + case _CRT_ASSERT: + fprintf( stderr, "ASSERT: %s\n", szMsg ); + fflush( stderr ); + (*retVal) = 1; + break; + + } + + return(TRUE); +} + + +// +// Function: boinc_trace +// +// Purpose: Converts the BOINCTRACE macro into a single string and report it +// to the CRT so it can be reported via the normal means. +// +// Date: 02/05/04 +// +void boinc_trace(const char *pszFormat, ...) +{ + static char szBuffer[1024]; + + // Trace messages should only be reported if running as a standalone + // application or told too. + if ( boinc_is_standalone() || boinc_is_verbose() ) { + + memset(szBuffer, 0, sizeof(szBuffer)); + + va_list ptr; + va_start(ptr, pszFormat); + + BOINCASSERT( -1 != _vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, ptr) ); + + va_end(ptr); + + _CrtDbgReport(_CRT_WARN, NULL, NULL, NULL, "TRACE: %s", szBuffer); + } +} + + +// +// Function: boinc_info_debug +// +// Purpose: Converts the BOINCINFO macro into a single string and report it +// to stderr so it can be reported via the normal means. +// +// Date: 02/05/04 +// +void boinc_info_debug(const char *pszFormat, ...) +{ + static char szBuffer[1024]; + + memset(szBuffer, 0, sizeof(szBuffer)); + + va_list ptr; + va_start(ptr, pszFormat); + + BOINCASSERT( -1 != _vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, ptr) ); + + va_end(ptr); + + _CrtDbgReport(_CRT_WARN, NULL, NULL, NULL, "%s", szBuffer); +} + + +#else // _DEBUG + +// +// Function: boinc_info_release +// +// Purpose: Converts the BOINCINFO macro into a single string and report it +// to stderr so it can be reported via the normal means. +// +// Date: 02/05/04 +// +void boinc_info_release(const char *pszFormat, ...) +{ + static char szBuffer[1024]; + + memset(szBuffer, 0, sizeof(szBuffer)); + + va_list ptr; + va_start(ptr, pszFormat); + + _vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, ptr); + + va_end(ptr); + + fprintf( stderr, "%s", szBuffer ); + fflush( stderr ); +} + +#endif // _DEBUG + +#endif // _WIN32 + + +// **************************************************************************** +// **************************************************************************** +// +// Diagnostics for POSIX Compatible systems. +// +// **************************************************************************** +// **************************************************************************** + +#ifdef HAVE_SIGNAL_H + +// Forward declare implementation specific functions - POSIX Platform Only. +void boinc_catch_signal(int signal); +void boinc_quit(int sig); + +int boinc_install_signal_handlers() { + signal(SIGHUP, boinc_catch_signal); // terminal line hangup + signal(SIGINT, boinc_catch_signal); // interrupt program + signal(SIGQUIT, boinc_quit); // quit program + signal(SIGILL, boinc_catch_signal); // illegal instruction + signal(SIGABRT, boinc_catch_signal); // abort(2) call + signal(SIGBUS, boinc_catch_signal); // bus error + signal(SIGSEGV, boinc_catch_signal); // segmentation violation + signal(SIGSYS, boinc_catch_signal); // system call given invalid argument + signal(SIGPIPE, boinc_catch_signal); // write on a pipe with no reader + return 0; +} + +void boinc_catch_signal(int signal) { + switch(signal) { + case SIGHUP: fprintf(stderr, "SIGHUP: terminal line hangup"); break; + case SIGINT: fprintf(stderr, "SIGINT: interrupt program"); break; + case SIGILL: fprintf(stderr, "SIGILL: illegal instruction"); break; + case SIGABRT: fprintf(stderr, "SIGABRT: abort called"); break; + case SIGBUS: fprintf(stderr, "SIGBUS: bus error"); break; + case SIGSEGV: fprintf(stderr, "SIGSEGV: segmentation violation"); break; + case SIGSYS: fprintf(stderr, "SIGSYS: system call given invalid argument"); break; + case SIGPIPE: fprintf(stderr, "SIGPIPE: write on a pipe with no reader"); break; + default: fprintf(stderr, "unknown signal %d", signal); break; + } + fprintf(stderr, "\nExiting...\n"); + exit(ERR_SIGNAL_CATCH); +} + +void boinc_quit(int sig) { + signal(SIGQUIT, boinc_quit); // reset signal + time_to_quit = true; +} + +#endif diff --git a/api/boinc_diagnostics.h b/api/boinc_diagnostics.h new file mode 100644 index 0000000000..2638abbd4e --- /dev/null +++ b/api/boinc_diagnostics.h @@ -0,0 +1,134 @@ +// The contents of this file are subject to the BOINC Public License +// Version 1.0 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://boinc.berkeley.edu/license_1.0.txt +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// +// The Initial Developer of the Original Code is the SETI@home project. +// Portions created by the SETI@home project are Copyright (C) 2002 +// University of California at Berkeley. All Rights Reserved. +// +// Contributor(s): +// + +#ifndef _BOINC_DIAGNOSTICS_ +#define _BOINC_DIAGNOSTICS_ + + +#ifdef _WIN32 +#include +#endif + +#include + +#include "boinc_exception.h" + + +// **************************************************************************** +// **************************************************************************** +// +// Diagnostics Support for Windows 95/98/ME/2000/XP/2003 +// +// **************************************************************************** +// **************************************************************************** + +#ifdef _WIN32 + +// +// Define macros for both debug and release builds. +// +// We are using the native debugging technology built into the Microsoft +// C Runtime Libraries to trap and report the asserts and traces. +// + +#ifdef _DEBUG + +// Forward declare so we can assign a macro to it. + +void boinc_trace(const char *pszFormat, ...); +void boinc_info_debug(const char *pszFormat, ...); + +#define BOINCASSERT(expr) _ASSERT_BASE((expr), #expr) +#define BOINCTRACE boinc_trace +#define BOINCINFO boinc_info_debug +#define BOINCERROR( err, errmsg ) \ + throw #err( __FILE__, __LINE__, errmsg ) + + +#else // _DEBUG + +// Forward declare so we can assign a macro to it. +void boinc_info_release(const char *pszFormat, ...); + +#define BOINCASSERT(expr) ((void)0) +#define BOINCTRACE ((void)0) +#define BOINCINFO boinc_info_release +#define BOINCERROR( err, errmsg ) \ + throw #err( errmsg ) + +#endif // _DEBUG + +#endif // _WIN32 + + +// **************************************************************************** +// **************************************************************************** +// +// Diagnostics Support for Undefined Platform +// +// **************************************************************************** +// **************************************************************************** +#ifndef BOINCASSERT +#define BOINCASSERT assert +#endif + +#ifndef BOINCTRACE +#define BOINCTRACE ((int)0) +#endif + +#ifndef BOINCINFO +#define BOINCINFO ((int)0) +#endif + +#ifndef BOINCERROR +#define BOINCERROR ((int)0) +#endif + + +// **************************************************************************** +// **************************************************************************** +// +// Diagnostics Functions +// +// **************************************************************************** +// **************************************************************************** + +int boinc_init_diag(); +int boinc_finish_diag(); + +int boinc_install_signal_handlers(); + + +// **************************************************************************** +// **************************************************************************** +// +// Diagnostics Functions +// +// **************************************************************************** +// **************************************************************************** + +#define BOINC_SUCCESS 0 +#define BOINC_NESTED_UNHANDLED_EXCEPTION_DETECTED -1000 +#define BOINC_OUT_OF_MEMORY boinc_out_of_memory_exception +#define BOINC_INVALID_PARAMETER boinc_invalid_parameter_exception +#define BOINC_FILE_OPERATION_FAILED boinc_file_operation_exception +#define BOINC_SIGNAL_OPERATION_FAILED boinc_signal_operation_exception + + +#endif diff --git a/api/boinc_exception.C b/api/boinc_exception.C new file mode 100644 index 0000000000..a879857277 --- /dev/null +++ b/api/boinc_exception.C @@ -0,0 +1,123 @@ +// The contents of this file are subject to the BOINC Public License +// Version 1.0 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://boinc.berkeley.edu/license_1.0.txt +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// +// The Initial Developer of the Original Code is the SETI@home project. +// Portions created by the SETI@home project are Copyright (C) 2002 +// University of California at Berkeley. All Rights Reserved. +// +// Contributor(s): +// + + +#include "boinc_exception.h" +#include "error_numbers.h" + + +// **************************************************************************** +// **************************************************************************** +// +// BOINC Base Exception Class Implementation +// +// **************************************************************************** +// **************************************************************************** + +const char * boinc_base_exception::ErrorType() + { return "BOINC Exception"; } + +const char * boinc_base_exception::ErrorMessage() + { return "Unknown Exception"; } + +long boinc_base_exception::ErrorValue() + { return -1; } + +const char * boinc_base_exception::what() +{ + m_strErrorBuffer.empty(); + + memset(m_szConversionBuffer, '\0', sizeof(m_szConversionBuffer)); + ltoa(ErrorValue(), m_szConversionBuffer, 10); + + m_strErrorBuffer.append(ErrorType()); + m_strErrorBuffer.append(" "); + m_strErrorBuffer.append(m_szConversionBuffer); + m_strErrorBuffer.append(" "); + m_strErrorBuffer.append(ErrorMessage()); + + m_strErrorBuffer.append("\n"); + + m_strErrorBuffer.append(m_strErrorData); + + m_strErrorBuffer.append("\n"); + + m_strErrorBuffer.append("Filename: '"); + m_strErrorBuffer.append(m_strFilename); + m_strErrorBuffer.append("'\n"); + + memset(m_szConversionBuffer, '\0', sizeof(m_szConversionBuffer)); + ltoa(m_lLineNumber, m_szConversionBuffer, 10); + + m_strErrorBuffer.append("Line: '"); + m_strErrorBuffer.append(m_szConversionBuffer); + m_strErrorBuffer.append("'\n"); + + return m_strErrorBuffer.c_str(); +} + + +// **************************************************************************** +// **************************************************************************** +// +// BOINC Base Runtime Exception Class Implementation +// +// **************************************************************************** +// **************************************************************************** + +const char * boinc_runtime_base_exception::ErrorType() + { return "BOINC Runtime Exception"; } + +const char * boinc_runtime_base_exception::ErrorMessage() + { return "Unknown Runtime Exception"; } + + +// **************************************************************************** +// **************************************************************************** +// +// BOINC Runtime Exceptions +// +// **************************************************************************** +// **************************************************************************** + + +const char * boinc_out_of_memory_exception::ErrorMessage() + { return "Out Of Memory"; } +long boinc_out_of_memory_exception::ErrorValue() + { return ERR_MALLOC; } + +const char * boinc_invalid_parameter_exception::ErrorMessage() + { return "Invalid Parameter"; } +long boinc_invalid_parameter_exception::ErrorValue() + { return -1001; } + + +const char * boinc_file_operation_exception::ErrorMessage() + { return "File Operation Failure"; } +long boinc_file_operation_exception::ErrorValue() + { return -1100; } + +const char * boinc_signal_operation_exception::ErrorMessage() + { return "Signal Operation Failure"; } +long boinc_signal_operation_exception::ErrorValue() + { return -1101; } + + + + diff --git a/api/boinc_exception.h b/api/boinc_exception.h new file mode 100644 index 0000000000..46cfa0f3a9 --- /dev/null +++ b/api/boinc_exception.h @@ -0,0 +1,153 @@ +// The contents of this file are subject to the BOINC Public License +// Version 1.0 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://boinc.berkeley.edu/license_1.0.txt +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// +// The Initial Developer of the Original Code is the SETI@home project. +// Portions created by the SETI@home project are Copyright (C) 2002 +// University of California at Berkeley. All Rights Reserved. +// +// Contributor(s): +// + +#ifndef _BOINC_EXCEPTIONS_ +#define _BOINC_EXCEPTIONS_ + +#include +#include + +using namespace std; + + +// **************************************************************************** +// **************************************************************************** +// +// BOINC Base Exception Class +// +// **************************************************************************** +// **************************************************************************** + + +class boinc_base_exception : public exception +{ + +private: + char m_szConversionBuffer[66]; // convert numbers to strings largest + // datatype is 64bits plus the + // possible sign character and the + // NULL terminator + string m_strErrorBuffer; // the formatted error message when + // asked + + string m_strErrorData; // any relevant data associated with + // the error + string m_strFilename; // the file in which the error occurred + long m_lLineNumber; // the line number in which the error + // occurred + +public: + + boinc_base_exception(const char *s=0) + : m_strErrorData(s){}; + + boinc_base_exception(const char *f, int l, const char *s=0) + : m_strFilename(f), m_lLineNumber(l), m_strErrorData(s){}; + + virtual const char * ErrorType(); + virtual const char * ErrorMessage(); + virtual long ErrorValue(); + + virtual const char * what(); +}; + + +// **************************************************************************** +// **************************************************************************** +// +// BOINC Base Runtime Exception Class +// +// **************************************************************************** +// **************************************************************************** + + +class boinc_runtime_base_exception : public boinc_base_exception +{ +public: + + boinc_runtime_base_exception(const char *s=0) : boinc_base_exception(s){} + boinc_runtime_base_exception(const char *f, int l, const char *s=0) + : boinc_base_exception(f, l, s){} + + virtual const char * ErrorType(); + virtual const char * ErrorMessage(); +}; + + +// **************************************************************************** +// **************************************************************************** +// +// BOINC Runtime Exceptions +// +// **************************************************************************** +// **************************************************************************** + + +class boinc_out_of_memory_exception : public boinc_runtime_base_exception +{ +public: + boinc_out_of_memory_exception(const char *s=0) + : boinc_runtime_base_exception(s){} + boinc_out_of_memory_exception(const char *f, int l, const char *s=0) + : boinc_runtime_base_exception(f, l, s) {} + + virtual const char * ErrorMessage(); + virtual long ErrorValue(); +}; + + +class boinc_invalid_parameter_exception : public boinc_runtime_base_exception +{ +public: + boinc_invalid_parameter_exception(const char *s=0) + : boinc_runtime_base_exception(s){} + boinc_invalid_parameter_exception(const char *f, int l, const char *s=0) + : boinc_runtime_base_exception(f, l, s){} + + virtual const char * ErrorMessage(); + virtual long ErrorValue(); +}; + + +class boinc_file_operation_exception : public boinc_runtime_base_exception +{ +public: + boinc_file_operation_exception(const char *s=0) + : boinc_runtime_base_exception(s){} + boinc_file_operation_exception(const char *f, int l, const char *s=0) + : boinc_runtime_base_exception(f, l, s) {} + + virtual const char * ErrorMessage(); + virtual long ErrorValue(); +}; + + +class boinc_signal_operation_exception : public boinc_runtime_base_exception +{ +public: + boinc_signal_operation_exception(const char *s=0) + : boinc_runtime_base_exception(s){} + boinc_signal_operation_exception(const char *f, int l, const char *s=0) + : boinc_runtime_base_exception(f, l, s) {} + + virtual const char * ErrorMessage(); + virtual long ErrorValue(); +}; + +#endif diff --git a/checkin_notes b/checkin_notes index d65e280fdd..d2454662a4 100755 --- a/checkin_notes +++ b/checkin_notes @@ -10180,3 +10180,16 @@ David Feb 28 2004 client/win/ wingui_mainwindow.cpp,h + +Rom Feb 28 2004 + - Added boinc_diagnostics.c,.h, boinc_exceptions.c,.h. Not included in the build yet, + but needed to snapshot the source. + - Fixed a bug where on Windows we were not really waiting for three seconds before + a retry. This is done for both reads and writes since on Windows there is a notion + of exclusive reads which would make successive read requests fail as well. + + api/ + boinc_diagnostics.C, .h (added) + boinc_exception.C, .h (added) + lib/ + filesys.C diff --git a/lib/filesys.C b/lib/filesys.C index 3d64f57524..5b1c32012d 100755 --- a/lib/filesys.C +++ b/lib/filesys.C @@ -18,6 +18,9 @@ // // Revision History: // $Log$ +// Revision 1.34 2004/02/29 00:50:04 rwalton +// *** empty log message *** +// // Revision 1.33 2004/01/04 06:48:39 davea // *** empty log message *** // @@ -348,7 +351,7 @@ FILE* boinc_fopen(const char* path, const char* mode) { f = fopen(path, mode); #ifdef _WIN32 - if (!f && strchr(mode, 'r')) { + if ((!f) && ((strchr(mode, 'w')) || (strchr(mode, 'r')))) { boinc_sleep(3.0); f = fopen(path, mode); }