network/stack: Get rid of socket_readv and socket_writev.

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 <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
Augustin Cavalier 2023-11-23 13:58:00 -05:00 committed by waddlesplash
parent 9d972e321d
commit 459fa41f17
2 changed files with 0 additions and 63 deletions

View File

@ -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);

View File

@ -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,