@@ -1502,6 +1502,9 @@ void janet_loop1_impl(int has_timeout, JanetTimestamp to) {
1502
1502
state = state -> _next ;
1503
1503
}
1504
1504
}
1505
+ if (stream -> flags |= JANET_STREAM_CLOSING ) {
1506
+ janet_stream_close (stream );
1507
+ }
1505
1508
}
1506
1509
}
1507
1510
}
@@ -1656,6 +1659,9 @@ void janet_loop1_impl(int has_timeout, JanetTimestamp timeout) {
1656
1659
janet_unlisten (state , 0 );
1657
1660
state = next_state ;
1658
1661
}
1662
+ if (stream -> flags |= JANET_STREAM_CLOSING ) {
1663
+ janet_stream_close (stream );
1664
+ }
1659
1665
}
1660
1666
}
1661
1667
}
@@ -1854,6 +1860,9 @@ void janet_loop1_impl(int has_timeout, JanetTimestamp timeout) {
1854
1860
1855
1861
state = next_state ;
1856
1862
}
1863
+ if (stream -> flags |= JANET_STREAM_CLOSING ) {
1864
+ janet_stream_close (stream );
1865
+ }
1857
1866
}
1858
1867
}
1859
1868
}
@@ -1970,6 +1979,9 @@ void janet_loop1_impl(int has_timeout, JanetTimestamp timeout) {
1970
1979
status3 == JANET_ASYNC_STATUS_DONE ||
1971
1980
status4 == JANET_ASYNC_STATUS_DONE )
1972
1981
janet_unlisten (state , 0 );
1982
+ if (state -> stream -> flags |= JANET_STREAM_CLOSING ) {
1983
+ janet_stream_close (state -> stream );
1984
+ }
1973
1985
}
1974
1986
}
1975
1987
@@ -2495,11 +2507,11 @@ static JanetAsyncStatus handle_connect(JanetListenerState *s) {
2495
2507
if (res == 0 ) {
2496
2508
janet_schedule (s -> fiber , janet_wrap_abstract (s -> stream ));
2497
2509
} else {
2498
- // TODO help needed. janet_stream_close( s->stream) ;
2510
+ s -> stream -> flags |= JANET_STREAM_CLOSING ;
2499
2511
janet_cancel (s -> fiber , janet_cstringv (strerror (res )));
2500
2512
}
2501
2513
} else {
2502
- // TODO help needed. janet_stream_close( s->stream) ;
2514
+ s -> stream -> flags |= JANET_STREAM_CLOSING ;
2503
2515
janet_cancel (s -> fiber , janet_ev_lasterr ());
2504
2516
}
2505
2517
return JANET_ASYNC_STATUS_DONE ;
0 commit comments