Skip to content

Commit

Permalink
add missing changes from #10136 that may have been lost during a reba…
Browse files Browse the repository at this point in the history
…se (#10975)

Mentioned in #10831 review comment on runtime/io.c:552.

Co-authored-by: sabine <sabine@tarides.com>
  • Loading branch information
sabine and sabine committed Feb 1, 2022
1 parent 6a7a7b3 commit 9a7b6ac
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions runtime/io.c
Expand Up @@ -605,8 +605,6 @@ CAMLprim value caml_ml_set_channel_name(value vchannel, value vname)
return Val_unit;
}

#define Pair_tag 0

struct channel_list {
struct channel* channel;
struct channel_list* next;
Expand All @@ -626,7 +624,8 @@ CAMLprim value caml_ml_out_channels_list (value unit)
channel = channel->next) {
/* Testing channel->fd >= 0 looks unnecessary, as
caml_ml_close_channel changes max when setting fd to -1. */
if (channel->max == NULL) {
if (channel->max == NULL
&& channel->flags & CHANNEL_FLAG_MANAGED_BY_GC) {
/* refcount is incremented here to keep the channel alive */
atomic_fetch_add (&channel->refcount, 1);
num_channels++;
Expand All @@ -648,7 +647,7 @@ CAMLprim value caml_ml_out_channels_list (value unit)
* our earlier increment */
atomic_fetch_add (&channel_list->channel->refcount, -1);
tail = res;
res = caml_alloc_small (2, Pair_tag);
res = caml_alloc_small (2, Tag_cons);
Field (res, 0) = chan;
Field (res, 1) = tail;
cl_tmp = channel_list;
Expand Down

0 comments on commit 9a7b6ac

Please sign in to comment.