From dfa44563dbd9e2befbade48360532e4937e72530 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 22 Aug 2002 20:19:18 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=362 --- api/boinc_api.C | 6 +++++- client/app.C | 25 +++++++++++-------------- client/client_types.h | 15 ++++++++++----- client/filesys.C | 2 +- client/http.C | 10 ---------- client/http.h | 1 - client/net_xfer.C | 12 +++++------- 7 files changed, 32 insertions(+), 39 deletions(-) diff --git a/api/boinc_api.C b/api/boinc_api.C index f6f98de28b..bc60e94d0e 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -56,6 +56,10 @@ int boinc_init() { FILE* f; int retval; +#ifdef _WIN32 + freopen(STDERR_FILE, "a", stderr); +#endif + f = fopen(INIT_DATA_FILE, "r"); if (!f) return ERR_FOPEN; retval = parse_init_data_file(f, aid); @@ -91,7 +95,7 @@ int boinc_resolve_filename(char *virtual_name, char *physical_name) { FILE *fp; char buf[512]; - strcpy( physical_name, virtual_name ); + strcpy(physical_name, virtual_name); // Open the file and load the first line fp = fopen(virtual_name, "r"); diff --git a/client/app.C b/client/app.C index 7ee0623dfe..eb2822d24d 100644 --- a/client/app.C +++ b/client/app.C @@ -153,13 +153,14 @@ int ACTIVE_TASK::start(bool first_time) { //app_prefs.graphics.refresh_period = 5; memset(&aid, 0, sizeof(aid)); + // TODO: fill in the app prefs, user name, team name, etc. aid.checkpoint_period = DEFAULT_CHECKPOINT_PERIOD; aid.fraction_done_update_period = DEFAULT_FRACTION_DONE_UPDATE_PERIOD; aid.wu_cpu_time = checkpoint_cpu_time; sprintf(prefs_path, "%s/%s", dirname, INIT_DATA_FILE); - prefs_fd = fopen(prefs_path, "wb"); + prefs_fd = fopen(prefs_path, "w"); if (!prefs_fd) { if (log_flags.task_debug) { printf("Failed to open core to app prefs file %s.\n", prefs_path); @@ -170,7 +171,7 @@ int ACTIVE_TASK::start(bool first_time) { fclose(prefs_fd); sprintf(init_path, "%s/%s", dirname, FD_INIT_FILE); - init_file = fopen(init_path, "wb"); + init_file = fopen(init_path, "w"); if (!init_file) { if(log_flags.task_debug) { printf( "Failed to open init file %s.\n", init_path ); @@ -292,8 +293,7 @@ int ACTIVE_TASK::start(bool first_time) { #ifdef _WIN32 PROCESS_INFORMATION process_info; STARTUPINFO startup_info; - //HINSTANCE inst; - char exec_path[256]; + char exec_path[256]; memset( &process_info, 0, sizeof( process_info ) ); memset( &startup_info, 0, sizeof( startup_info ) ); @@ -301,25 +301,23 @@ int ACTIVE_TASK::start(bool first_time) { startup_info.lpReserved = NULL; startup_info.lpDesktop = ""; - // hook up stderr to a specially-named file (do this inside the new process) - // - //freopen(STDERR_FILE, "a", stderr); + // NOTE: in Windows, stderr is redirected within boinc_init(); // Need to condense argv into a single string //if (log_flags.task_debug) print_argv(argv); // sprintf(exec_path, "%s/%s", dirname, exec_name); - if( !CreateProcess(exec_path, + if (!CreateProcess(exec_path, wup->command_line, - NULL, // not sure about this for security - NULL, // not sure about this for security + NULL, + NULL, FALSE, CREATE_NEW_PROCESS_GROUP|CREATE_NO_WINDOW|NORMAL_PRIORITY_CLASS, NULL, dirname, &startup_info, - &process_info ) - ) { + &process_info + )) { state = GetLastError(); LPVOID lpMsgBuf; FormatMessage( @@ -333,8 +331,7 @@ int ACTIVE_TASK::start(bool first_time) { 0, NULL ); - fprintf(stdout, "CreateProcess: %s\n", (LPCTSTR)lpMsgBuf); - //MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION ); + fprintf(stdout, "CreateProcess: %s\n", (LPCTSTR)lpMsgBuf); } pid_handle = process_info.hProcess; diff --git a/client/client_types.h b/client/client_types.h index 8766746e37..d31ef49ca1 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -178,11 +178,16 @@ struct WORKUNIT { int write(FILE*); }; -#define RESULT_NEW 0 // New result, files still need to be downloaded -#define RESULT_FILES_DOWNLOADED 1 // Files are downloaded, result can be computed -#define RESULT_COMPUTE_DONE 2 // Computation is done, files to be uploaded -#define RESULT_READY_TO_ACK 3 // Files are uploaded, notify scheduling server -#define RESULT_SERVER_ACK 4 // Received an ack from server, result is done +#define RESULT_NEW 0 + // New result, files may still need to be downloaded +#define RESULT_FILES_DOWNLOADED 1 + // Files are downloaded, result can be computed +#define RESULT_COMPUTE_DONE 2 + // Computation is done, files need to be uploaded +#define RESULT_READY_TO_ACK 3 + // Files are uploaded, notify scheduling server +#define RESULT_SERVER_ACK 4 + // Received ack from server, can delete result struct RESULT { char name[256]; diff --git a/client/filesys.C b/client/filesys.C index e5f7282198..85c3bf1f6b 100644 --- a/client/filesys.C +++ b/client/filesys.C @@ -196,7 +196,7 @@ int file_size(char* path, int& size) { int boinc_link(char *existing, char *new_link) { FILE *fp; - fp = fopen(new_link, "wb"); + fp = fopen(new_link, "w"); if (!fp) return ERR_FOPEN; fprintf(fp, "%s\n", existing); fclose(fp); diff --git a/client/http.C b/client/http.C index d32644b407..394beec8a1 100644 --- a/client/http.C +++ b/client/http.C @@ -345,10 +345,6 @@ int HTTP_OP_SET::insert(HTTP_OP* ho) { return 0; } -// Runs through the set of HTTP_OP objects in the set and decides -// what operation is appropriate for each. This section needs more -// thorough documentation, as it is fairly complex -// bool HTTP_OP_SET::poll() { unsigned int i; HTTP_OP* htp; @@ -554,9 +550,3 @@ int HTTP_OP_SET::remove(HTTP_OP* p) { fprintf(stdout, "HTTP_OP_SET::remove(): not found\n"); return 1; } - -// Returns the size of the set of HTTP_OP objects -// -int HTTP_OP_SET::size() { - return http_ops.size(); -} diff --git a/client/http.h b/client/http.h index bc2e4ecd11..d28b3e1658 100644 --- a/client/http.h +++ b/client/http.h @@ -81,7 +81,6 @@ public: bool poll(); int insert(HTTP_OP*); int remove(HTTP_OP*); - int size(); }; #define HTTP_STATE_IDLE 0 diff --git a/client/net_xfer.C b/client/net_xfer.C index 8b76cf703f..ab2e8e3c72 100644 --- a/client/net_xfer.C +++ b/client/net_xfer.C @@ -88,14 +88,13 @@ int NET_XFER::open_server() { if (fd < 0) return -1; #ifdef _WIN32 - unsigned long one = 1; - ioctlsocket(fd, FIONBIO, &one); + unsigned long one = 1; + ioctlsocket(fd, FIONBIO, &one); #else int flags; - //ioctl(fd, FIONBIO, &one); flags = fcntl(fd, F_GETFL, 0); if (flags < 0) return -1; - else if( fcntl(fd, F_SETFL, flags|O_NONBLOCK) < 0 ) return -1; + else if (fcntl(fd, F_SETFL, flags|O_NONBLOCK) < 0 ) return -1; #endif addr.sin_family = AF_INET; @@ -123,7 +122,7 @@ int NET_XFER::open_server() { return 0; } -void NET_XFER::close_socket( void ) { +void NET_XFER::close_socket() { #ifdef _WIN32 if (socket) closesocket(socket); #else @@ -132,7 +131,6 @@ void NET_XFER::close_socket( void ) { } void NET_XFER::init(char* host, int p, int b) { - // net_xfer_state = ? socket = -1; is_connected = false; want_download = false; @@ -161,7 +159,6 @@ int NET_XFER_SET::insert(NET_XFER* nxp) { int NET_XFER_SET::remove(NET_XFER* nxp) { vector::iterator iter; - // Close the socket nxp->close_socket(); iter = net_xfers.begin(); @@ -179,6 +176,7 @@ int NET_XFER_SET::remove(NET_XFER* nxp) { // transfer data to/from a list of active streams // transfer at most max_bytes bytes. // TODO: implement other bandwidth constraints (ul/dl ratio, time of day) +// int NET_XFER_SET::poll(int max_bytes, int& bytes_transferred) { int n, retval;