Eliminate some flakes

- Get ASAN working on Windows.

- Deleting directories and then recreating them with the same name in a
  short period of time appears to be a no-no on Windows.

- There's no reason to call FlushFileBuffers on close() for pipes, and
  it's harmful since it might block indefinitely for no good reason.
This commit is contained in:
Justine Tunney 2021-02-03 06:22:51 -08:00
parent 27c899af56
commit 4e56d89dcd
60 changed files with 588 additions and 751 deletions

View file

@ -17,13 +17,15 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/internal.h"
#include "libc/nt/enum/filetype.h"
#include "libc/nt/files.h"
#include "libc/nt/runtime.h"
#include "libc/sysv/errfuns.h"
textwindows int close$nt(int fd) {
bool32 ok;
if (g_fds.p[fd].kind == kFdFile) {
if (g_fds.p[fd].kind == kFdFile &&
GetFileType(g_fds.p[fd].handle) == kNtFileTypeDisk) {
/*
* Like Linux, closing a file on Windows doesn't guarantee it's
* immediately synced to disk. But unlike Linux, this could cause
@ -32,6 +34,8 @@ textwindows int close$nt(int fd) {
FlushFileBuffers(g_fds.p[fd].handle);
}
ok = CloseHandle(g_fds.p[fd].handle);
if (g_fds.p[fd].kind == kFdConsole) ok &= CloseHandle(g_fds.p[fd].extra);
if (g_fds.p[fd].kind == kFdConsole) {
ok &= CloseHandle(g_fds.p[fd].extra);
}
return ok ? 0 : __winerr();
}