10000 merge revision(s) 45066: [Backport #9545] [Backport #9550] · github/ruby@dc8c558 · GitHub
[go: up one dir, main page]

Skip to content

Commit dc8c558

Browse files
committed
merge revision(s) 45066: [Backport ruby#9545] [Backport ruby#9550]
* ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error (bsock_recvmsg_internal): ditto * test/socket/test_unix.rb: test above for infinite loop git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 61d1261 commit dc8c558

File tree

4 files changed

+38
-11
lines changed

4 files changed

+38
-11
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Sat Feb 22 16:17:54 2014 Eric Wong <e@80x24.org>
2+
3+
* ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error
4+
(bsock_recvmsg_internal): ditto
5+
* test/socket/test_unix.rb: test above for infinite loop
6+
17
Sat Feb 22 15:56:53 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
28

39
* thread_pthread.c (rb_thread_create_timer_thread): fix for platforms

ext/socket/ancdata.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,12 +1280,11 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
12801280

12811281
ss = rb_sendmsg(fptr->fd, &mh, flags);
12821282

1283-
if (!nonblock && rb_io_wait_writable(fptr->fd)) {
1284-
rb_io_check_closed(fptr);
1285-
goto retry;
1286-
}
1287-
12881283
if (ss == -1) {
1284+
if (!nonblock && rb_io_wait_writable(fptr->fd)) {
1285+
rb_io_check_closed(fptr);
1286+
goto retry;
1287+
}
12891288
if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
12901289
rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "sendmsg(2) would block");
12911290
rb_sys_fail("sendmsg(2)");
@@ -1595,12 +1594,11 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
15951594

15961595
ss = rb_recvmsg(fptr->fd, &mh, flags);
15971596

1598-
if (!nonblock && rb_io_wait_readable(fptr->fd)) {
1599-
rb_io_check_closed(fptr);
1600-
goto retry;
1601-
}
1602-
16031597
if (ss == -1) {
1598+
if (!nonblock && rb_io_wait_readable(fptr->fd)) {
1599+
rb_io_check_closed(fptr);
1600+
goto retry;
1601+
}
16041602
if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
16051603
rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "recvmsg(2) would block");
16061604
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)

test/socket/test_unix.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
require "test/unit"
77
require "tempfile"
8+
require "timeout"
89
require "tmpdir"
910
require "thread"
1011
require "io/nonblock"
@@ -369,6 +370,28 @@ def test_dgram_pair
369370
s2.close if s2
370371
end
371372

373+
def test_dgram_pair_sendrecvmsg_errno_set
374+
s1, s2 = to_close = UNIXSocket.pair(Socket::SOCK_DGRAM)
375+
pipe = IO.pipe
376+
to_close.concat(pipe)
377+
set_errno = lambda do
378+
begin
379+
pipe[0].read_nonblock(1)
380+
fail
381+
rescue => e
382+
assert(IO::EAGAINWaitReadable === e)
383+
end
384+
end
385+
Timeout.timeout(10) do
386+
set_errno.call
387+
assert_equal(2, s1.sendmsg("HI"))
388+
set_errno.call
389+
assert_equal("HI", s2.recvmsg[0])
390+
end
391+
ensure
392+
to_close.each(&:close) if to_close
393+
end
394+
372395
def test_epipe # [ruby-dev:34619]
373396
s1, s2 = UNIXSocket.pair
374397
s1.shutdown(Socket::SHUT_WR)

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.1"
22
#define RUBY_RELEASE_DATE "2014-02-22"
3-
#define RUBY_PATCHLEVEL 64
3+
#define RUBY_PATCHLEVEL 65
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 2

0 commit comments

Comments
 (0)
0