Skip to content

Commit

Permalink
use calling frame when given else look it up
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckremes committed Mar 10, 2016
1 parent 202364f commit 2fd33bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions vm/builtin/io.cpp
Expand Up @@ -52,11 +52,15 @@ namespace rubinius {
return io;
}

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

return as<Fixnum>(io_object->send(state, native_env->current_call_frame(), state->symbol("descriptor")))->to_native();
assert(frame);
Object* io_object = (Object*) frame->self();
return as<Fixnum>(io_object->send(state, frame, state->symbol("descriptor")))->to_native();
}

void IO::ensure_open(STATE) {
Expand Down Expand Up @@ -157,7 +161,7 @@ namespace rubinius {

{
GCIndependent guard(state, calling_environment);
bytes_read = recvfrom(descriptor(state),
bytes_read = recvfrom(descriptor(state, calling_environment),
(char*)buffer->byte_address(), size,
flags->to_native(),
(struct sockaddr*)buf, &alen);
Expand Down Expand Up @@ -412,7 +416,7 @@ namespace rubinius {
struct cmsghdr *cmsg;
char cmsg_buf[cmsg_space];

fd = io->descriptor(state);
fd = io->descriptor(state, NULL);

msg.msg_name = NULL;
msg.msg_namelen = 0;
Expand All @@ -437,7 +441,7 @@ namespace rubinius {
int* fd_data = (int*)CMSG_DATA(cmsg);
*fd_data = fd;

if(sendmsg(descriptor(state), &msg, 0) == -1) {
if(sendmsg(descriptor(state, NULL), &msg, 0) == -1) {
return Primitives::failure();
}

Expand Down Expand Up @@ -479,7 +483,7 @@ namespace rubinius {
int* fd_data = (int *)CMSG_DATA(cmsg);
*fd_data = -1;

int read_fd = descriptor(state);
int read_fd = descriptor(state, NULL);

int code = -1;

Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/io.hpp
Expand Up @@ -19,7 +19,7 @@ namespace rubinius {
static void init(STATE);
static IO* create(STATE, int fd);

native_int descriptor(STATE);
native_int descriptor(STATE, CallFrame* frame);
void ensure_open(STATE);

/* Class primitives */
Expand Down

0 comments on commit 2fd33bf

Please sign in to comment.