aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/transport
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-04-22 16:17:09 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-04-22 16:17:09 -0700
commitfbf5be26a3ab98115eec118a9858b000dd9fc045 (patch)
treeadef4e404e128a26ab2f7ce7ff11d6f2f3ebccb3 /src/core/transport
parent6ad62a7204c98e872a078902761d4a77af74a3d2 (diff)
One test compiles
Diffstat (limited to 'src/core/transport')
-rw-r--r--src/core/transport/chttp2_transport.c5
-rw-r--r--src/core/transport/stream_op.c14
-rw-r--r--src/core/transport/stream_op.h6
-rw-r--r--src/core/transport/transport.c16
-rw-r--r--src/core/transport/transport_op_string.c115
5 files changed, 70 insertions, 86 deletions
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c
index fed3088789..9c2af560c1 100644
--- a/src/core/transport/chttp2_transport.c
+++ b/src/core/transport/chttp2_transport.c
@@ -1503,8 +1503,6 @@ static int is_window_update_legal(gpr_int64 window_update, gpr_int64 window) {
return window + window_update < MAX_WINDOW;
}
-static void free_md(void *p, grpc_op_error result) { gpr_free(p); }
-
static void add_metadata_batch(transport *t, stream *s) {
grpc_metadata_batch b;
size_t i;
@@ -1522,8 +1520,7 @@ static void add_metadata_batch(transport *t, stream *s) {
s->incoming_metadata[s->incoming_metadata_count - 1].next = NULL;
grpc_sopb_add_metadata(&s->parser.incoming_sopb, b);
- grpc_sopb_add_flow_ctl_cb(&s->parser.incoming_sopb, free_md,
- s->incoming_metadata);
+ /* TODO(ctiller): don't leak incoming_metadata */
/* reset */
s->incoming_deadline = gpr_inf_future;
diff --git a/src/core/transport/stream_op.c b/src/core/transport/stream_op.c
index 882c078d51..ea22b0e1c8 100644
--- a/src/core/transport/stream_op.c
+++ b/src/core/transport/stream_op.c
@@ -81,9 +81,6 @@ void grpc_stream_ops_unref_owned_objects(grpc_stream_op *ops, size_t nops) {
case GRPC_OP_METADATA:
grpc_metadata_batch_destroy(&ops[i].data.metadata);
break;
- case GRPC_OP_FLOW_CTL_CB:
- ops[i].data.flow_ctl_cb.cb(ops[i].data.flow_ctl_cb.arg, GRPC_OP_ERROR);
- break;
case GRPC_NO_OP:
case GRPC_OP_BEGIN_MESSAGE:
break;
@@ -119,6 +116,7 @@ static grpc_stream_op *add(grpc_stream_op_buffer *sopb) {
assert_contained_metadata_ok(sopb->ops, sopb->nops);
+ GPR_ASSERT(sopb->nops <= sopb->capacity);
if (sopb->nops == sopb->capacity) {
expandto(sopb, GROW(sopb->capacity));
}
@@ -158,16 +156,6 @@ void grpc_sopb_add_slice(grpc_stream_op_buffer *sopb, gpr_slice slice) {
assert_contained_metadata_ok(sopb->ops, sopb->nops);
}
-void grpc_sopb_add_flow_ctl_cb(grpc_stream_op_buffer *sopb,
- void (*cb)(void *arg, grpc_op_error error),
- void *arg) {
- grpc_stream_op *op = add(sopb);
- op->type = GRPC_OP_FLOW_CTL_CB;
- op->data.flow_ctl_cb.cb = cb;
- op->data.flow_ctl_cb.arg = arg;
- assert_contained_metadata_ok(sopb->ops, sopb->nops);
-}
-
void grpc_sopb_append(grpc_stream_op_buffer *sopb, grpc_stream_op *ops,
size_t nops) {
size_t orig_nops = sopb->nops;
diff --git a/src/core/transport/stream_op.h b/src/core/transport/stream_op.h
index c3901bf608..f5de64d583 100644
--- a/src/core/transport/stream_op.h
+++ b/src/core/transport/stream_op.h
@@ -154,12 +154,10 @@ void grpc_sopb_add_begin_message(grpc_stream_op_buffer *sopb, gpr_uint32 length,
void grpc_sopb_add_metadata(grpc_stream_op_buffer *sopb, grpc_metadata_batch metadata);
/* Append a GRPC_SLICE to a buffer - does not ref/unref the slice */
void grpc_sopb_add_slice(grpc_stream_op_buffer *sopb, gpr_slice slice);
-/* Append a GRPC_OP_FLOW_CTL_CB to a buffer */
-void grpc_sopb_add_flow_ctl_cb(grpc_stream_op_buffer *sopb,
- void (*cb)(void *arg, grpc_op_error error),
- void *arg);
/* Append a buffer to a buffer - does not ref/unref any internal objects */
void grpc_sopb_append(grpc_stream_op_buffer *sopb, grpc_stream_op *ops,
size_t nops);
+char *grpc_sopb_string(grpc_stream_op_buffer *sopb);
+
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_STREAM_OP_H */
diff --git a/src/core/transport/transport.c b/src/core/transport/transport.c
index ef0020dc58..35195348e7 100644
--- a/src/core/transport/transport.c
+++ b/src/core/transport/transport.c
@@ -56,14 +56,9 @@ int grpc_transport_init_stream(grpc_transport *transport, grpc_stream *stream,
return transport->vtable->init_stream(transport, stream, server_data);
}
-void grpc_transport_send_batch(grpc_transport *transport, grpc_stream *stream,
- grpc_stream_op *ops, size_t nops, int is_last) {
- transport->vtable->send_batch(transport, stream, ops, nops, is_last);
-}
-
-void grpc_transport_set_allow_window_updates(grpc_transport *transport,
- grpc_stream *stream, int allow) {
- transport->vtable->set_allow_window_updates(transport, stream, allow);
+void grpc_transport_perform_op(grpc_transport *transport, grpc_stream *stream,
+ grpc_transport_op *op) {
+ transport->vtable->perform_op(transport, stream, op);
}
void grpc_transport_add_to_pollset(grpc_transport *transport,
@@ -76,11 +71,6 @@ void grpc_transport_destroy_stream(grpc_transport *transport,
transport->vtable->destroy_stream(transport, stream);
}
-void grpc_transport_abort_stream(grpc_transport *transport, grpc_stream *stream,
- grpc_status_code status) {
- transport->vtable->abort_stream(transport, stream, status);
-}
-
void grpc_transport_ping(grpc_transport *transport, void (*cb)(void *user_data),
void *user_data) {
transport->vtable->ping(transport, cb, user_data);
diff --git a/src/core/transport/transport_op_string.c b/src/core/transport/transport_op_string.c
index 5f7e1be268..e886690234 100644
--- a/src/core/transport/transport_op_string.c
+++ b/src/core/transport/transport_op_string.c
@@ -66,65 +66,76 @@ static void put_metadata_list(gpr_strvec *b, grpc_metadata_batch md) {
}
}
-char *grpc_call_op_string(grpc_call_op *op) {
+char *grpc_sopb_string(grpc_stream_op_buffer *sopb) {
+ char *out;
+ char *tmp;
+ size_t i;
+ gpr_strvec b;
+ gpr_strvec_init(&b);
+
+ for (i = 0; i < sopb->nops; i++) {
+ grpc_stream_op *op = &sopb->ops[i];
+ if (i) gpr_strvec_add(&b, gpr_strdup(", "));
+ switch (op->type) {
+ case GRPC_NO_OP:
+ gpr_strvec_add(&b, gpr_strdup("NO_OP"));
+ break;
+ case GRPC_OP_BEGIN_MESSAGE:
+ gpr_asprintf(&tmp, "BEGIN_MESSAGE:%d", op->data.begin_message.length);
+ gpr_strvec_add(&b, tmp);
+ break;
+ case GRPC_OP_SLICE:
+ gpr_asprintf(&tmp, "SLICE:%d", GPR_SLICE_LENGTH(op->data.slice));
+ break;
+ case GRPC_OP_METADATA:
+ put_metadata_list(&b, op->data.metadata);
+ break;
+ }
+ }
+
+ out = gpr_strvec_flatten(&b, NULL);
+ gpr_strvec_destroy(&b);
+
+ return out;
+}
+
+char *grpc_transport_op_string(grpc_transport_op *op) {
char *tmp;
char *out;
+ int first = 1;
gpr_strvec b;
gpr_strvec_init(&b);
- switch (op->dir) {
- case GRPC_CALL_DOWN:
- gpr_strvec_add(&b, gpr_strdup(">"));
- break;
- case GRPC_CALL_UP:
- gpr_strvec_add(&b, gpr_strdup("<"));
- break;
+ if (op->send_ops) {
+ if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
+ first = 0;
+ gpr_strvec_add(&b, gpr_strdup("SEND"));
+ if (op->is_last_send) {
+ gpr_strvec_add(&b, gpr_strdup("_LAST"));
+ }
+ gpr_strvec_add(&b, gpr_strdup("["));
+ gpr_strvec_add(&b, grpc_sopb_string(op->send_ops));
+ gpr_strvec_add(&b, gpr_strdup("]"));
}
- switch (op->type) {
- case GRPC_SEND_METADATA:
- gpr_strvec_add(&b, gpr_strdup("SEND_METADATA"));
- put_metadata_list(&b, op->data.metadata);
- break;
- case GRPC_SEND_MESSAGE:
- gpr_strvec_add(&b, gpr_strdup("SEND_MESSAGE"));
- break;
- case GRPC_SEND_PREFORMATTED_MESSAGE:
- gpr_strvec_add(&b, gpr_strdup("SEND_PREFORMATTED_MESSAGE"));
- break;
- case GRPC_SEND_FINISH:
- gpr_strvec_add(&b, gpr_strdup("SEND_FINISH"));
- break;
- case GRPC_REQUEST_DATA:
- gpr_strvec_add(&b, gpr_strdup("REQUEST_DATA"));
- break;
- case GRPC_RECV_METADATA:
- gpr_strvec_add(&b, gpr_strdup("RECV_METADATA"));
- put_metadata_list(&b, op->data.metadata);
- break;
- case GRPC_RECV_MESSAGE:
- gpr_strvec_add(&b, gpr_strdup("RECV_MESSAGE"));
- break;
- case GRPC_RECV_HALF_CLOSE:
- gpr_strvec_add(&b, gpr_strdup("RECV_HALF_CLOSE"));
- break;
- case GRPC_RECV_FINISH:
- gpr_strvec_add(&b, gpr_strdup("RECV_FINISH"));
- break;
- case GRPC_RECV_SYNTHETIC_STATUS:
- gpr_asprintf(&tmp, "RECV_SYNTHETIC_STATUS status=%d message='%s'",
- op->data.synthetic_status.status,
- op->data.synthetic_status.message);
- gpr_strvec_add(&b, tmp);
- break;
- case GRPC_CANCEL_OP:
- gpr_strvec_add(&b, gpr_strdup("CANCEL_OP"));
- break;
+
+ if (op->recv_ops) {
+ if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
+ first = 0;
+ gpr_strvec_add(&b, gpr_strdup("RECV"));
}
- gpr_asprintf(&tmp, " flags=0x%08x", op->flags);
- gpr_strvec_add(&b, tmp);
+
if (op->bind_pollset) {
- gpr_strvec_add(&b, gpr_strdup("bind_pollset"));
+ if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
+ first = 0;
+ gpr_strvec_add(&b, gpr_strdup("BIND"));
+ }
+
+ if (op->cancel_with_status != GRPC_STATUS_OK) {
+ if (!first) gpr_strvec_add(&b, gpr_strdup(" "));
+ first = 0;
+ gpr_asprintf(&tmp, "CANCEL:%d", op->cancel_with_status);
+ gpr_strvec_add(&b, tmp);
}
out = gpr_strvec_flatten(&b, NULL);
@@ -134,8 +145,8 @@ char *grpc_call_op_string(grpc_call_op *op) {
}
void grpc_call_log_op(char *file, int line, gpr_log_severity severity,
- grpc_call_element *elem, grpc_call_op *op) {
- char *str = grpc_call_op_string(op);
+ grpc_call_element *elem, grpc_transport_op *op) {
+ char *str = grpc_transport_op_string(op);
gpr_log(file, line, severity, "OP[%s:%p]: %s", elem->filter->name, elem, str);
gpr_free(str);
}