diff options
author | Daniel Stenberg <daniel@haxx.se> | 2004-07-24 21:47:49 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2004-07-24 21:47:49 +0000 |
commit | b3b2ba31f7f666f31e187db9c223062553966566 (patch) | |
tree | 6acdfb45246bcf76087412ae8cbdd4cf31dd3e17 /ares/windows_port.c | |
parent | 7f78bc3c6d167760a41a5183d21b3ecfe2718a7c (diff) |
Gisle Vanem:
Basically in loops like handle_errors(), 'query->next' was assigned a local
variable and then query was referenced after the memory was freed by
next_server(). I've changed that so next_server() and end_query() returns the
next query. So callers should use this ret-value.
The next problem was that 'server->tcp_buffer_pos' had a random value at entry
to 1st recv() (luckily causing Winsock to return ENOBUFS).
I've also added a ares_writev() for Windows to streamline the code
a bit more.
Diffstat (limited to 'ares/windows_port.c')
-rw-r--r-- | ares/windows_port.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ares/windows_port.c b/ares/windows_port.c index 9611e054e..ac6ffb272 100644 --- a/ares/windows_port.c +++ b/ares/windows_port.c @@ -5,6 +5,8 @@ #include <stdlib.h> #include <ctype.h> #include <string.h> +#include <errno.h> +#include <malloc.h> #include "nameser.h" @@ -52,4 +54,36 @@ ares_gettimeofday(struct timeval *tv, struct timezone *tz) return 0; } +int +ares_writev (SOCKET s, const struct iovec *vector, size_t count) +{ + char *buffer, *bp; + size_t i, bytes = 0; + + /* Find the total number of bytes to write + */ + for (i = 0; i < count; i++) + bytes += vector[i].iov_len; + + if (bytes == 0) /* not an error */ + return (0); + + /* Allocate a temporary buffer to hold the data + */ + buffer = bp = (char*) alloca (bytes); + if (!buffer) + { + errno = ENOMEM; + return (-1); + } + + /* Copy the data into buffer. + */ + for (i = 0; i < count; ++i) + { + memcpy (bp, vector[i].iov_base, vector[i].iov_len); + bp += vector[i].iov_len; + } + return send (s, (const void*)buffer, bytes, 0); +} #endif /* WIN32 builds only */ |