Closes the DataChannel when the send buffer is full or on transport errors.
As stated in the spec. BUG=2645 R=pthatcher@google.com, wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/12619004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6270 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -164,17 +164,23 @@ bool DataChannel::Send(const DataBuffer& buffer) {
|
||||
// If the queue is non-empty, we're waiting for SignalReadyToSend,
|
||||
// so just add to the end of the queue and keep waiting.
|
||||
if (!queued_send_data_.empty()) {
|
||||
return QueueSendData(buffer);
|
||||
if (!QueueSendData(buffer)) {
|
||||
if (data_channel_type_ == cricket::DCT_RTP) {
|
||||
return false;
|
||||
}
|
||||
Close();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
cricket::SendDataResult send_result;
|
||||
if (!InternalSendWithoutQueueing(buffer, &send_result)) {
|
||||
if (send_result == cricket::SDR_BLOCK) {
|
||||
return QueueSendData(buffer);
|
||||
if (data_channel_type_ == cricket::DCT_RTP) {
|
||||
return false;
|
||||
}
|
||||
if (send_result != cricket::SDR_BLOCK || !QueueSendData(buffer)) {
|
||||
Close();
|
||||
}
|
||||
// Fail for other results.
|
||||
// TODO(jiayl): We should close the data channel in this case.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -325,9 +331,8 @@ void DataChannel::OnDataReceived(cricket::DataChannel* channel,
|
||||
observer_->OnMessage(*buffer.get());
|
||||
} else {
|
||||
if (queued_received_data_.size() > kMaxQueuedReceivedDataPackets) {
|
||||
// TODO(jiayl): We should close the data channel in this case.
|
||||
LOG(LS_ERROR)
|
||||
<< "Queued received data exceeds the max number of packes.";
|
||||
<< "Queued received data exceeds the max number of packets.";
|
||||
ClearQueuedReceivedData();
|
||||
}
|
||||
queued_received_data_.push(buffer.release());
|
||||
@ -522,8 +527,8 @@ bool DataChannel::InternalSendWithoutQueueing(
|
||||
}
|
||||
|
||||
bool DataChannel::QueueSendData(const DataBuffer& buffer) {
|
||||
if (queued_send_data_.size() > kMaxQueuedSendDataPackets) {
|
||||
LOG(LS_ERROR) << "Can't buffer any more data in the data channel.";
|
||||
if (queued_send_data_.size() >= kMaxQueuedSendDataPackets) {
|
||||
LOG(LS_ERROR) << "Can't buffer any more data for the data channel.";
|
||||
return false;
|
||||
}
|
||||
queued_send_data_.push_back(new DataBuffer(buffer));
|
||||
|
Reference in New Issue
Block a user