diff options
-rw-r--r-- | socket.c | 3 | ||||
-rw-r--r-- | stream.c | 13 | ||||
-rw-r--r-- | sysif.c | 6 |
3 files changed, 8 insertions, 14 deletions
@@ -552,9 +552,6 @@ static val dgram_get_prop(val stream, val ind) { struct dgram_stream *d = coerce(struct dgram_stream *, stream->co.handle); - if (ind == fd_k) - return num(d->fd); - if (ind == name_k) { if (d->fd == -1) return lit("closed"); @@ -217,11 +217,6 @@ static noreturn val unimpl_truncate(val stream, val len) unimpl(stream, lit("truncate-stream")); } -static noreturn val unimpl_get_fd(val stream) -{ - unimpl(stream, lit("fileno")); -} - static noreturn val unimpl_get_sock_family(val stream) { unimpl(stream, lit("sock-family")); @@ -421,7 +416,7 @@ void fill_stream_ops(struct strm_ops *ops) if (!ops->clear_error) ops->clear_error = null_clear_error; if (!ops->get_fd) - ops->get_fd = unimpl_get_fd; + ops->get_fd = null_get_fd; if (!ops->get_sock_family) ops->get_sock_family = unimpl_get_sock_family; if (!ops->get_sock_type) @@ -726,8 +721,6 @@ static val stdio_get_prop(val stream, val ind) return h->is_real_time ? t : nil; } else if (ind == name_k) { return h->descr; - } else if (ind == fd_k) { - return h->f ? num(fileno(h->f)) : nil; } else if (ind == byte_oriented_k) { return h->is_byte_oriented ? t : nil; } @@ -2896,6 +2889,10 @@ val stream_get_prop(val stream, val ind) val self = lit("stream-get-prop"); struct strm_ops *ops = coerce(struct strm_ops *, cobj_ops(self, stream, stream_s)); + + if (ind == fd_k && ops->get_fd != null_get_fd) + return ops->get_fd(stream); + return ops->get_prop(stream, ind); } @@ -303,7 +303,7 @@ static val mkdir_wrap(val path, val mode) #if HAVE_CHMOD || HAVE_CHOWN || HAVE_SYS_STAT || HAVE_FILE_STAMP_CHANGE static int get_fd(val stream, val self) { - val fd_in = if3(integerp(stream), stream, stream_get_prop(stream, fd_k)); + val fd_in = if3(integerp(stream), stream, stream_fd(stream)); if (stream && !fd_in) uw_throwf(file_error_s, @@ -1326,7 +1326,7 @@ static val poll_wrap(val poll_list, val timeout_in) break; case COBJ: if (subtypep(obj->co.cls, stream_s)) { - val fdval = stream_get_prop(obj, fd_k); + val fdval = stream_fd(obj); if (!fdval) { free(pfd); uw_throwf(file_error_s, @@ -1553,7 +1553,7 @@ void simulate_setuid_setgid(val open_script) return; { - val fdv = stream_get_prop(open_script, fd_k); + val fdv = stream_fd(open_script); if (fdv) { struct stat stb; |