Skip to content

Commit 9b0fdcf

Browse files
committed
erts: Guard the linger check for portability
SO_LINGER is guarded everywhere else in the file, so guard the new check too. Without the option a close cannot linger, so the dirty scheduler is skipped. Also use SOCKOPTLEN_T for the option length like every other getsockopt call in the file; SOCKLEN_T falls back to size_t on Windows where getsockopt writes through an int pointer.
1 parent 6be6a8e commit 9b0fdcf

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

erts/emulator/nifs/common/prim_socket_nif.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7653,8 +7653,9 @@ ERL_NIF_TERM nif_finalize_close_dirty(ErlNifEnv* env,
76537653
static
76547654
BOOLEAN_T finalize_close_may_block(ESockDescriptor* descP)
76557655
{
7656+
#if defined(SO_LINGER)
76567657
struct linger lval;
7657-
SOCKLEN_T lsz = sizeof(lval);
7658+
SOCKOPTLEN_T lsz = sizeof(lval);
76587659

76597660
if (descP->sock == INVALID_SOCKET)
76607661
return FALSE;
@@ -7664,6 +7665,10 @@ BOOLEAN_T finalize_close_may_block(ESockDescriptor* descP)
76647665
return TRUE;
76657666

76667667
return (lval.l_onoff != 0) && (lval.l_linger > 0);
7668+
#else
7669+
/* Without SO_LINGER a close cannot linger, so it cannot block */
7670+
return FALSE;
7671+
#endif
76677672
}
76687673

76697674

0 commit comments

Comments
 (0)