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
chuckremes committed Mar 10, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 202364f commit 2fd33bf
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions vm/builtin/io.cpp
Original file line number Diff line number Diff line change
@@ -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) {
@@ -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);
@@ -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;
@@ -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();
}

@@ -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;

2 changes: 1 addition & 1 deletion vm/builtin/io.hpp
Original file line number Diff line number Diff line change
@@ -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 */

0 comments on commit 2fd33bf

Please sign in to comment.