test_compat_go now negotiating yamux

This commit is contained in:
John Jones 2017-11-28 23:58:28 -05:00
parent 8551121bf8
commit 35d795df94
2 changed files with 7 additions and 1 deletions

View file

@ -141,7 +141,7 @@ int libp2p_conn_dialer_join_swarm(const struct Dialer* dialer, struct Libp2pPeer
return 0;
libp2p_logger_debug("dialer", "We successfully negotiated multistream over secio.\n");
// yamux over multistream
new_stream = libp2p_yamux_stream_new(new_stream, 0, NULL);
new_stream = libp2p_yamux_stream_new(peer->sessionContext->default_stream, 0, NULL);
if (new_stream != NULL) {
if (!libp2p_yamux_stream_ready(peer->sessionContext, 5))
return 0;

View file

@ -270,6 +270,11 @@ int libp2p_yamux_read(void* stream_context, struct StreamMessage** message, int
ctx = (struct YamuxContext*)stream_context;
}
if (ctx->state != yamux_stream_est) {
libp2p_logger_debug("yamux", "read: Yamux still not inited, so passing to lower protocol.\n");
return ctx->stream->parent_stream->read(ctx->stream->parent_stream->stream_context, message, timeout_secs);
}
struct Stream* parent_stream = libp2p_yamux_get_parent_stream(stream_context);
if (channel != NULL && channel->channel != 0) {
libp2p_logger_debug("yamux", "Data received on yamux stream %d.\n", channel->channel);
@ -623,6 +628,7 @@ struct Stream* libp2p_yamux_stream_new(struct Stream* parent_stream, int am_serv
out->read_raw = libp2p_yamux_read_raw;
out->handle_upgrade = libp2p_yamux_handle_upgrade;
out->address = parent_stream->address;
out->socket_mutex = parent_stream->socket_mutex;
// build YamuxContext
struct YamuxContext* ctx = libp2p_yamux_context_new(out);
if (ctx == NULL) {