Skip to content

Commit 2fd33bf

Browse files
committedMar 10, 2016
use calling frame when given else look it up
1 parent 202364f commit 2fd33bf

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed
 

‎vm/builtin/io.cpp

+12-8
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ namespace rubinius {
5252
return io;
5353
}
5454

55-
native_int IO::descriptor(STATE) {
56-
NativeMethodEnvironment* native_env = state->vm()->native_method_environment;
57-
Object* io_object = (Object*) native_env->current_call_frame()->self();
55+
native_int IO::descriptor(STATE, CallFrame* frame) {
56+
if (!frame) {
57+
NativeMethodEnvironment* native_env = state->vm()->native_method_environment;
58+
frame = native_env->current_call_frame();
59+
}
5860

59-
return as<Fixnum>(io_object->send(state, native_env->current_call_frame(), state->symbol("descriptor")))->to_native();
61+
assert(frame);
62+
Object* io_object = (Object*) frame->self();
63+
return as<Fixnum>(io_object->send(state, frame, state->symbol("descriptor")))->to_native();
6064
}
6165

6266
void IO::ensure_open(STATE) {
@@ -157,7 +161,7 @@ namespace rubinius {
157161

158162
{
159163
GCIndependent guard(state, calling_environment);
160-
bytes_read = recvfrom(descriptor(state),
164+
bytes_read = recvfrom(descriptor(state, calling_environment),
161165
(char*)buffer->byte_address(), size,
162166
flags->to_native(),
163167
(struct sockaddr*)buf, &alen);
@@ -412,7 +416,7 @@ namespace rubinius {
412416
struct cmsghdr *cmsg;
413417
char cmsg_buf[cmsg_space];
414418

415-
fd = io->descriptor(state);
419+
fd = io->descriptor(state, NULL);
416420

417421
msg.msg_name = NULL;
418422
msg.msg_namelen = 0;
@@ -437,7 +441,7 @@ namespace rubinius {
437441
int* fd_data = (int*)CMSG_DATA(cmsg);
438442
*fd_data = fd;
439443

440-
if(sendmsg(descriptor(state), &msg, 0) == -1) {
444+
if(sendmsg(descriptor(state, NULL), &msg, 0) == -1) {
441445
return Primitives::failure();
442446
}
443447

@@ -479,7 +483,7 @@ namespace rubinius {
479483
int* fd_data = (int *)CMSG_DATA(cmsg);
480484
*fd_data = -1;
481485

482-
int read_fd = descriptor(state);
486+
int read_fd = descriptor(state, NULL);
483487

484488
int code = -1;
485489

‎vm/builtin/io.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace rubinius {
1919
static void init(STATE);
2020
static IO* create(STATE, int fd);
2121

22-
native_int descriptor(STATE);
22+
native_int descriptor(STATE, CallFrame* frame);
2323
void ensure_open(STATE);
2424

2525
/* Class primitives */

0 commit comments

Comments
 (0)