Made spdylay_session_open_stream return a pointer to created spdylay_stream.
This commit is contained in:
parent
971e46f563
commit
580638c482
|
@ -264,21 +264,23 @@ int spdylay_session_add_rst_stream(spdylay_session *session,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spdylay_session_open_stream(spdylay_session *session, int32_t stream_id,
|
spdylay_stream* spdylay_session_open_stream(spdylay_session *session,
|
||||||
uint8_t flags, uint8_t pri,
|
int32_t stream_id,
|
||||||
spdylay_stream_state initial_state)
|
uint8_t flags, uint8_t pri,
|
||||||
|
spdylay_stream_state initial_state)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
spdylay_stream *stream = malloc(sizeof(spdylay_stream));
|
spdylay_stream *stream = malloc(sizeof(spdylay_stream));
|
||||||
if(stream == NULL) {
|
if(stream == NULL) {
|
||||||
return SPDYLAY_ERR_NOMEM;
|
return NULL;
|
||||||
}
|
}
|
||||||
spdylay_stream_init(stream, stream_id, flags, pri, initial_state);
|
spdylay_stream_init(stream, stream_id, flags, pri, initial_state);
|
||||||
r = spdylay_map_insert(&session->streams, stream_id, stream);
|
r = spdylay_map_insert(&session->streams, stream_id, stream);
|
||||||
if(r != 0) {
|
if(r != 0) {
|
||||||
free(stream);
|
free(stream);
|
||||||
|
stream = NULL;
|
||||||
}
|
}
|
||||||
return r;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spdylay_session_close_stream(spdylay_session *session, int32_t stream_id)
|
int spdylay_session_close_stream(spdylay_session *session, int32_t stream_id)
|
||||||
|
@ -345,7 +347,6 @@ ssize_t spdylay_session_prep_frame(spdylay_session *session,
|
||||||
/* TODO Get or validate stream ID here */
|
/* TODO Get or validate stream ID here */
|
||||||
uint8_t *framebuf;
|
uint8_t *framebuf;
|
||||||
ssize_t framebuflen;
|
ssize_t framebuflen;
|
||||||
int r;
|
|
||||||
switch(item->frame_type) {
|
switch(item->frame_type) {
|
||||||
case SPDYLAY_SYN_STREAM: {
|
case SPDYLAY_SYN_STREAM: {
|
||||||
if(session->goaway_flags) {
|
if(session->goaway_flags) {
|
||||||
|
@ -361,13 +362,12 @@ ssize_t spdylay_session_prep_frame(spdylay_session *session,
|
||||||
if(framebuflen < 0) {
|
if(framebuflen < 0) {
|
||||||
return framebuflen;
|
return framebuflen;
|
||||||
}
|
}
|
||||||
r = spdylay_session_open_stream(session, item->frame->syn_stream.stream_id,
|
if(spdylay_session_open_stream(session, item->frame->syn_stream.stream_id,
|
||||||
item->frame->syn_stream.hd.flags,
|
item->frame->syn_stream.hd.flags,
|
||||||
item->frame->syn_stream.pri,
|
item->frame->syn_stream.pri,
|
||||||
SPDYLAY_STREAM_INITIAL);
|
SPDYLAY_STREAM_INITIAL) == NULL) {
|
||||||
if(r != 0) {
|
|
||||||
free(framebuf);
|
free(framebuf);
|
||||||
return r;
|
return SPDYLAY_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -751,13 +751,12 @@ int spdylay_session_on_syn_stream_received(spdylay_session *session,
|
||||||
be opened. */
|
be opened. */
|
||||||
r = 0;
|
r = 0;
|
||||||
} else {
|
} else {
|
||||||
r = spdylay_session_open_stream(session, frame->syn_stream.stream_id,
|
spdylay_stream *stream;
|
||||||
frame->syn_stream.hd.flags,
|
stream = spdylay_session_open_stream(session, frame->syn_stream.stream_id,
|
||||||
frame->syn_stream.pri,
|
frame->syn_stream.hd.flags,
|
||||||
SPDYLAY_STREAM_OPENING);
|
frame->syn_stream.pri,
|
||||||
if(r == 0) {
|
SPDYLAY_STREAM_OPENING);
|
||||||
spdylay_stream *stream = spdylay_session_get_stream
|
if(stream) {
|
||||||
(session, frame->syn_stream.stream_id);
|
|
||||||
if(flags & SPDYLAY_FLAG_FIN) {
|
if(flags & SPDYLAY_FLAG_FIN) {
|
||||||
spdylay_stream_shutdown(stream, SPDYLAY_SHUT_RD);
|
spdylay_stream_shutdown(stream, SPDYLAY_SHUT_RD);
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,12 +140,14 @@ int spdylay_session_add_goaway(spdylay_session *session,
|
||||||
* priority |pri| and flags |flags|. Currently, |flags| &
|
* priority |pri| and flags |flags|. Currently, |flags| &
|
||||||
* SPDYLAY_FLAG_UNIDIRECTIONAL is non-zero, this stream is
|
* SPDYLAY_FLAG_UNIDIRECTIONAL is non-zero, this stream is
|
||||||
* unidirectional. |flags| & SPDYLAY_FLAG_FIN is non-zero, the sender
|
* unidirectional. |flags| & SPDYLAY_FLAG_FIN is non-zero, the sender
|
||||||
* of SYN_STREAM will not send any further data in this stream.
|
* of SYN_STREAM will not send any further data in this stream. The
|
||||||
* The state of stream is set to |initial_state|.
|
* state of stream is set to |initial_state|. This function returns a
|
||||||
|
* pointer to created new stream object, or NULL.
|
||||||
*/
|
*/
|
||||||
int spdylay_session_open_stream(spdylay_session *session, int32_t stream_id,
|
spdylay_stream* spdylay_session_open_stream(spdylay_session *session,
|
||||||
uint8_t flags, uint8_t pri,
|
int32_t stream_id,
|
||||||
spdylay_stream_state initial_state);
|
uint8_t flags, uint8_t pri,
|
||||||
|
spdylay_stream_state initial_state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Closes stream whose stream ID is |stream_id|. This function returns
|
* Closes stream whose stream ID is |stream_id|. This function returns
|
||||||
|
|
Loading…
Reference in New Issue