aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/transport
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2018-11-20 15:03:12 -0800
committerGravatar Yash Tibrewal <yashkt@google.com>2018-11-20 15:03:12 -0800
commitc7e92f26ebaecc8ea619de8b757034bb848b37d4 (patch)
tree96ebecd4987e1eb2950b5b857c1f603138870ee3 /src/core/ext/transport
parentbab043e8650799b91a4e40853e56439c2ddb15a7 (diff)
Reviewer comments
Diffstat (limited to 'src/core/ext/transport')
-rw-r--r--src/core/ext/transport/chttp2/transport/context_list.cc14
-rw-r--r--src/core/ext/transport/chttp2/transport/context_list.h24
2 files changed, 18 insertions, 20 deletions
diff --git a/src/core/ext/transport/chttp2/transport/context_list.cc b/src/core/ext/transport/chttp2/transport/context_list.cc
index 11f5c14a39..4acd0c9583 100644
--- a/src/core/ext/transport/chttp2/transport/context_list.cc
+++ b/src/core/ext/transport/chttp2/transport/context_list.cc
@@ -21,30 +21,30 @@
#include "src/core/ext/transport/chttp2/transport/context_list.h"
namespace {
-void (*cb)(void*, grpc_core::Timestamps*) = nullptr;
+void (*write_timestamps_callback_g)(void*, grpc_core::Timestamps*) = nullptr;
}
namespace grpc_core {
void ContextList::Execute(void* arg, grpc_core::Timestamps* ts,
grpc_error* error) {
ContextList* head = static_cast<ContextList*>(arg);
- ContextList* ptr;
+ ContextList* to_be_freed;
while (head != nullptr) {
if (error == GRPC_ERROR_NONE && ts != nullptr) {
- if (cb) {
- cb(head->s_->context, ts);
+ if (write_timestamps_callback_g) {
+ write_timestamps_callback_g(head->s_->context, ts);
}
}
GRPC_CHTTP2_STREAM_UNREF(static_cast<grpc_chttp2_stream*>(head->s_),
"timestamp");
- ptr = head;
+ to_be_freed = head;
head = head->next_;
- grpc_core::Delete(ptr);
+ grpc_core::Delete(to_be_freed);
}
}
void grpc_http2_set_write_timestamps_callback(
void (*fn)(void*, grpc_core::Timestamps*)) {
- cb = fn;
+ write_timestamps_callback_g = fn;
}
} /* namespace grpc_core */
diff --git a/src/core/ext/transport/chttp2/transport/context_list.h b/src/core/ext/transport/chttp2/transport/context_list.h
index 0cf7ba4dc3..68d11e94d8 100644
--- a/src/core/ext/transport/chttp2/transport/context_list.h
+++ b/src/core/ext/transport/chttp2/transport/context_list.h
@@ -16,8 +16,8 @@
*
*/
-#ifndef GRPC_CORE_EXT_TRANSPORT_CONTEXT_LIST_H
-#define GRPC_CORE_EXT_TRANSPORT_CONTEXT_LIST_H
+#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CONTEXT_LIST_H
+#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CONTEXT_LIST_H
#include <grpc/support/port_platform.h>
@@ -33,8 +33,10 @@ class ContextList {
* list. */
static void Append(ContextList** head, grpc_chttp2_stream* s) {
/* Make sure context is not already present */
- ContextList* ptr = *head;
GRPC_CHTTP2_STREAM_REF(s, "timestamp");
+
+#ifndef NDEBUG
+ ContextList* ptr = *head;
while (ptr != nullptr) {
if (ptr->s_ == s) {
GPR_ASSERT(
@@ -43,17 +45,13 @@ class ContextList {
}
ptr = ptr->next_;
}
+#endif
+
+ /* Create a new element in the list and add it at the front */
ContextList* elem = grpc_core::New<ContextList>();
elem->s_ = s;
- if (*head == nullptr) {
- *head = elem;
- return;
- }
- ptr = *head;
- while (ptr->next_ != nullptr) {
- ptr = ptr->next_;
- }
- ptr->next_ = elem;
+ elem->next_ = *head;
+ *head = elem;
}
/* Executes a function \a fn with each context in the list and \a ts. It also
@@ -69,4 +67,4 @@ void grpc_http2_set_write_timestamps_callback(
void (*fn)(void*, grpc_core::Timestamps*));
} /* namespace grpc_core */
-#endif /* GRPC_CORE_EXT_TRANSPORT_CONTEXT_LIST_H */
+#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CONTEXT_LIST_H */