Skip to content

Commit

Permalink
Include Backend#splice_chunks only on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
noteflakes committed Jul 21, 2023
1 parent c577211 commit 04c83e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/polyphony/backend_libev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,7 @@ static inline int splice_chunks_splice(Backend_t *backend, int src_fd, int dest_
#endif
}

#ifdef POLYPHONY_LINUX
VALUE Backend_splice_chunks(VALUE self, VALUE src, VALUE dest, VALUE prefix, VALUE postfix, VALUE chunk_prefix, VALUE chunk_postfix, VALUE chunk_size) {
Backend_t *backend;
GetBackend(self, backend);
Expand Down Expand Up @@ -1595,6 +1596,7 @@ VALUE Backend_splice_chunks(VALUE self, VALUE src, VALUE dest, VALUE prefix, VAL
if (pipefd[1] != -1) close(pipefd[1]);
return RAISE_EXCEPTION(result);
}
#endif

VALUE Backend_trace(int argc, VALUE *argv, VALUE self) {
Backend_t *backend;
Expand Down Expand Up @@ -1660,7 +1662,10 @@ void Init_Backend(void) {
rb_define_method(cBackend, "chain", Backend_chain, -1);
rb_define_method(cBackend, "idle_gc_period=", Backend_idle_gc_period_set, 1);
rb_define_method(cBackend, "idle_proc=", Backend_idle_proc_set, 1);

#ifdef POLYPHONY_LINUX
rb_define_method(cBackend, "splice_chunks", Backend_splice_chunks, 7);
#endif

rb_define_method(cBackend, "accept", Backend_accept, 2);
rb_define_method(cBackend, "accept_loop", Backend_accept_loop, 2);
Expand Down
2 changes: 2 additions & 0 deletions test/test_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ def test_nested_timeout
end

def test_splice_chunks
skip if !Thread.current.backend.respond_to?(:splice_chunks)

body = 'abcd' * 4
chunk_size = 12

Expand Down

0 comments on commit 04c83e1

Please sign in to comment.