Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions erts/emulator/drivers/common/inet_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -8831,7 +8831,12 @@ static int sctp_set_opts(inet_descriptor* desc, char* ptr, int len)
proto = IPPROTO_SCTP;
type = SCTP_EVENTS;
arg_ptr = (char*) (&arg.es);
#if defined(__linux__)
arg_sz = offsetof(struct sctp_event_subscribe,
sctp_adaptation_layer_event) + 1;
#else
arg_sz = sizeof ( arg.es);
#endif
break;
}
/* The following is not available on
Expand Down
12 changes: 11 additions & 1 deletion erts/emulator/nifs/common/prim_socket_nif.c
Original file line number Diff line number Diff line change
Expand Up @@ -8010,6 +8010,8 @@ ERL_NIF_TERM esock_setopt_sctp_events(ErlNifEnv* env,
{
struct sctp_event_subscribe events;
BOOLEAN_T error;
int last_opt = offsetof(struct sctp_event_subscribe,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you could add a "#if defined(linux) ... #endif" around all the last_opt assignments.
Unless you are counting on the compiler optimizing those away on non-linux?

sctp_adaptation_layer_event) + 1;

SSDBG( descP,
("SOCKET", "esock_setopt_sctp_events {%d} -> entry with"
Expand Down Expand Up @@ -8047,20 +8049,28 @@ ERL_NIF_TERM esock_setopt_sctp_events(ErlNifEnv* env,
#if defined(HAVE_STRUCT_SCTP_EVENT_SUBSCRIBE_SCTP_AUTHENTICATION_EVENT)
events.sctp_authentication_event =
esock_setopt_sctp_event(env, eVal, atom_authentication, &error);
last_opt = offsetof(struct sctp_event_subscribe,
sctp_authentication_event) + 1;
#endif

#if defined(HAVE_STRUCT_SCTP_EVENT_SUBSCRIBE_SCTP_SENDER_DRY_EVENT)
events.sctp_sender_dry_event =
esock_setopt_sctp_event(env, eVal, atom_sender_dry, &error);
last_opt = offsetof(struct sctp_event_subscribe, sctp_sender_dry_event) + 1;
#endif

if (error) {
goto invalid;
} else {
ERL_NIF_TERM result;
#if defined(__linux__)
int arg_sz = last_opt;
#else
int arg_sz = sizeof(events);
#endif

result = esock_setopt_level_opt(env, descP, level, opt,
&events, sizeof(events));
&events, arg_sz);
SSDBG( descP,
("SOCKET",
"esock_setopt_sctp_events {%d} -> set events -> %T\r\n",
Expand Down
Loading