mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Untested (and compiled-out) evbuffer_write backend to use WSASend on win32 where we use writev on unix.
svn:r998
This commit is contained in:
parent
fbd5e820d7
commit
822ca048ad
28
buffer.c
28
buffer.c
@ -922,8 +922,34 @@ evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd,
|
||||
void *p = evbuffer_pullup(buffer, howmuch);
|
||||
n = write(fd, p, howmuch, 0);
|
||||
#endif
|
||||
#elif 0
|
||||
const int N_BUFFERS 8;
|
||||
WSABUF buffers[N_BUFFERS];
|
||||
struct evbuffer_chain *chain = buffer->first;
|
||||
int i = 0;
|
||||
DWORD bytesSent;
|
||||
/* XXX make this top out at some maximal data length? if the buffer has
|
||||
* (say) 1MB in it, split over 128 chains, there's no way it all gets
|
||||
* written in one go. */
|
||||
while (chain != NULL && i < N_BUFFERS && howmuch) {
|
||||
buffers[i].buf = chain->buffer + chain->misalign;
|
||||
if (howmuch >= chain->off) {
|
||||
buffers[i++].len = chain->off;
|
||||
howmuch -= chain->off;
|
||||
} else {
|
||||
buffers[i++].len = howmuch;
|
||||
break;
|
||||
}
|
||||
chain = chain->next;
|
||||
}
|
||||
|
||||
if (WSASend(s, buffers, i, &bytesSent, 0, NULL, NULL))
|
||||
n = -1;
|
||||
else
|
||||
n = bytesSent;
|
||||
#else
|
||||
/* XXX(niels): investigate if windows has writev */
|
||||
/* XXX(nickm) Don't disable this code until we know if the WSARecv
|
||||
* code above works. */
|
||||
void *p = evbuffer_pullup(buffer, howmuch);
|
||||
n = send(fd, p, howmuch, 0);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user