You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2017/11/28 08:23:29 UTC
[trafficserver] branch quic-latest updated: Resolve a race
This is an automated email from the ASF dual-hosted git repository.
maskit pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/quic-latest by this push:
new 66044e3 Resolve a race
66044e3 is described below
commit 66044e3f4e99372fbe33d2b2f4e0b095164ff4c1
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Tue Nov 28 17:22:04 2017 +0900
Resolve a race
---
iocore/net/P_QUICNetVConnection.h | 2 ++
iocore/net/QUICNetVConnection.cc | 50 +++++++++++++++++++++++++++------------
2 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/iocore/net/P_QUICNetVConnection.h b/iocore/net/P_QUICNetVConnection.h
index bba69ad..b504fea 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -225,6 +225,8 @@ private:
std::queue<QUICFrameUPtr> _frame_send_queue;
std::queue<QUICFrameUPtr> _stream_frame_send_queue;
+ void _schedule_packet_write_ready();
+ void _unschedule_packet_write_ready();
Event *_packet_write_ready = nullptr;
void _transmit_packet(QUICPacketUPtr);
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 56ec2a7..3bcb7f5 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -126,6 +126,7 @@ QUICNetVConnection::free(EThread *t)
this->_udp_con = nullptr;
this->_packet_handler = nullptr;
+ _unschedule_packet_write_ready();
delete this->_version_negotiator;
delete this->_handshake_handler;
@@ -225,9 +226,7 @@ void
QUICNetVConnection::transmit_packet(QUICPacketUPtr packet)
{
this->_transmit_packet(std::move(packet));
- if (!this->_packet_write_ready) {
- this->_packet_write_ready = eventProcessor.schedule_imm(this, ET_CALL, QUIC_EVENT_PACKET_WRITE_READY, nullptr);
- }
+ this->_schedule_packet_write_ready();
}
void
@@ -293,10 +292,7 @@ void
QUICNetVConnection::transmit_frame(QUICFrameUPtr frame)
{
this->_transmit_frame(std::move(frame));
- if (!this->_packet_write_ready) {
- DebugQUICCon("Schedule %s event", QUICDebugNames::quic_event(QUIC_EVENT_PACKET_WRITE_READY));
- this->_packet_write_ready = eventProcessor.schedule_imm(this, ET_CALL, QUIC_EVENT_PACKET_WRITE_READY, nullptr);
- }
+ this->_schedule_packet_write_ready();
}
void
@@ -333,10 +329,7 @@ QUICNetVConnection::handle_frame(std::shared_ptr<const QUICFrame> frame)
Debug("quic_flow_ctrl", "Connection [%" PRIx64 "] [REMOTE] %" PRIu64 "/%" PRIu64,
static_cast<uint64_t>(this->_quic_connection_id), this->_remote_flow_controller->current_offset(),
this->_remote_flow_controller->current_limit());
-
- if (!this->_packet_write_ready) {
- this->_packet_write_ready = eventProcessor.schedule_imm(this, ET_CALL, QUIC_EVENT_PACKET_WRITE_READY, nullptr);
- }
+ this->_schedule_packet_write_ready();
break;
case QUICFrameType::BLOCKED:
@@ -361,6 +354,8 @@ QUICNetVConnection::handle_frame(std::shared_ptr<const QUICFrame> frame)
int
QUICNetVConnection::state_pre_handshake(int event, Event *data)
{
+ SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+
if (!this->thread) {
this->thread = this_ethread();
}
@@ -384,6 +379,7 @@ QUICNetVConnection::state_pre_handshake(int event, Event *data)
int
QUICNetVConnection::state_handshake(int event, Event *data)
{
+ SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
switch (event) {
@@ -452,6 +448,7 @@ QUICNetVConnection::state_handshake(int event, Event *data)
int
QUICNetVConnection::state_connection_established(int event, Event *data)
{
+ SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
switch (event) {
case QUIC_EVENT_PACKET_READ_READY: {
@@ -488,6 +485,8 @@ QUICNetVConnection::state_connection_established(int event, Event *data)
int
QUICNetVConnection::state_connection_closing(int event, Event *data)
{
+ SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+
QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
switch (event) {
case QUIC_EVENT_PACKET_READ_READY: {
@@ -522,12 +521,10 @@ QUICNetVConnection::state_connection_closing(int event, Event *data)
int
QUICNetVConnection::state_connection_closed(int event, Event *data)
{
+ SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
switch (event) {
case QUIC_EVENT_SHUTDOWN: {
- if (this->_packet_write_ready) {
- this->_packet_write_ready->cancel();
- this->_packet_write_ready = nullptr;
- }
+ this->_unschedule_packet_write_ready();
this->next_inactivity_timeout_at = 0;
this->next_activity_timeout_at = 0;
@@ -542,6 +539,9 @@ QUICNetVConnection::state_connection_closed(int event, Event *data)
}
default:
DebugQUICCon("Unexpected event: %s", QUICDebugNames::quic_event(event));
+ if (this->_packet_write_ready == data) {
+ this->_packet_write_ready = nullptr;
+ }
}
return EVENT_DONE;
@@ -980,3 +980,23 @@ QUICNetVConnection::_dequeue_recv_packet(QUICPacketCreationResult &result)
return quic_packet;
}
+
+void
+QUICNetVConnection::_schedule_packet_write_ready()
+{
+ SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+ if (!this->_packet_write_ready) {
+ DebugQUICCon("Schedule %s event", QUICDebugNames::quic_event(QUIC_EVENT_PACKET_WRITE_READY));
+ this->_packet_write_ready = eventProcessor.schedule_imm(this, ET_CALL, QUIC_EVENT_PACKET_WRITE_READY, nullptr);
+ }
+}
+
+void
+QUICNetVConnection::_unschedule_packet_write_ready()
+{
+ SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+ if (this->_packet_write_ready) {
+ this->_packet_write_ready->cancel();
+ this->_packet_write_ready = nullptr;
+ }
+}
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].