Skip to content

Commit 0ef9533

Browse files
committed
Shutdown and close never fail
1 parent 86a6a5b commit 0ef9533

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

libraries/common/io/network.effekt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ def read(handle: Connection, buffer: ByteArray, offset: Int, size: Int): Int / E
1717
def write(handle: Connection, buffer: ByteArray, offset: Int, size: Int): Int / Exception[IOError] =
1818
internal::checkResult(internal::write(handle, buffer, offset, size))
1919

20-
def close(handle: Connection): Unit / Exception[IOError] = {
21-
internal::checkResult(internal::close(handle)); ()
22-
}
20+
def close(handle: Connection): Unit =
21+
internal::close(handle)
2322

2423
/// A tcp listener. Should not be inspected.
2524
type Listener = Int
@@ -31,9 +30,8 @@ def listen(listener: Listener, handler: Connection => Unit at {io, async, global
3130
internal::checkResult(internal::listen(listener, handler)); ()
3231
}
3332

34-
def shutdown(listener: Listener): Unit / Exception[IOError] = {
35-
internal::checkResult(internal::shutdown(listener)); ()
36-
}
33+
def shutdown(listener: Listener): Unit =
34+
internal::shutdown(listener)
3735

3836
namespace internal {
3937

@@ -67,7 +65,7 @@ namespace internal {
6765
ret void
6866
"""
6967

70-
extern async def close(handle: Int): Int =
68+
extern async def close(handle: Int): Unit =
7169
llvm """
7270
call void @c_tcp_close(%Int ${handle}, %Stack %stack)
7371
ret void
@@ -85,7 +83,7 @@ namespace internal {
8583
ret void
8684
"""
8785

88-
extern async def shutdown(handle: Int): Int =
86+
extern async def shutdown(handle: Int): Unit =
8987
llvm """
9088
call void @c_tcp_shutdown(%Int ${handle}, %Stack %stack)
9189
ret void

libraries/llvm/io.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,7 @@ void c_tcp_write(Int handle, struct Pos buffer, Int offset, Int size, Stack stac
307307
void c_tcp_close_cb(uv_handle_t* handle) {
308308
Stack stack = (Stack)handle->data;
309309
free(handle);
310-
// TODO resume_Pos Unit
311-
resume_Int(stack, 0);
310+
resume_Pos(stack, Unit);
312311
}
313312

314313
void c_tcp_close(Int handle, Stack stack) {

0 commit comments

Comments
 (0)