diff options
author | Jean Boussier <[email protected]> | 2022-09-20 16:10:56 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2023-08-30 10:07:18 +0200 |
commit | bcc905100f1079e191632cfd02319c10af82dac0 (patch) | |
tree | e8dbe37eb4de741c51210f65ffaa0336ce579c8a /ext/socket/ancdata.c | |
parent | acedbcb1b4eb6b362f11e783bff53c237d05afc6 (diff) |
BasicSocket#recv* return `nil` rather than an empty packet
[Bug #19012]
man recvmsg(2) states:
> Return Value
> These calls return the number of bytes received, or -1 if an error occurred.
> The return value will be 0 when the peer has performed an orderly shutdown.
Not too sure how one is supposed to make the difference between a packet of
size 0 and a closed connection.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6407
Diffstat (limited to 'ext/socket/ancdata.c')
-rw-r--r-- | ext/socket/ancdata.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c index 7406177de2..6ef040b692 100644 --- a/ext/socket/ancdata.c +++ b/ext/socket/ancdata.c @@ -1555,6 +1555,10 @@ bsock_recvmsg_internal(VALUE sock, ss = rb_recvmsg(fptr->fd, &mh, flags); + if (ss == 0 && !rsock_is_dgram(fptr)) { + return Qnil; + } + if (ss == -1) { int e; if (!nonblock && rb_io_maybe_wait_readable(errno, fptr->self, RUBY_IO_TIMEOUT_DEFAULT)) { |