mirror of https://github.com/BOINC/boinc.git
client (Win): when read stderr.txt, wait for write lock to be release first.
Apparently, on Win, there is still a write lock on stderr.txt, and its buffer isn't flushed, until shortly after the app process exits. This is bizarre, but so be it.
This commit is contained in:
parent
883ccab46b
commit
f2d690029c
24
lib/util.cpp
24
lib/util.cpp
|
@ -322,6 +322,30 @@ int read_file_malloc(const char* path, char*& buf, size_t max_len, bool tail) {
|
|||
int retval;
|
||||
double size;
|
||||
|
||||
// Win: if another process has this file open for writing,
|
||||
// wait for up to 5 seconds.
|
||||
// This is because when a job exits, the write to stderr.txt
|
||||
// sometimes (inexplicably) doesn't appear immediately
|
||||
|
||||
#ifdef _WIN32
|
||||
for (int i=0; i<5; i++) {
|
||||
HANDLE h = CreateFileA(
|
||||
path,
|
||||
GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL
|
||||
);
|
||||
if (h != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(h);
|
||||
break;
|
||||
}
|
||||
boinc_sleep(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
retval = file_size(path, size);
|
||||
if (retval) return retval;
|
||||
|
||||
|
|
Loading…
Reference in New Issue