Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ required-features = ["headers"] # Do not build unless generating headers.
[dependencies]
anyhow = "1"
bytes = "1.10"
iroh = { version = "0.90", features = ["discovery-local-network"] }
iroh-base = { version = "0.90", features = ["ticket"] }
iroh = { version = "0.91", features = ["discovery-local-network"] }
iroh-base = { version = "0.91", features = ["ticket"] }
once_cell = "1.21"
rand = "0.8"
safer-ffi = { version = "0.1.13" }
Expand All @@ -37,7 +37,3 @@ data-encoding = "2.9.0"
[features]
# generate headers
headers = ["safer-ffi/headers"]

[patch.crates-io]
iroh = { git = "https://github.com/n0-computer/iroh.git", branch = "main" }
iroh-base = { git = "https://github.com/n0-computer/iroh.git", branch = "main" }
23 changes: 16 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
CC = cc
CFLAGS = -Wall -g
CFLAGS = -Wall -g -O0
LDFLAGS = -L ./target/debug -l iroh_c_ffi -lSystem -lc -lm

all: main multi-thread-client multi-thread-server single-thread-server

main: main.o
main.o: main.c
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

multi-thread-client: multi-thread-client.o
multi-thread-client.o: multi-thread-client.c
single-thread-server: single-thread-server.o
single-thread-server.o: single-thread-server.c
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

multi-thread-server: multi-thread-server.o
multi-thread-server.o: multi-thread-server.c
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

single-thread-server: single-thread-server.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

# Generic compile rule for .c → .o
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@

clean:
rm -f main main.o multi-thread-client.o multi-thread-client multi-thread-server.o multi-thread-server single-thread-server.o single-thread-server
rm -f main main.o multi-thread-client.o multi-thread-client \
multi-thread-server.o multi-thread-server \
single-thread-server.o single-thread-server
3 changes: 0 additions & 3 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,3 @@ name = "ring"
[[licenses.clarify.license-files]]
hash = 3171872035
path = "LICENSE"

[sources]
allow-git = ["https://github.com/n0-computer/iroh.git"]
4 changes: 4 additions & 0 deletions irohnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,8 @@ recv_stream_default (void);
* Free the recv stream.
*
* Implicitly calls `stop(0)` on the connection.
*
* Must be called before `endpoint_free`
*/
void
recv_stream_free (
Expand Down Expand Up @@ -1016,6 +1018,8 @@ send_stream_finish (

/** \brief
* Frees the send stream.
*
* Must be called before `endpoint_free`
*/
void
send_stream_free (
Expand Down
16 changes: 15 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,15 @@ callback(
ConnectionType_t conn_type
)
{
printf("Callback 0\n");
ConnectionStatus *cs;
printf("Callback 1\n");
cs = (ConnectionStatus *)ctx;
printf("Callback 2\n");
cs->res = res;
printf("Callback 3\n");
cs->conn_type = conn_type;
printf("Callback done\n");
}

int
Expand Down Expand Up @@ -461,17 +466,23 @@ run_client (

// gracefully close the endpoint. This will wait until all the connections have closed gracefully, ensure the server receives a `CONNECTION_CLOSE`, so it can also cleanly close.

printf("free recv_stream\n");
recv_stream_free(recv_stream);

printf("closing endpoint\n");
endpoint_close(ep);
printf("endpoint closed\n");

printf("fflush to stdout\n");
fflush(stdout);

// cleanup
printf("free recv_str\n");
free(recv_str);
printf("free recv_buffer\n");
free(recv_buffer);
printf("free conn_status\n");
free(conn_status);
recv_stream_free(recv_stream);
return 0;
}

Expand Down Expand Up @@ -523,6 +534,7 @@ main (int argc, char const * const argv[])
return ret;
}

printf("free addrs\n");
// cleanup
free(addrs);

Expand All @@ -541,7 +553,9 @@ main (int argc, char const * const argv[])
}

// cleanup
printf("free config\n");
endpoint_config_free(config);

printf("exit\n");
return EXIT_SUCCESS;
}
4 changes: 2 additions & 2 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ pub fn endpoint_node_addr(ep: &repr_c::Box<Endpoint>, out: &mut NodeAddr) -> End
.expect("endpoint not initialized")
.node_addr()
.initialized()
.await?;
.await;
anyhow::Ok(addr)
});

Expand Down Expand Up @@ -1015,7 +1015,7 @@ pub fn endpoint_home_relay(ep: &repr_c::Box<Endpoint>, out: &mut Url) -> Endpoin
.expect("endpoint not initialized")
.home_relay()
.initialized()
.await?;
.await;
anyhow::Ok(relay_url)
});

Expand Down
4 changes: 4 additions & 0 deletions src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub fn recv_stream_default() -> repr_c::Box<RecvStream> {
/// Free the recv stream.
///
/// Implicitly calls `stop(0)` on the connection.
///
/// Must be called before `endpoint_free`
#[ffi_export]
pub fn recv_stream_free(stream: repr_c::Box<RecvStream>) {
drop(stream);
Expand Down Expand Up @@ -161,6 +163,8 @@ pub fn send_stream_default() -> repr_c::Box<SendStream> {
}

/// Frees the send stream.
///
/// Must be called before `endpoint_free`
#[ffi_export]
pub fn send_stream_free(stream: repr_c::Box<SendStream>) {
drop(stream);
Expand Down
Loading