+#define SocketHandleGetOverlappedResult(sh, io) (sh.is_handle ? \
+ GetOverlappedResult(sh.h, io->overlapped, io->size, FALSE) : \
+ WSAGetOverlappedResult(sh.s, io->overlapped, io->size, FALSE, io->flags))
+
+#define SocketHandleGetLastError(sh) (sh.is_handle ? \
+ GetLastError() : WSAGetLastError())
+
+#define SocketHandleSetLastError(sh, ...) (sh.is_handle ? \
+ SetLastError(__VA_ARGS__) : WSASetLastError(__VA_ARGS__))
+
+#define SocketHandleSetInvalError(sh) (sh.is_handle ? \
+ SetLastError(ERROR_INVALID_FUNCTION) : WSASetLastError(WSAEINVAL))
+
I would prefer small static inline functions here. With modern compilers
they get inlined and are nicer than these macros.
#else /* ifdef _WIN32 */
#define openvpn_close_socket(s) close(s)
@@ -1020,7 +1041,8 @@ link_socket_read_udp_win32(struct link_socket *sock,
struct buffer *buf,
struct link_socket_actual *from)
{
- return socket_finalize(sock->sd, &sock->reads, buf, from);
+ sockethandle_t sh = { .s = sock->sd };
It would be good to explicitly have is_handle = false here. Otherwise we
rely on implicit zero initialisation, which I am not sure is guaranteed
and it also is better for documentation.
Arne
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel