mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Improve threading and i/o routines
- On Windows connect() can now be interrupted by a signal; connect() w/ O_NONBLOCK will now raise EINPROGRESS; and connect() with SO_SNDTIMEO will raise ETIMEDOUT after the interval has elapsed. - We now get the AcceptEx(), ConnectEx(), and TransmitFile() functions from the WIN32 API the officially blessed way, using WSAIoctl(). - Do nothing on Windows when fsync() is called on a directory handle. This was raising EACCES earlier becaues GENERIC_WRITE is required on the handle. It's possible to FlushFileBuffers() a directory handle if it's opened with write access but MSDN doesn't document what it does. If you have any idea, please let us know! - Prefer manual reset event objects for read() and write() on Windows. - Do some code cleanup on our dlmalloc customizations. - Fix errno type error in Windows blocking routines. - Make the futex polyfill simpler and faster.
This commit is contained in:
parent
f7343319cc
commit
49b0eaa69f
43 changed files with 528 additions and 425 deletions
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
|
@ -172,7 +173,7 @@ TEST(fwrite, signalStorm) {
|
|||
if (!pid) {
|
||||
do {
|
||||
ASSERT_NE(-1, kill(getppid(), SIGINT));
|
||||
usleep(25);
|
||||
usleep(5000);
|
||||
} while (!gotsigint);
|
||||
_exit(0);
|
||||
}
|
||||
|
|
|
@ -28,12 +28,12 @@ void *Worker(void *arg) {
|
|||
int i;
|
||||
char *volatile p;
|
||||
char *volatile q;
|
||||
for (i = 0; i < 256; ++i) {
|
||||
for (i = 0; i < 3000; ++i) {
|
||||
p = malloc(17);
|
||||
free(p);
|
||||
p = malloc(17);
|
||||
q = malloc(17);
|
||||
sched_yield();
|
||||
pthread_yield();
|
||||
free(p);
|
||||
free(q);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ void SetUpOnce(void) {
|
|||
}
|
||||
|
||||
TEST(memory, test) {
|
||||
int i, n = 32;
|
||||
int i, n = 8;
|
||||
pthread_t *t = gc(malloc(sizeof(pthread_t) * n));
|
||||
for (i = 0; i < n; ++i) {
|
||||
ASSERT_EQ(0, pthread_create(t + i, 0, Worker, 0));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue