This is typically more efficient on the kernel call stack.
As far as I can see writev_send/recv is only used with sockets
so far, but in any case we fallback on ENOTSOCK.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
struct tevent_context *ev;
struct tevent_queue_entry *queue_entry;
int fd;
+ bool is_sock;
struct tevent_fd *fde;
struct iovec *iov;
int count;
}
state->ev = ev;
state->fd = fd;
+ state->is_sock = true;
state->total_size = 0;
state->count = count;
state->iov = (struct iovec *)talloc_memdup(
ssize_t written;
bool ok;
- written = writev(state->fd, state->iov, state->count);
+ if (state->is_sock) {
+ struct msghdr msg = {
+ .msg_iov = state->iov,
+ .msg_iovlen = state->count,
+ };
+
+ written = sendmsg(state->fd, &msg, 0);
+ if ((written == -1) && (errno == ENOTSOCK)) {
+ state->is_sock = false;
+ }
+ }
+ if (!state->is_sock) {
+ written = writev(state->fd, state->iov, state->count);
+ }
if ((written == -1) &&
((errno == EINTR) ||
(errno == EAGAIN) ||