tatsuhiro-t / spdylay

The experimental SPDY protocol version 2, 3 and 3.1 implementation in C
http://tatsuhiro-t.github.io/spdylay/
MIT License
602 stars 103 forks source link

a problem to implement the callback on_ctrl_not_send_callback #134

Closed sambc-SDK closed 9 years ago

sambc-SDK commented 9 years ago

Hi, I used spdylay to build some programs well before.But today I found a problem when I implementing the callback on_ctrl_not_send_callback.

Background: In my client program, every stream is associated with a structure -- "request" -- which I implement by myself. The program will new a request structure when it want to send a request, and call the function spdylay_submit_request with the request structure as the argument stream_user_data. So I can free the request structure in callback on_stream_close_callback when the stream is closing.

Problem: Today, I found a problem when I implementing the callback on_ctrl_not_send_callback. When on_ctrl_not_send_callback is called, and the argument type is SPDYLAY_SYN_STREAM, it means a STREAM is being canceled. Then I try to free the request structure of this stream, and I found I can't do it, because the frame->syn_stream->stream_id is zero and I can't find the structure from the stream by calling spdylay_session_get_stream_user_data().

This is the problem what I found. And thanks for reply.

tatsuhiro-t commented 9 years ago

This is indeed an issue. The thing is we only create stream after we decided to send SYN_STREAM, so in this case, stream is not created, and no stream ID is assigned. We fixed this in nghttp2 API, but not ported to spdylay, since it would break API compatibility. I think I can fix this problem, by allocating stream ID when spdylay_submit_request or spdylay_submit_syn_stream are called. And create stream as needed when calling on_ctrl_not_send_callback.

tatsuhiro-t commented 9 years ago

I just pushed commit to fix this issue.

sambc-SDK commented 9 years ago

Thank you very much, and it works well now.