Revamp client's Windows POSIX compatibility code
Unlike POSIX sockets, Windows sockets are not file descriptors, but "OS handles", with a completely separate set of functions. However, Windows can create a file descriptor for a socket, and return a file descriptor's underlying handle. Use that instead of our gross hacks to keep up the illusion that sockets are file descriptors. Slightly dirty: we put file descriptors into fd_set. Works because both boil down to int. Change w32_select(), w32_socket(), w32_connect(), w32_recv(), w32_writev_socket(), w32_send() to take and return only file descriptors, and map to sockets internally. Replace w32_close_socket() by w32_close(), and drop the close() macro hackery that made tcp_connect(), host_connect() use w32_close_socket(). New fd_is_socket(). Windows provides select()-like functions only for handles. Because of that, the client used a handle for reading script files, and stored it in file descriptor input_fd. Drop this dirty hack, use a file descriptor instead. Works because we can get its underlying handle. Remove the dirty macro hackery that made play(), ring_from_file() and doexecute() unwittingly work with a handle. Remove w32_openhandle() and w32_close_handle(). Replace w32_readv_handle() by w32_readv_fd(). Update w32_select(). Remove w32_openfd(), it's not really needed. The old code stuffed WSA error codes into errno, which doesn't work. Use new w32_set_winsock_errno() to convert & stuff. Fix signed vs. unsigned warnings in Windows client. Move the struct sigaction replacement next to the sigaction() replacement. Rename sysdep_init() to w32_sysdep_init() for consistency.
This commit is contained in:
parent
f4209f7ea9
commit
798af5b45b
8 changed files with 155 additions and 176 deletions
|
@ -28,7 +28,7 @@
|
|||
* ringbuf.c: Simple ring buffer
|
||||
*
|
||||
* Known contributors to this file:
|
||||
* Markus Armbruster, 2007
|
||||
* Markus Armbruster, 2007-2009
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -41,7 +41,7 @@
|
|||
#include <unistd.h>
|
||||
#else
|
||||
#define readv(fd, iov, iovcnt) \
|
||||
w32_readv_handle((fd), (iov), (iovcnt))
|
||||
w32_readv_fd((fd), (iov), (iovcnt))
|
||||
#define writev(fd, iov, iovcnt) \
|
||||
w32_writev_socket((fd), (iov), (iovcnt))
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue