Skip to content

Commit 8c04c09

Browse files
Fix copy-past typo in tickit_watch_io()
GH#8 Added test for the situation.
1 parent e1a9c7d commit 8c04c09

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/tickit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ void *tickit_watch_io(Tickit *t, int fd, TickitIOCondition cond, TickitBindFlags
466466
watch->t = t;
467467
watch->type = WATCH_IO;
468468

469-
watch->flags = flags & (TICKIT_BIND_UNBIND|TICKIT_BIND_UNBIND);
469+
watch->flags = flags & (TICKIT_BIND_UNBIND|TICKIT_BIND_DESTROY);
470470
watch->fn = fn;
471471
watch->user = user;
472472

t/51tickit-io.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
int captured_fd;
88
TickitIOCondition captured_cond;
9+
static int unbound_count;
910

1011
static int on_call_incr(Tickit *t, TickitEventFlags flags, void *_info, void *user)
1112
{
@@ -20,6 +21,8 @@ static int on_call_incr(Tickit *t, TickitEventFlags flags, void *_info, void *us
2021

2122
tickit_stop(t);
2223
}
24+
if(flags & TICKIT_EV_UNBIND)
25+
unbound_count++;
2326

2427
return 1;
2528
}
@@ -90,9 +93,22 @@ int main(int argc, char *argv[])
9093
tickit_watch_cancel(t, watch);
9194
}
9295

93-
close(fds[0]);
94-
9596
tickit_unref(t);
9697

98+
/* object destruction */
99+
{
100+
t = tickit_new_for_term(tickit_mockterm_new(25, 80));
101+
102+
tickit_watch_io(t, fds[0], TICKIT_IO_IN, TICKIT_BIND_DESTROY, &on_call_incr, NULL);
103+
104+
unbound_count = 0;
105+
106+
tickit_unref(t);
107+
108+
is_int(unbound_count, 1, "unbound_count after tickit_unref");
109+
}
110+
111+
close(fds[0]);
112+
97113
return exit_status();
98114
}

0 commit comments

Comments
 (0)