Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
2458-Realloc-instead-of-sub-binaries.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2458-Realloc-instead-of-sub-binaries.patch of Package erlang
From f5d23227741a4ff8e0dee92c2a01c38fa1d06a32 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen <raimo@erlang.org> Date: Thu, 18 Jan 2024 17:10:21 +0100 Subject: [PATCH 08/14] Realloc instead of sub binaries --- erts/emulator/nifs/common/socket_int.h | 2 +- erts/emulator/nifs/unix/unix_socket_syncio.c | 21 +++++--------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/erts/emulator/nifs/common/socket_int.h b/erts/emulator/nifs/common/socket_int.h index 0d0dbc059e..a9df0d311d 100644 --- a/erts/emulator/nifs/common/socket_int.h +++ b/erts/emulator/nifs/common/socket_int.h @@ -687,7 +687,7 @@ GLOBAL_ERROR_REASON_ATOM_DEFS; #define GET_MAP_VAL(E, M, K, V) enif_get_map_value((E), (M), (K), (V)) #define ALLOC_BIN(SZ, BP) enif_alloc_binary((SZ), (BP)) -#define REALLOC_BIN(SZ, BP) enif_realloc_binary((SZ), (BP)) +#define REALLOC_BIN(BP, SZ) enif_realloc_binary((BP), (SZ)) #define FREE_BIN(BP) enif_release_binary((BP)) #define FREE_IOVEC(IV) enif_free_iovec((IV)) diff --git a/erts/emulator/nifs/unix/unix_socket_syncio.c b/erts/emulator/nifs/unix/unix_socket_syncio.c index a2a92c02ad..332d72b599 100644 --- a/erts/emulator/nifs/unix/unix_socket_syncio.c +++ b/erts/emulator/nifs/unix/unix_socket_syncio.c @@ -2858,21 +2858,10 @@ ERL_NIF_TERM recvfrom_check_result(ErlNifEnv* env, fromAddrP, fromAddrLen, &eSockAddr); - if (read == bufP->size) { - - data = MKBIN(env, bufP); - - } else { - - /* +++ We got a chunk of data but +++ - * +++ since we did not fill the +++ - * +++ buffer, we must split it +++ - * +++ into a sub-binary. +++ - */ - - data = MKBIN(env, bufP); - data = MKSBIN(env, data, 0, read); + if (read != bufP->size) { + ESOCK_ASSERT( REALLOC_BIN(bufP, read) ); } + data = MKBIN(env, bufP); ESOCK_CNT_INC(env, descP, sockRef, esock_atom_read_pkg, &descP->readPkgCnt, 1); @@ -7254,8 +7243,8 @@ ERL_NIF_TERM recv_check_partial_done(ErlNifEnv* env, /* This transfers "ownership" of the *allocated* binary to an * erlang term (no need for an explicit free). */ + ESOCK_ASSERT( REALLOC_BIN(bufP, read) ); data = MKBIN(env, bufP); - data = MKSBIN(env, data, 0, read); SSDBG( descP, ("UNIX-ESSIO", "recv_check_partial_done(%T) {%d} -> [%ld] done\r\n", @@ -7304,8 +7293,8 @@ ERL_NIF_TERM recv_check_partial_part(ErlNifEnv* env, ERL_NIF_TERM data; descP->readState |= ESOCK_STATE_SELECTED; + ESOCK_ASSERT( REALLOC_BIN(bufP, read) ); data = MKBIN(env, bufP); - data = MKSBIN(env, data, 0, read); res = MKT2(env, esock_atom_select, data); } -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor