Merge branch 'endpoints' of github.com:ctiller/grpc into endpoints
diff --git a/src/core/iomgr/endpoint.h b/src/core/iomgr/endpoint.h
index 38f1e46..d14d52d 100644
--- a/src/core/iomgr/endpoint.h
+++ b/src/core/iomgr/endpoint.h
@@ -77,15 +77,19 @@
/* Write slices out to the socket.
If the connection is ready for more data after the end of the call, it
- returns GRPC_ENDPOINT_WRITE_DONE.
- Otherwise it returns GRPC_ENDPOINT_WRITE_PENDING and calls cb when the
- connection is ready for more data. */
+ returns GRPC_ENDPOINT_DONE.
+ Otherwise it returns GRPC_ENDPOINT_PENDING and calls cb when the
+ connection is ready for more data.
+ \a slices may be mutated at will by the endpoint until cb is called.
+ No guarantee is made to the content of slices after a write EXCEPT that
+ it is a valid slice buffer.
+ */
grpc_endpoint_op_status grpc_endpoint_write(
grpc_endpoint *ep, gpr_slice_buffer *slices,
grpc_iomgr_closure *cb) GRPC_MUST_USE_RESULT;
/* Causes any pending read/write callbacks to run immediately with
- GRPC_ENDPOINT_CB_SHUTDOWN status */
+ success==0 */
void grpc_endpoint_shutdown(grpc_endpoint *ep);
void grpc_endpoint_destroy(grpc_endpoint *ep);
diff --git a/src/core/iomgr/tcp_windows.c b/src/core/iomgr/tcp_windows.c
index a63123c..1cf2ca2 100644
--- a/src/core/iomgr/tcp_windows.c
+++ b/src/core/iomgr/tcp_windows.c
@@ -169,7 +169,9 @@
cb->cb(cb->cb_arg, success);
}
-static grpc_endpoint_op_status win_read(grpc_endpoint *ep, gpr_slice_buffer *read_slices, grpc_iomgr_closure *cb) {
+static grpc_endpoint_op_status win_read(grpc_endpoint *ep,
+ gpr_slice_buffer *read_slices,
+ grpc_iomgr_closure *cb) {
grpc_tcp *tcp = (grpc_tcp *)ep;
grpc_winsocket *handle = tcp->socket;
grpc_winsocket_callback_info *info = &handle->read_info;
@@ -275,8 +277,8 @@
/* Initiates a write. */
static grpc_endpoint_op_status win_write(grpc_endpoint *ep,
- gpr_slice_buffer *slices,
- grpc_iomgr_closure *cb) {
+ gpr_slice_buffer *slices,
+ grpc_iomgr_closure *cb) {
grpc_tcp *tcp = (grpc_tcp *)ep;
grpc_winsocket *socket = tcp->socket;
grpc_winsocket_callback_info *info = &socket->write_info;
@@ -398,8 +400,8 @@
}
static grpc_endpoint_vtable vtable = {
- win_read, win_write, win_add_to_pollset, win_add_to_pollset_set,
- win_shutdown, win_destroy, win_get_peer};
+ win_read, win_write, win_add_to_pollset, win_add_to_pollset_set,
+ win_shutdown, win_destroy, win_get_peer};
grpc_endpoint *grpc_tcp_create(grpc_winsocket *socket, char *peer_string) {
grpc_tcp *tcp = (grpc_tcp *)gpr_malloc(sizeof(grpc_tcp));
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c
index 46ab0a5..8caa10c 100644
--- a/src/core/transport/chttp2_transport.c
+++ b/src/core/transport/chttp2_transport.c
@@ -1074,12 +1074,12 @@
t->parsing_active = 1;
/* merge stream lists */
grpc_chttp2_stream_map_move_into(&t->new_stream_map,
- &t->parsing_stream_map);
+ &t->parsing_stream_map);
grpc_chttp2_prepare_to_read(&t->global, &t->parsing);
gpr_mu_unlock(&t->mu);
for (; i < t->read_buffer.count &&
- grpc_chttp2_perform_read(&t->parsing, t->read_buffer.slices[i]);
- i++)
+ grpc_chttp2_perform_read(&t->parsing, t->read_buffer.slices[i]);
+ i++)
;
gpr_mu_lock(&t->mu);
if (i != t->read_buffer.count) {
@@ -1087,12 +1087,12 @@
}
/* merge stream lists */
grpc_chttp2_stream_map_move_into(&t->new_stream_map,
- &t->parsing_stream_map);
+ &t->parsing_stream_map);
t->global.concurrent_stream_count =
- grpc_chttp2_stream_map_size(&t->parsing_stream_map);
+ grpc_chttp2_stream_map_size(&t->parsing_stream_map);
if (t->parsing.initial_window_update != 0) {
grpc_chttp2_stream_map_for_each(&t->parsing_stream_map,
- update_global_window, t);
+ update_global_window, t);
t->parsing.initial_window_update = 0;
}
/* handle higher level things */
@@ -1102,8 +1102,7 @@
if (!*success || i != t->read_buffer.count) {
drop_connection(t);
read_error_locked(t);
- }
- else {
+ } else {
keep_reading = 1;
}
gpr_slice_buffer_reset_and_unref(&t->read_buffer);
@@ -1111,17 +1110,16 @@
if (keep_reading) {
switch (grpc_endpoint_read(t->ep, &t->read_buffer, &t->recv_data)) {
- case GRPC_ENDPOINT_DONE:
- *success = 1;
- return 1;
- case GRPC_ENDPOINT_ERROR:
- *success = 0;
- return 1;
- case GRPC_ENDPOINT_PENDING:
- return 0;
+ case GRPC_ENDPOINT_DONE:
+ *success = 1;
+ return 1;
+ case GRPC_ENDPOINT_ERROR:
+ *success = 0;
+ return 1;
+ case GRPC_ENDPOINT_PENDING:
+ return 0;
}
- }
- else {
+ } else {
UNREF_TRANSPORT(t, "recv_data");
return 0;
}
@@ -1133,7 +1131,8 @@
static void recv_data(void *tp, int success) {
grpc_chttp2_transport *t = tp;
- while (recv_data_loop(t, &success));
+ while (recv_data_loop(t, &success))
+ ;
}
/*