From 459fa41f178d68d227d381201f279c3ea27d35b7 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 23 Nov 2023 13:58:00 -0500 Subject: [PATCH] network/stack: Get rid of socket_readv and socket_writev. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These have not been used in years (maybe since the redesign of the network stack?). Only socket_writev had an implementation, which was mostly just an incomplete version of socket_send. Scatter/gather I/O is already supported via msghdr's msg_iov/len fields, so this is redundant anyway. Change-Id: If41c4f4ee021856f6db49c7cb95422a9c1aa7700 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7127 Reviewed-by: waddlesplash Tested-by: Commit checker robot Reviewed-by: Adrien Destugues Reviewed-by: Jérôme Duval --- headers/private/net/net_socket.h | 4 -- .../kernel/network/stack/net_socket.cpp | 59 ------------------- 2 files changed, 63 deletions(-) diff --git a/headers/private/net/net_socket.h b/headers/private/net/net_socket.h index af6a85e971..3a0558cc41 100644 --- a/headers/private/net/net_socket.h +++ b/headers/private/net/net_socket.h @@ -52,10 +52,6 @@ struct net_socket_module_info { status_t (*close)(net_socket* socket); void (*free)(net_socket* socket); - status_t (*readv)(net_socket* socket, const iovec* vecs, - size_t vecCount, size_t* _length); - status_t (*writev)(net_socket* socket, const iovec* vecs, - size_t vecCount, size_t* _length); status_t (*control)(net_socket* socket, uint32 op, void* data, size_t length); diff --git a/src/add-ons/kernel/network/stack/net_socket.cpp b/src/add-ons/kernel/network/stack/net_socket.cpp index 8196eee8f4..a0f6e0d956 100644 --- a/src/add-ons/kernel/network/stack/net_socket.cpp +++ b/src/add-ons/kernel/network/stack/net_socket.cpp @@ -459,63 +459,6 @@ socket_free(net_socket* _socket) } -status_t -socket_readv(net_socket* socket, const iovec* vecs, size_t vecCount, - size_t* _length) -{ - return -1; -} - - -status_t -socket_writev(net_socket* socket, const iovec* vecs, size_t vecCount, - size_t* _length) -{ - if (socket->peer.ss_len == 0) - return ECONNRESET; - - if (socket->address.ss_len == 0) { - // try to bind first - status_t status = socket_bind(socket, NULL, 0); - if (status != B_OK) - return status; - } - - // TODO: useful, maybe even computed header space! - net_buffer* buffer = gNetBufferModule.create(256); - if (buffer == NULL) - return ENOBUFS; - - // copy data into buffer - - for (uint32 i = 0; i < vecCount; i++) { - if (gNetBufferModule.append(buffer, vecs[i].iov_base, - vecs[i].iov_len) < B_OK) { - gNetBufferModule.free(buffer); - return ENOBUFS; - } - } - - memcpy(buffer->source, &socket->address, socket->address.ss_len); - memcpy(buffer->destination, &socket->peer, socket->peer.ss_len); - size_t size = buffer->size; - - ssize_t bytesWritten = socket->first_info->send_data(socket->first_protocol, - buffer); - if (bytesWritten < B_OK) { - if (buffer->size != size) { - // this appears to be a partial write - *_length = size - buffer->size; - } - gNetBufferModule.free(buffer); - return bytesWritten; - } - - *_length = bytesWritten; - return B_OK; -} - - status_t socket_control(net_socket* socket, uint32 op, void* data, size_t length) { @@ -1747,8 +1690,6 @@ net_socket_module_info gNetSocketModule = { socket_close, socket_free, - socket_readv, - socket_writev, socket_control, socket_read_avail,