mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=3165
This commit is contained in:
parent
d6d7f7c575
commit
86e83e1e2c
|
@ -1104,7 +1104,7 @@ AC_DEFUN([SAH_HEADER_STDCXX],[
|
|||
#
|
||||
# Revision Log:
|
||||
# $Log$
|
||||
# Revision 1.73 2004/03/24 23:33:37 davea
|
||||
# Revision 1.74 2004/03/25 22:24:26 davea
|
||||
# *** empty log message ***
|
||||
#
|
||||
# Revision 1.1 2003/12/11 18:38:24 korpela
|
||||
|
|
|
@ -117,20 +117,20 @@ int main(int argc, char **argv) {
|
|||
MFILE out;
|
||||
FILE* state, *in;
|
||||
bool standalone = false;
|
||||
unsigned long dwDiagnosticsFlags = 0;
|
||||
int flags = 0;
|
||||
|
||||
my_start_time = time(0);
|
||||
|
||||
|
||||
dwDiagnosticsFlags =
|
||||
flags =
|
||||
BOINC_DIAG_DUMPCALLSTACKENABLED |
|
||||
BOINC_DIAG_HEAPCHECKENABLED |
|
||||
BOINC_DIAG_REDIRECTSTDERR;
|
||||
|
||||
if (standalone)
|
||||
dwDiagnosticsFlags = dwDiagnosticsFlags | BOINC_DIAG_TRACETOSTDERR;
|
||||
flags |= BOINC_DIAG_TRACETOSTDERR;
|
||||
|
||||
boinc_init_diag(dwDiagnosticsFlags);
|
||||
boinc_init_diagnostics(flags);
|
||||
|
||||
|
||||
// NOTE: if you change output here, remember to change the output that
|
||||
|
|
|
@ -10899,4 +10899,23 @@ Rom Mar 25 2004
|
|||
- Removed Delay Load technologies
|
||||
|
||||
api/
|
||||
graphics_api.C
|
||||
graphics_api.C
|
||||
|
||||
David Mar 25 2004
|
||||
- Unix client: use semaphore instead of lockfile to prevent multiple copies
|
||||
- rename boinc_init_diag() to boinc_init_diagnostics()
|
||||
- rename boinc_execution_engine() to main_loop()
|
||||
- add get_key() (to generate IPC key unique to a directory)
|
||||
- replaced RETSIGTYPE with void
|
||||
|
||||
apps/
|
||||
upper_case.C
|
||||
client/
|
||||
Makefile.am
|
||||
client_types.h
|
||||
cs_apps.C
|
||||
main.C
|
||||
lib/
|
||||
diagnostics.C,h
|
||||
error_numbers.h
|
||||
synch.C,h
|
||||
|
|
|
@ -51,6 +51,7 @@ boinc_client_SOURCES = \
|
|||
../lib/messages.C \
|
||||
../lib/parse.C \
|
||||
../lib/shmem.C \
|
||||
../lib/synch.C \
|
||||
../lib/util.C
|
||||
|
||||
boinc_client_DEPENDENCIES = $(LIBRSA)
|
||||
|
|
|
@ -219,6 +219,7 @@ boinc_client_SOURCES = \
|
|||
../lib/messages.C \
|
||||
../lib/parse.C \
|
||||
../lib/shmem.C \
|
||||
../lib/synch.C \
|
||||
../lib/util.C
|
||||
|
||||
|
||||
|
@ -286,7 +287,7 @@ am_boinc_client_OBJECTS = boinc_client-app.$(OBJEXT) \
|
|||
boinc_client-language.$(OBJEXT) boinc_client-md5_file.$(OBJEXT) \
|
||||
boinc_client-md5.$(OBJEXT) boinc_client-messages.$(OBJEXT) \
|
||||
boinc_client-parse.$(OBJEXT) boinc_client-shmem.$(OBJEXT) \
|
||||
boinc_client-util.$(OBJEXT)
|
||||
boinc_client-synch.$(OBJEXT) boinc_client-util.$(OBJEXT)
|
||||
boinc_client_OBJECTS = $(am_boinc_client_OBJECTS)
|
||||
boinc_client_LDFLAGS =
|
||||
am_cpu_benchmark_OBJECTS = cpu_benchmark.$(OBJEXT)
|
||||
|
@ -338,6 +339,7 @@ am__depfiles_maybe = depfiles
|
|||
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-scheduler_op.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-shmem.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-ss_logic.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-synch.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-time_stats.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-util.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/cpu_benchmark.Po
|
||||
|
@ -429,6 +431,7 @@ boinc_client-md5.$(OBJEXT): ../lib/md5.c
|
|||
boinc_client-messages.$(OBJEXT): ../lib/messages.C
|
||||
boinc_client-parse.$(OBJEXT): ../lib/parse.C
|
||||
boinc_client-shmem.$(OBJEXT): ../lib/shmem.C
|
||||
boinc_client-synch.$(OBJEXT): ../lib/synch.C
|
||||
boinc_client-util.$(OBJEXT): ../lib/util.C
|
||||
boinc_client$(EXEEXT): $(boinc_client_OBJECTS) $(boinc_client_DEPENDENCIES)
|
||||
@rm -f boinc_client$(EXEEXT)
|
||||
|
@ -483,6 +486,7 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-scheduler_op.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-shmem.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-ss_logic.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-synch.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-time_stats.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-util.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu_benchmark.Po@am__quote@
|
||||
|
@ -1392,6 +1396,28 @@ boinc_client-shmem.obj: ../lib/shmem.C
|
|||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-shmem.obj `if test -f '../lib/shmem.C'; then $(CYGPATH_W) '../lib/shmem.C'; else $(CYGPATH_W) '$(srcdir)/../lib/shmem.C'`
|
||||
|
||||
boinc_client-synch.o: ../lib/synch.C
|
||||
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-synch.o -MD -MP -MF "$(DEPDIR)/boinc_client-synch.Tpo" \
|
||||
@am__fastdepCXX_TRUE@ -c -o boinc_client-synch.o `test -f '../lib/synch.C' || echo '$(srcdir)/'`../lib/synch.C; \
|
||||
@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/boinc_client-synch.Tpo" "$(DEPDIR)/boinc_client-synch.Po"; \
|
||||
@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/boinc_client-synch.Tpo"; exit 1; \
|
||||
@am__fastdepCXX_TRUE@ fi
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../lib/synch.C' object='boinc_client-synch.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/boinc_client-synch.Po' tmpdepfile='$(DEPDIR)/boinc_client-synch.TPo' @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-synch.o `test -f '../lib/synch.C' || echo '$(srcdir)/'`../lib/synch.C
|
||||
|
||||
boinc_client-synch.obj: ../lib/synch.C
|
||||
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-synch.obj -MD -MP -MF "$(DEPDIR)/boinc_client-synch.Tpo" \
|
||||
@am__fastdepCXX_TRUE@ -c -o boinc_client-synch.obj `if test -f '../lib/synch.C'; then $(CYGPATH_W) '../lib/synch.C'; else $(CYGPATH_W) '$(srcdir)/../lib/synch.C'`; \
|
||||
@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/boinc_client-synch.Tpo" "$(DEPDIR)/boinc_client-synch.Po"; \
|
||||
@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/boinc_client-synch.Tpo"; exit 1; \
|
||||
@am__fastdepCXX_TRUE@ fi
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../lib/synch.C' object='boinc_client-synch.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/boinc_client-synch.Po' tmpdepfile='$(DEPDIR)/boinc_client-synch.TPo' @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-synch.obj `if test -f '../lib/synch.C'; then $(CYGPATH_W) '../lib/synch.C'; else $(CYGPATH_W) '$(srcdir)/../lib/synch.C'`
|
||||
|
||||
boinc_client-util.o: ../lib/util.C
|
||||
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-util.o -MD -MP -MF "$(DEPDIR)/boinc_client-util.Tpo" \
|
||||
@am__fastdepCXX_TRUE@ -c -o boinc_client-util.o `test -f '../lib/util.C' || echo '$(srcdir)/'`../lib/util.C; \
|
||||
|
|
|
@ -47,7 +47,8 @@ struct STRING256 {
|
|||
|
||||
// If the status is neither of these two,
|
||||
// it will be an error code defined in error_numbers.h,
|
||||
// indicating an unrecoverable error in the upload or download of the file
|
||||
// indicating an unrecoverable error in the upload or download of the file,
|
||||
// or that the file was too big and was deleted
|
||||
//
|
||||
#define FILE_NOT_PRESENT 0
|
||||
#define FILE_PRESENT 1
|
||||
|
|
|
@ -91,7 +91,9 @@ int CLIENT_STATE::app_finished(ACTIVE_TASK& at) {
|
|||
|
||||
bool had_error = false;
|
||||
|
||||
if (at.exit_status != 0 && at.exit_status != ERR_QUIT_REQUEST) had_error = true;
|
||||
if (at.exit_status != 0 && at.exit_status != ERR_QUIT_REQUEST) {
|
||||
had_error = true;
|
||||
}
|
||||
|
||||
for (i=0; i<rp->output_files.size(); i++) {
|
||||
fip = rp->output_files[i].file_info;
|
||||
|
@ -103,9 +105,8 @@ int CLIENT_STATE::app_finished(ACTIVE_TASK& at) {
|
|||
fip->status = retval;
|
||||
had_error = true;
|
||||
} else if (size > fip->max_nbytes) {
|
||||
// Note: this is only checked when the application finishes. there
|
||||
// is also a check_max_disk_exceeded that is checked while the
|
||||
// application is running.
|
||||
// Note: this is only checked when the application finishes.
|
||||
// The total disk space is checked while the application is running.
|
||||
//
|
||||
msg_printf(
|
||||
rp->project, MSG_INFO,
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#include "synch.h"
|
||||
#endif
|
||||
|
||||
#include "diagnostics.h"
|
||||
|
@ -188,29 +189,34 @@ BOOL WINAPI ConsoleControlHandler ( DWORD dwCtrlType ){
|
|||
}
|
||||
#endif
|
||||
|
||||
int boinc_execution_engine(int argc, char** argv) {
|
||||
|
||||
int main_loop(int argc, char** argv) {
|
||||
int retval;
|
||||
double dt;
|
||||
|
||||
setbuf(stdout, 0);
|
||||
#if 0
|
||||
if (lock_file(LOCK_FILE_NAME)) {
|
||||
fprintf(stderr, "Another copy of BOINC is already running\n");
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
key_t key;
|
||||
char path[256];
|
||||
getcwd(path, 256);
|
||||
retval = get_key(path, 'a', key);
|
||||
if (!retval) retval = create_semaphore(key);
|
||||
if (!retval) retval = lock_semaphore(key);
|
||||
if (retval) {
|
||||
fprintf(stderr, "Another copy of BOINC is already running\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Initialize Diagnostics
|
||||
//
|
||||
unsigned long dwDiagnosticsFlags = 0;
|
||||
|
||||
dwDiagnosticsFlags =
|
||||
boinc_init_diagnostics(
|
||||
BOINC_DIAG_DUMPCALLSTACKENABLED |
|
||||
BOINC_DIAG_HEAPCHECKENABLED |
|
||||
BOINC_DIAG_TRACETOSTDERR;
|
||||
|
||||
boinc_init_diag(dwDiagnosticsFlags);
|
||||
|
||||
BOINC_DIAG_TRACETOSTDERR
|
||||
);
|
||||
|
||||
// Unix/Linux console controls
|
||||
#ifndef WIN32
|
||||
|
@ -296,10 +302,10 @@ int main(int argc, char** argv) {
|
|||
LogEventErrorMessage(TEXT("StartServiceCtrlDispatcher failed."));
|
||||
}
|
||||
} else {
|
||||
retval = boinc_execution_engine(argc, argv);
|
||||
retval = main_loop(argc, argv);
|
||||
}
|
||||
} else {
|
||||
retval = boinc_execution_engine(argc, argv);
|
||||
retval = main_loop(argc, argv);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
@ -311,7 +317,7 @@ int main(int argc, char** argv) {
|
|||
// For platforms other than windows just treat it as a console application
|
||||
//
|
||||
int main(int argc, char** argv) {
|
||||
return boinc_execution_engine(argc, argv);
|
||||
return main_loop(argc, argv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
//#include <signal.h>
|
||||
#endif
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "diagnostics.h"
|
||||
|
@ -36,51 +36,33 @@
|
|||
#include "filesys.h"
|
||||
#include "util.h"
|
||||
|
||||
// Diagnostics Global State
|
||||
//
|
||||
|
||||
static int g_BOINCDIAG_dwDiagnosticsFlags;
|
||||
|
||||
static int flags;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// Diagnostics Support for Windows 95/98/ME/2000/XP/2003
|
||||
//
|
||||
|
||||
// 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 );
|
||||
|
||||
LONG CALLBACK boinc_catch_signal(EXCEPTION_POINTERS *ExceptionInfo);
|
||||
int __cdecl boinc_message_reporting( int reportType, char *szMsg, int *retVal );
|
||||
#else
|
||||
|
||||
// Diagnostics for POSIX Compatible systems.
|
||||
//
|
||||
|
||||
// Forward declare implementation functions - POSIX Platform Only.
|
||||
extern RETSIGTYPE boinc_catch_signal(int signal);
|
||||
extern void boinc_quit(int sig);
|
||||
|
||||
static void boinc_catch_signal(int signal);
|
||||
//static void boinc_quit(int sig);
|
||||
#endif
|
||||
|
||||
|
||||
// Used to initialize the diagnostics environment.
|
||||
// initialize the diagnostics environment.
|
||||
//
|
||||
int boinc_init_diag( int dwDiagnosticsFlags ) {
|
||||
|
||||
int boinc_init_diagnostics(int _flags) {
|
||||
void* lpRetVal;
|
||||
|
||||
// Store Diagnostics Flags globally for use.
|
||||
g_BOINCDIAG_dwDiagnosticsFlags = dwDiagnosticsFlags;
|
||||
|
||||
flags = _flags;
|
||||
|
||||
// Archive any old stderr.txt and stdout.txt files, if requested
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_ARCHIVESTDERR ) {
|
||||
if (boinc_copy( BOINC_DIAG_STDERR, BOINC_DIAG_STDERROLD)) {
|
||||
if ( flags & BOINC_DIAG_ARCHIVESTDERR ) {
|
||||
if (boinc_copy(BOINC_DIAG_STDERR, BOINC_DIAG_STDERROLD)) {
|
||||
//BOINCFILEERROR( "Failed to archive existing stderr.txt file" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_ARCHIVESTDOUT) {
|
||||
if ( flags & BOINC_DIAG_ARCHIVESTDOUT) {
|
||||
if (boinc_copy( BOINC_DIAG_STDOUT, BOINC_DIAG_STDOUTOLD )) {
|
||||
//BOINCFILEERROR( "Failed to archive existing stdout.txt file" );
|
||||
}
|
||||
|
@ -88,25 +70,28 @@ int boinc_init_diag( int dwDiagnosticsFlags ) {
|
|||
|
||||
|
||||
// Redirect stderr and/or stdout streams, if requested
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_REDIRECTSTDERR ) {
|
||||
if (flags & BOINC_DIAG_REDIRECTSTDERR ) {
|
||||
lpRetVal = (void*) freopen(BOINC_DIAG_STDERR, "a", stderr);
|
||||
if ( NULL == lpRetVal )
|
||||
BOINCFILEERROR( "Failed to reopen stderr for diagnostics redirection" );
|
||||
if ( NULL == lpRetVal ) {
|
||||
BOINCFILEERROR("Failed to reopen stderr for diagnostics redirection" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_REDIRECTSTDERROVERWRITE ) {
|
||||
if (flags & BOINC_DIAG_REDIRECTSTDERROVERWRITE ) {
|
||||
lpRetVal = (void*) freopen(BOINC_DIAG_STDERR, "w", stderr);
|
||||
if ( NULL == lpRetVal )
|
||||
BOINCFILEERROR( "Failed to reopen stderr for diagnostics redirection (overwrite)" );
|
||||
if ( NULL == lpRetVal ) {
|
||||
BOINCFILEERROR("Failed to reopen stderr for diagnostics redirection (overwrite)" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_REDIRECTSTDOUT ) {
|
||||
if (flags & BOINC_DIAG_REDIRECTSTDOUT ) {
|
||||
lpRetVal = (void*) freopen(BOINC_DIAG_STDOUT, "a", stdout);
|
||||
if ( NULL == lpRetVal )
|
||||
if ( NULL == lpRetVal ) {
|
||||
BOINCFILEERROR( "Failed to reopen stdout for diagnostics redirection" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_REDIRECTSTDOUTOVERWRITE ) {
|
||||
if (flags & BOINC_DIAG_REDIRECTSTDOUTOVERWRITE ) {
|
||||
lpRetVal = (void*) freopen(BOINC_DIAG_STDOUT, "w", stdout);
|
||||
if ( NULL == lpRetVal )
|
||||
BOINCFILEERROR( "Failed to reopen stdout for diagnostics redirection (overwrite)" );
|
||||
|
@ -120,10 +105,10 @@ int boinc_init_diag( int dwDiagnosticsFlags ) {
|
|||
// MFC by default, configures itself for the memory leak detection on exit
|
||||
//
|
||||
|
||||
//if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_MEMORYLEAKCHECKENABLED )
|
||||
//if (flags & BOINC_DIAG_MEMORYLEAKCHECKENABLED )
|
||||
// SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF );
|
||||
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_HEAPCHECKENABLED ) {
|
||||
if (flags & BOINC_DIAG_HEAPCHECKENABLED ) {
|
||||
AfxEnableMemoryTracking(TRUE);
|
||||
afxMemDF = allocMemDF | checkAlwaysMemDF;
|
||||
}
|
||||
|
@ -132,10 +117,10 @@ int boinc_init_diag( int dwDiagnosticsFlags ) {
|
|||
|
||||
_CrtSetReportHook( boinc_message_reporting );
|
||||
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_MEMORYLEAKCHECKENABLED )
|
||||
if (flags & BOINC_DIAG_MEMORYLEAKCHECKENABLED )
|
||||
SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF );
|
||||
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_HEAPCHECKENABLED )
|
||||
if (flags & BOINC_DIAG_HEAPCHECKENABLED )
|
||||
SET_CRT_DEBUG_FIELD( _CRTDBG_CHECK_EVERY_1024_DF );
|
||||
|
||||
#endif // _CONSOLE
|
||||
|
@ -162,13 +147,9 @@ int boinc_finish_diag() {
|
|||
// Used to setup an unhandled exception filter on Windows
|
||||
//
|
||||
int boinc_install_signal_handlers() {
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
SetUnhandledExceptionFilter( boinc_catch_signal );
|
||||
|
||||
#else //_WIN32
|
||||
|
||||
boinc_set_signal_handler(SIGHUP, boinc_catch_signal);
|
||||
boinc_set_signal_handler(SIGINT, boinc_catch_signal);
|
||||
boinc_set_signal_handler(SIGQUIT, boinc_catch_signal);
|
||||
|
@ -178,10 +159,8 @@ int boinc_install_signal_handlers() {
|
|||
boinc_set_signal_handler(SIGSEGV, boinc_catch_signal);
|
||||
boinc_set_signal_handler(SIGSYS, boinc_catch_signal);
|
||||
boinc_set_signal_handler(SIGPIPE, boinc_catch_signal);
|
||||
|
||||
#endif //_WIN32
|
||||
|
||||
return BOINC_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -313,7 +292,7 @@ LONG CALLBACK boinc_catch_signal(EXCEPTION_POINTERS *pExPtrs) {
|
|||
fflush( stderr );
|
||||
|
||||
// Unwind the stack and spew it to stderr
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_DUMPCALLSTACKENABLED )
|
||||
if (flags & BOINC_DIAG_DUMPCALLSTACKENABLED )
|
||||
StackwalkFilter( pExPtrs, EXCEPTION_EXECUTE_HANDLER, NULL );
|
||||
|
||||
fprintf( stderr, "Exiting...\n" );
|
||||
|
@ -342,12 +321,12 @@ int __cdecl boinc_message_reporting( int reportType, char *szMsg, int *retVal ){
|
|||
|
||||
OutputDebugString(szMsg); // Reports string to the debugger output window
|
||||
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_TRACETOSTDERR ) {
|
||||
if (flags & BOINC_DIAG_TRACETOSTDERR ) {
|
||||
fprintf( stderr, "%s", szMsg );
|
||||
fflush( stderr );
|
||||
}
|
||||
|
||||
if ( g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_TRACETOSTDOUT ) {
|
||||
if (flags & BOINC_DIAG_TRACETOSTDOUT ) {
|
||||
fprintf( stdout, "%s", szMsg );
|
||||
fflush( stdout );
|
||||
}
|
||||
|
@ -368,14 +347,13 @@ int __cdecl boinc_message_reporting( int reportType, char *szMsg, int *retVal ){
|
|||
// Converts the BOINCTRACE macro into a single string and report it
|
||||
// to the CRT so it can be reported via the normal means.
|
||||
//
|
||||
void boinc_trace(const char *pszFormat, ...)
|
||||
{
|
||||
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 ( (g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_TRACETOSTDERR) ||
|
||||
(g_BOINCDIAG_dwDiagnosticsFlags & BOINC_DIAG_TRACETOSTDOUT) ) {
|
||||
if ((flags & BOINC_DIAG_TRACETOSTDERR) ||
|
||||
(flags & BOINC_DIAG_TRACETOSTDOUT) ) {
|
||||
|
||||
memset(szBuffer, 0, sizeof(szBuffer));
|
||||
|
||||
|
@ -447,7 +425,7 @@ void boinc_info_release(const char *pszFormat, ...)
|
|||
|
||||
// Set a signal handler only if it is not currently ignored
|
||||
//
|
||||
void boinc_set_signal_handler(int sig, RETSIGTYPE (*handler)(int)) {
|
||||
void boinc_set_signal_handler(int sig, void(*handler)(int)) {
|
||||
#ifdef HAVE_SIGACTION
|
||||
struct sigaction temp;
|
||||
sigaction(sig, NULL, &temp);
|
||||
|
@ -468,7 +446,7 @@ void boinc_set_signal_handler(int sig, RETSIGTYPE (*handler)(int)) {
|
|||
|
||||
// Set a signal handler even if it is currently ignored
|
||||
//
|
||||
void boinc_set_signal_handler_force(int sig, RETSIGTYPE (*handler)(int)) {
|
||||
void boinc_set_signal_handler_force(int sig, void(*handler)(int)) {
|
||||
#ifdef HAVE_SIGACTION
|
||||
struct sigaction temp;
|
||||
sigaction(sig, NULL, &temp);
|
||||
|
@ -483,7 +461,7 @@ void boinc_set_signal_handler_force(int sig, RETSIGTYPE (*handler)(int)) {
|
|||
}
|
||||
|
||||
|
||||
RETSIGTYPE boinc_catch_signal(int signal) {
|
||||
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;
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
#define _BOINC_DIAGNOSTICS_
|
||||
|
||||
|
||||
// Diagnostics Support for Windows 95/98/ME/2000/XP/2003
|
||||
//
|
||||
#ifdef _WIN32
|
||||
|
||||
// Define macros for both debug and release builds.
|
||||
|
@ -68,13 +66,12 @@ void boinc_info_release(const char *pszFormat, ...);
|
|||
#endif // _DEBUG
|
||||
|
||||
#else // non-Win starts here
|
||||
extern void boinc_set_signal_handler(int sig, RETSIGTYPE (*handler)(int));
|
||||
extern void boinc_set_signal_handler_force(int sig, RETSIGTYPE (*handler)(int));
|
||||
#include <signal.h>
|
||||
extern void boinc_set_signal_handler(int sig, void(*handler)(int));
|
||||
extern void boinc_set_signal_handler_force(int sig, void(*handler)(int));
|
||||
#endif // _WIN32
|
||||
|
||||
|
||||
// Diagnostics Support for All Platforms
|
||||
//
|
||||
#ifdef _DEBUG
|
||||
|
||||
#define BOINCERROR( errmsg ) \
|
||||
|
@ -103,9 +100,6 @@ extern void boinc_set_signal_handler_force(int sig, RETSIGTYPE (*handler)(int));
|
|||
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
// Diagnostics Support for Undefined Platform
|
||||
//
|
||||
#ifndef BOINCASSERT
|
||||
#define BOINCASSERT assert
|
||||
#endif
|
||||
|
@ -118,15 +112,11 @@ extern void boinc_set_signal_handler_force(int sig, RETSIGTYPE (*handler)(int));
|
|||
#define BOINCINFO ((int)0)
|
||||
#endif
|
||||
|
||||
|
||||
// Diagnostics Functions
|
||||
//
|
||||
extern int boinc_init_diag(int);
|
||||
extern int boinc_init_diagnostics(int flags);
|
||||
extern int boinc_finish_diag();
|
||||
extern int boinc_install_signal_handlers();
|
||||
|
||||
|
||||
// Diagnostic Flags
|
||||
// flags for boinc_init_diagnostics()
|
||||
//
|
||||
#define BOINC_DIAG_DUMPCALLSTACKENABLED 0x00000001L
|
||||
#define BOINC_DIAG_HEAPCHECKENABLED 0x00000002L
|
||||
|
@ -141,7 +131,7 @@ extern int boinc_install_signal_handlers();
|
|||
#define BOINC_DIAG_TRACETOSTDOUT 0x00000400L
|
||||
|
||||
|
||||
// Diagnostics Contants
|
||||
// filenames
|
||||
//
|
||||
#define BOINC_DIAG_STDERR "stderr.txt"
|
||||
#define BOINC_DIAG_STDERROLD "stderr.old"
|
||||
|
|
|
@ -113,3 +113,7 @@
|
|||
// exit_status not found in scheduler request
|
||||
#define ERR_FILE_MISSING -163
|
||||
#define ERR_NESTED_UNHANDLED_EXCEPTION_DETECTED -164
|
||||
#define ERR_SEMGET -165
|
||||
#define ERR_SEMCTL -166
|
||||
#define ERR_SEMOP -167
|
||||
#define ERR_FTOK -168
|
||||
|
|
26
lib/synch.C
26
lib/synch.C
|
@ -23,6 +23,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "error_numbers.h"
|
||||
#include "synch.h"
|
||||
|
||||
union semun {
|
||||
|
@ -39,14 +40,14 @@ int create_semaphore(key_t key){
|
|||
id = semget(key, 1, IPC_CREAT|IPC_EXCL|0777);
|
||||
if (id < 0) {
|
||||
perror("create_semaphore: semget");
|
||||
return -1;
|
||||
return ERR_SEMGET;
|
||||
}
|
||||
memset(&s, 0, sizeof(s));
|
||||
s.val = 1;
|
||||
retval = semctl(id, 0, SETVAL, s);
|
||||
if (retval) {
|
||||
perror("create_semaphore: semctl");
|
||||
return -1;
|
||||
return ERR_SEMCTL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -56,12 +57,12 @@ int destroy_semaphore(key_t key){
|
|||
id = semget(key, 0, 0);
|
||||
if (id < 0) {
|
||||
perror("destroy_semaphore: semget");
|
||||
return -1;
|
||||
return ERR_SEMGET;
|
||||
}
|
||||
retval = semctl(id, 1, IPC_RMID, 0);
|
||||
if (retval) {
|
||||
perror("destroy_semaphore: semctl");
|
||||
return -1;
|
||||
return ERR_SEMCTL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -73,15 +74,15 @@ int lock_semaphore(key_t key) {
|
|||
id = semget(key, 0, 0);
|
||||
if (id < 0) {
|
||||
perror("lock_semaphore: semget");
|
||||
return -1;
|
||||
return ERR_SEMGET;
|
||||
}
|
||||
s.sem_num = 0;
|
||||
s.sem_op = -1;
|
||||
s.sem_flg = SEM_UNDO;
|
||||
retval = semop(id, &s, 1);
|
||||
if (retval) {
|
||||
perror("lock_semaphore: semctl");
|
||||
return -1;
|
||||
perror("lock_semaphore: semop");
|
||||
return ERR_SEMOP;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -93,16 +94,21 @@ int unlock_semaphore(key_t key) {
|
|||
id = semget(key, 0, 0);
|
||||
if (id < 0) {
|
||||
perror("unlock_semaphore: semget");
|
||||
return -1;
|
||||
return ERR_SEMGET;
|
||||
}
|
||||
s.sem_num = 0;
|
||||
s.sem_op = 1;
|
||||
s.sem_flg = SEM_UNDO;
|
||||
retval = semop(id, &s, 1);
|
||||
if (retval) {
|
||||
perror("unlock_semaphore: semctl");
|
||||
return -1;
|
||||
perror("unlock_semaphore: semop");
|
||||
return ERR_SEMOP;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_key(char* path, int id, key_t& key) {
|
||||
key = ftok(path, id);
|
||||
if (key == (key_t)-1) return ERR_FTOK;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include <sys/sem.h>
|
||||
#include <sys/ipc.h>
|
||||
|
||||
extern int create_semaphore(key_t);
|
||||
extern int destroy_semaphore(key_t);
|
||||
extern int lock_semaphore(key_t);
|
||||
extern int unlock_semaphore(key_t);
|
||||
extern int get_key(char* path, int id, key_t&);
|
||||
|
|
Loading…
Reference in New Issue