mirror of https://github.com/BOINC/boinc.git
Changes made to files to for Windows port.
svn path=/trunk/boinc/; revision=90
This commit is contained in:
parent
906e8a62e1
commit
6233799071
|
@ -17,6 +17,8 @@
|
|||
// Contributor(s):
|
||||
//
|
||||
|
||||
#include "windows_cpp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "error_numbers.h"
|
||||
|
|
78
client/app.C
78
client/app.C
|
@ -21,14 +21,20 @@
|
|||
// connected to I/O files in various ways.
|
||||
// Shouldn't depend on CLIENT_STATE.
|
||||
|
||||
#include "windows_cpp.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "client_types.h"
|
||||
#include "client_state.h"
|
||||
|
@ -210,6 +216,7 @@ int ACTIVE_TASK::start(bool first_time) {
|
|||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
//CreateProcess
|
||||
#endif
|
||||
|
||||
#ifdef macintosh
|
||||
|
@ -233,14 +240,53 @@ int ACTIVE_TASK_SET::insert(ACTIVE_TASK* atp) {
|
|||
// check for child process exit
|
||||
//
|
||||
bool ACTIVE_TASK_SET::poll() {
|
||||
int pid;
|
||||
int stat;
|
||||
ACTIVE_TASK* atp;
|
||||
struct rusage rs;
|
||||
char path[256];
|
||||
int n;
|
||||
|
||||
#ifdef _WIN32
|
||||
unsigned long exit_code;
|
||||
int i;
|
||||
FILETIME creation_time, exit_time, kernel_time, user_time;
|
||||
ULARGE_INTEGER tKernel, tUser;
|
||||
LONGLONG totTime;
|
||||
|
||||
for (i=0; i<active_tasks.size(); i++) {
|
||||
atp = active_tasks[i];
|
||||
if( GetExitCodeProcess( atp->pid_handle,&exit_code ) ) {
|
||||
// Get the elapsed CPU time
|
||||
// Factor this into the equivalent of a S@H etime function?
|
||||
if( GetProcessTimes( atp->pid_handle, &creation_time, &exit_time, &kernel_time, &user_time ) ) {
|
||||
tKernel.LowPart = kernel_time.dwLowDateTime;
|
||||
tKernel.HighPart = kernel_time.dwHighDateTime;
|
||||
|
||||
tUser.LowPart = user_time.dwLowDateTime;
|
||||
tUser.HighPart = user_time.dwHighDateTime;
|
||||
|
||||
// Runtimes in 100-nanosecond units
|
||||
totTime = tKernel.QuadPart + tUser.QuadPart;
|
||||
|
||||
atp->result->cpu_time = (totTime / 10000000.0);
|
||||
} else {
|
||||
atp->result->cpu_time = ((double)clock())/CLOCKS_PER_SEC;
|
||||
}
|
||||
if( exit_code != STILL_ACTIVE ) {
|
||||
// Not sure how to incorporate the other states (WAS_SIGNALED, etc)
|
||||
atp->state = PROCESS_EXITED;
|
||||
atp->exit_status = exit_code;
|
||||
atp->result->exit_status = atp->exit_status;
|
||||
}
|
||||
} else {
|
||||
// Not sure what to do here
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef unix
|
||||
struct rusage rs;
|
||||
int pid;
|
||||
|
||||
pid = wait3(&stat, WNOHANG, &rs);
|
||||
if (pid <= 0) return false;
|
||||
if (log_flags.task_debug) printf("got signal for process %d\n", pid);
|
||||
|
@ -262,6 +308,7 @@ bool ACTIVE_TASK_SET::poll() {
|
|||
atp->state = PROCESS_EXIT_UNKNOWN;
|
||||
atp->result->exit_status = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// check for the stderr file, copy to result record
|
||||
//
|
||||
|
@ -274,7 +321,6 @@ bool ACTIVE_TASK_SET::poll() {
|
|||
}
|
||||
|
||||
clean_out_dir(atp->dirname);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -295,7 +341,7 @@ void ACTIVE_TASK_SET::suspend_all() {
|
|||
ACTIVE_TASK* atp;
|
||||
for (i=0; i<active_tasks.size(); i++) {
|
||||
atp = active_tasks[i];
|
||||
kill(atp->pid, SIGSTOP);
|
||||
atp->suspend();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,10 +350,30 @@ void ACTIVE_TASK_SET::unsuspend_all() {
|
|||
ACTIVE_TASK* atp;
|
||||
for (i=0; i<active_tasks.size(); i++) {
|
||||
atp = active_tasks[i];
|
||||
kill(atp->pid, SIGCONT);
|
||||
atp->unsuspend();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void ACTIVE_TASK::suspend() {
|
||||
// figure out a way to do this
|
||||
//kill(atp->pid, SIGSTOP);
|
||||
}
|
||||
|
||||
void ACTIVE_TASK::unsuspend() {
|
||||
// figure out a way to do this
|
||||
//kill(atp->pid, SIGCONT);
|
||||
}
|
||||
#else
|
||||
void ACTIVE_TASK::suspend() {
|
||||
kill(this->pid, SIGSTOP);
|
||||
}
|
||||
|
||||
void ACTIVE_TASK::unsuspend() {
|
||||
kill(this->pid, SIGCONT);
|
||||
}
|
||||
#endif
|
||||
|
||||
int ACTIVE_TASK_SET::remove(ACTIVE_TASK* atp) {
|
||||
vector<ACTIVE_TASK*>::iterator iter;
|
||||
|
||||
|
|
14
client/app.h
14
client/app.h
|
@ -26,11 +26,17 @@
|
|||
#define PROCESS_EXIT_UNKNOWN 4
|
||||
|
||||
#ifdef macintosh
|
||||
typedef ProcessSerialNumber PROCESS_ID;
|
||||
typedef int PROCESS_ID;
|
||||
//typedef ProcessSerialNumber PROCESS_ID;
|
||||
#else
|
||||
typedef int PROCESS_ID;
|
||||
#endif
|
||||
|
||||
#include "windows_cpp.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
|
||||
|
@ -42,6 +48,9 @@ class CLIENT_STATE;
|
|||
//
|
||||
class ACTIVE_TASK {
|
||||
public:
|
||||
#ifdef _WIN32
|
||||
HANDLE pid_handle;
|
||||
#endif
|
||||
RESULT* result;
|
||||
WORKUNIT* wup;
|
||||
APP_VERSION* app_version;
|
||||
|
@ -61,6 +70,9 @@ public:
|
|||
void request_pause(int x);
|
||||
// request a task to pause. If not paused after x secs, kill
|
||||
|
||||
void suspend();
|
||||
void unsuspend();
|
||||
|
||||
int write(FILE*);
|
||||
int parse(FILE*, CLIENT_STATE*);
|
||||
};
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
// Contributor(s):
|
||||
//
|
||||
|
||||
#include "windows_cpp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "error_numbers.h"
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
// Contributor(s):
|
||||
//
|
||||
|
||||
#include "windows_cpp.h"
|
||||
|
||||
#include "error_numbers.h"
|
||||
#include "file_names.h"
|
||||
#include "filesys.h"
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
// client_state.C (to cross-link objects)
|
||||
//
|
||||
|
||||
#include "windows_cpp.h"
|
||||
|
||||
#ifndef _TYPES_
|
||||
#define _TYPES_
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
// Contributor(s):
|
||||
//
|
||||
|
||||
#include "windows_cpp.h"
|
||||
|
||||
#include "md5_file.h"
|
||||
#include "log_flags.h"
|
||||
#include "file_names.h"
|
||||
|
|
|
@ -20,7 +20,14 @@
|
|||
// functions relating to file transfer
|
||||
//
|
||||
|
||||
#include "windows_cpp.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "md5_file.h"
|
||||
#include "file_xfer.h"
|
||||
|
|
|
@ -17,6 +17,12 @@
|
|||
// Contributor(s):
|
||||
//
|
||||
|
||||
#include "windows_cpp.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
@ -31,6 +37,25 @@ void get_slot_dir(int slot, char* path) {
|
|||
sprintf(path, "slots/%d", slot);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// Double check permissions for CreateDirectory
|
||||
|
||||
int make_project_dir(PROJECT& p) {
|
||||
CreateDirectory(p.domain, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int make_slot_dir(int slot) {
|
||||
char buf[256];
|
||||
CreateDirectory("slots", NULL);
|
||||
get_slot_dir(slot, buf);
|
||||
CreateDirectory(buf, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int make_project_dir(PROJECT& p) {
|
||||
mkdir(p.domain, 0777);
|
||||
return 0;
|
||||
|
@ -43,3 +68,5 @@ int make_slot_dir(int slot) {
|
|||
mkdir(buf, 0777);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -17,6 +17,8 @@
|
|||
// Contributor(s):
|
||||
//
|
||||
|
||||
#include "windows_cpp.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "log_flags.h"
|
||||
#include "file_xfer.h"
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
// Contributor(s):
|
||||
//
|
||||
|
||||
#include "windows_cpp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
@ -47,6 +49,7 @@
|
|||
#include <winsock.h>
|
||||
#endif
|
||||
|
||||
#include "util.h"
|
||||
#include "error_numbers.h"
|
||||
#include "filesys.h"
|
||||
|
||||
|
@ -157,7 +160,7 @@ int file_delete(char* path) {
|
|||
retval = remove(path);
|
||||
#endif
|
||||
if (!retval) break;
|
||||
if (i==0) sleep(3);
|
||||
if (i==0) boinc_sleep(3);
|
||||
}
|
||||
if (retval) {
|
||||
strcpy(failed_file, path);
|
||||
|
|
Loading…
Reference in New Issue