python: send_cb returns 0 to indicate SPDYLAY_ERR_WOULDBLOCK. Reorder cbs.

This commit is contained in:
Tatsuhiro Tsujikawa 2012-08-21 01:05:45 +09:00
parent 5dcdf95a67
commit 288962f3e6
2 changed files with 15 additions and 7 deletions

View File

@ -23,6 +23,10 @@ cdef extern from 'spdylay/spdylay.h':
SPDYLAY_CTRL_FLAG_FIN
SPDYLAY_CTRL_FLAG_UNIDIRECTIONAL
ctypedef enum spdylay_data_flag:
SPDYLAY_DATA_FLAG_NONE
SPDYLAY_DATA_FLAG_FIN
ctypedef enum spdylay_frame_type:
SPDYLAY_SYN_STREAM
SPDYLAY_SYN_REPLY

View File

@ -303,10 +303,10 @@ cdef ssize_t send_callback(cspdylay.spdylay_session *session,
pysession.base_error = e
return cspdylay.SPDYLAY_ERR_CALLBACK_FAILURE
if rv == cspdylay.SPDYLAY_ERR_WOULDBLOCK:
return cspdylay.SPDYLAY_ERR_WOULDBLOCK
else:
if rv:
return rv
else:
return cspdylay.SPDYLAY_ERR_WOULDBLOCK
else:
# If no send_callback is given, pretend all data were sent and
# just return length
@ -402,9 +402,9 @@ cdef class Session:
return self.user_data
def __cinit__(self, side, version,
recv_cb=None, send_cb=None,
on_data_chunk_recv_cb=None,
send_cb=None, recv_cb=None,
on_ctrl_recv_cb=None,
on_data_chunk_recv_cb=None,
on_stream_close_cb=None,
on_request_recv_cb=None,
user_data=None):
@ -469,9 +469,9 @@ cdef class Session:
raise UnsupportedVersionError(cspdylay.spdylay_strerror(rv))
def __init__(self, side, version,
recv_cb=None, send_cb=None,
on_data_chunk_recv_cb=None,
send_cb=None, recv_cb=None,
on_ctrl_recv_cb=None,
on_data_chunk_recv_cb=None,
on_stream_close_cb=None,
on_request_recv_cb=None,
user_data=None):
@ -686,6 +686,10 @@ CTRL_FLAG_NONE = cspdylay.SPDYLAY_CTRL_FLAG_NONE
CTRL_FLAG_FIN = cspdylay.SPDYLAY_CTRL_FLAG_FIN
CTRL_FLAG_UNIDIRECTIONAL = cspdylay.SPDYLAY_CTRL_FLAG_UNIDIRECTIONAL
# Data frame flags
DATA_FLAG_NONE = cspdylay.SPDYLAY_DATA_FLAG_NONE
DATA_FLAG_FIN = cspdylay.SPDYLAY_DATA_FLAG_FIN
# Error codes used in callback
ERR_OK = 0 # Not defined in <spdylay/spdylay.h>
ERR_EOF = cspdylay.SPDYLAY_ERR_EOF