mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-27 15:52:28 +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
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
#include "libc/nt/winsock.h"
|
||||
|
@ -30,9 +31,11 @@ __msabi extern typeof(__sys_closesocket_nt) *const __imp_closesocket;
|
|||
*
|
||||
* This function should only be called by close().
|
||||
*/
|
||||
textwindows int sys_closesocket_nt(struct Fd *fd) {
|
||||
int rc = __imp_closesocket(fd->handle);
|
||||
if (rc != -1) {
|
||||
textwindows int sys_closesocket_nt(struct Fd *f) {
|
||||
if (_weaken(sys_connect_nt_cleanup)) {
|
||||
_weaken(sys_connect_nt_cleanup)(f, true);
|
||||
}
|
||||
if (!__imp_closesocket(f->handle)) {
|
||||
return 0;
|
||||
} else {
|
||||
return __winsockerr();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue