diff options
author | Craig Tiller <ctiller@google.com> | 2015-01-13 16:11:30 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-01-13 16:11:30 -0800 |
commit | 375605b65f9d58b7544b4af8bc93d4cf8489f010 (patch) | |
tree | bc0e1a8861a3dfdb6e8b0bb43a219d31efb88064 /src/core/surface | |
parent | 80fa15c15121a7d0ec020dec8bfa3697a96058b6 (diff) | |
parent | 49a06a6cb843b8ce592312c28b43c9dc527b99ee (diff) |
Merge github.com:google/grpc into api
Diffstat (limited to 'src/core/surface')
-rw-r--r-- | src/core/surface/call.c | 2 | ||||
-rw-r--r-- | src/core/surface/call.h | 2 | ||||
-rw-r--r-- | src/core/surface/channel.c | 2 | ||||
-rw-r--r-- | src/core/surface/channel.h | 2 | ||||
-rw-r--r-- | src/core/surface/client.c | 7 | ||||
-rw-r--r-- | src/core/surface/client.h | 2 | ||||
-rw-r--r-- | src/core/surface/completion_queue.h | 2 | ||||
-rw-r--r-- | src/core/surface/event_string.h | 2 | ||||
-rw-r--r-- | src/core/surface/lame_client.c | 29 | ||||
-rw-r--r-- | src/core/surface/server.c | 4 | ||||
-rw-r--r-- | src/core/surface/server.h | 2 | ||||
-rw-r--r-- | src/core/surface/server_chttp2.c | 16 | ||||
-rw-r--r-- | src/core/surface/surface_trace.h | 2 |
13 files changed, 52 insertions, 22 deletions
diff --git a/src/core/surface/call.c b/src/core/surface/call.c index f6d93bd957..297d9587eb 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -202,7 +202,7 @@ struct grpc_call { gpr_refcount internal_refcount; }; -#define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call)+1)) +#define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1)) #define CALL_FROM_CALL_STACK(call_stack) (((grpc_call *)(call_stack)) - 1) #define CALL_ELEM_FROM_CALL(call, idx) \ grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx) diff --git a/src/core/surface/call.h b/src/core/surface/call.h index 5c2ef3be18..01605bb38a 100644 --- a/src/core/surface/call.h +++ b/src/core/surface/call.h @@ -73,4 +73,4 @@ grpc_metadata_buffer *grpc_call_get_metadata_buffer(grpc_call *call); void grpc_call_add_mdelem(grpc_call *call, grpc_mdelem *mdelem, gpr_uint32 flags); -#endif /* __GRPC_INTERNAL_SURFACE_CALL_H__ */ +#endif /* __GRPC_INTERNAL_SURFACE_CALL_H__ */ diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index 8ef13675fe..a1bcea58dd 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -51,7 +51,7 @@ struct grpc_channel { grpc_mdstr *authority_string; }; -#define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack *)((c)+1)) +#define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack *)((c) + 1)) grpc_channel *grpc_channel_create_from_filters( const grpc_channel_filter **filters, size_t num_filters, diff --git a/src/core/surface/channel.h b/src/core/surface/channel.h index 11d4939916..b3ea2ede40 100644 --- a/src/core/surface/channel.h +++ b/src/core/surface/channel.h @@ -48,4 +48,4 @@ grpc_mdstr *grpc_channel_get_message_string(grpc_channel *channel); void grpc_channel_internal_ref(grpc_channel *channel); void grpc_channel_internal_unref(grpc_channel *channel); -#endif /* __GRPC_INTERNAL_SURFACE_CHANNEL_H__ */ +#endif /* __GRPC_INTERNAL_SURFACE_CHANNEL_H__ */ diff --git a/src/core/surface/client.c b/src/core/surface/client.c index 98cb460d63..524b0718a9 100644 --- a/src/core/surface/client.c +++ b/src/core/surface/client.c @@ -106,13 +106,12 @@ static void init_channel_elem(grpc_channel_element *elem, GPR_ASSERT(!is_last); } -static void destroy_channel_elem(grpc_channel_element *elem) { -} +static void destroy_channel_elem(grpc_channel_element *elem) {} const grpc_channel_filter grpc_client_surface_filter = { - call_op, channel_op, + call_op, channel_op, - sizeof(call_data), init_call_elem, destroy_call_elem, + sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem, diff --git a/src/core/surface/client.h b/src/core/surface/client.h index eb567276e2..cff3d401d9 100644 --- a/src/core/surface/client.h +++ b/src/core/surface/client.h @@ -38,4 +38,4 @@ extern const grpc_channel_filter grpc_client_surface_filter; -#endif /* __GRPC_INTERNAL_SURFACE_CLIENT_H__ */ +#endif /* __GRPC_INTERNAL_SURFACE_CLIENT_H__ */ diff --git a/src/core/surface/completion_queue.h b/src/core/surface/completion_queue.h index 2e752a3fe0..5e45749396 100644 --- a/src/core/surface/completion_queue.h +++ b/src/core/surface/completion_queue.h @@ -104,4 +104,4 @@ void grpc_cq_dump_pending_ops(grpc_completion_queue *cc); grpc_pollset *grpc_cq_pollset(grpc_completion_queue *cc); -#endif /* __GRPC_INTERNAL_SURFACE_COMPLETION_QUEUE_H__ */ +#endif /* __GRPC_INTERNAL_SURFACE_COMPLETION_QUEUE_H__ */ diff --git a/src/core/surface/event_string.h b/src/core/surface/event_string.h index 30b693e95c..b34e2d152b 100644 --- a/src/core/surface/event_string.h +++ b/src/core/surface/event_string.h @@ -39,4 +39,4 @@ /* Returns a string describing an event. Must be later freed with gpr_free() */ char *grpc_event_string(grpc_event *ev); -#endif /* __GRPC_INTERNAL_SURFACE_EVENT_STRING_H__ */ +#endif /* __GRPC_INTERNAL_SURFACE_EVENT_STRING_H__ */ diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c index 6a832436ca..5fa3e42362 100644 --- a/src/core/surface/lame_client.c +++ b/src/core/surface/lame_client.c @@ -33,6 +33,8 @@ #include "src/core/surface/lame_client.h" +#include <string.h> + #include "src/core/channel/channel_stack.h" #include "src/core/surface/channel.h" #include "src/core/surface/call.h" @@ -42,16 +44,28 @@ typedef struct { void *unused; } call_data; -typedef struct { void *unused; } channel_data; +typedef struct { grpc_mdelem *message; } channel_data; + +static void do_nothing(void *data, grpc_op_error error) {} static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, grpc_call_op *op) { + channel_data *channeld = elem->channel_data; GRPC_CALL_LOG_OP(GPR_INFO, elem, op); switch (op->type) { - case GRPC_SEND_START: + case GRPC_SEND_START: { + grpc_call_op set_status_op; + grpc_mdelem_ref(channeld->message); + memset(&set_status_op, 0, sizeof(grpc_call_op)); + set_status_op.dir = GRPC_CALL_UP; + set_status_op.type = GRPC_RECV_METADATA; + set_status_op.done_cb = do_nothing; + set_status_op.data.metadata = channeld->message; + grpc_call_recv_metadata(elem, &set_status_op); grpc_call_recv_finish(elem, 1); break; + } case GRPC_SEND_METADATA: grpc_mdelem_unref(op->data.metadata); break; @@ -81,11 +95,20 @@ static void destroy_call_elem(grpc_call_element *elem) {} static void init_channel_elem(grpc_channel_element *elem, const grpc_channel_args *args, grpc_mdctx *mdctx, int is_first, int is_last) { + channel_data *channeld = elem->channel_data; + GPR_ASSERT(is_first); GPR_ASSERT(is_last); + + channeld->message = grpc_mdelem_from_strings(mdctx, "grpc-message", + "Rpc sent on a lame channel."); } -static void destroy_channel_elem(grpc_channel_element *elem) {} +static void destroy_channel_elem(grpc_channel_element *elem) { + channel_data *channeld = elem->channel_data; + + grpc_mdelem_unref(channeld->message); +} static const grpc_channel_filter lame_filter = { call_op, channel_op, diff --git a/src/core/surface/server.c b/src/core/surface/server.c index aa544a97f2..167bfe97d1 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -405,9 +405,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } static const grpc_channel_filter server_surface_filter = { - call_op, channel_op, + call_op, channel_op, - sizeof(call_data), init_call_elem, destroy_call_elem, + sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem, diff --git a/src/core/surface/server.h b/src/core/surface/server.h index 61292ebe4e..50574d66a4 100644 --- a/src/core/surface/server.h +++ b/src/core/surface/server.h @@ -60,4 +60,4 @@ grpc_transport_setup_result grpc_server_setup_transport( const grpc_channel_args *grpc_server_get_channel_args(grpc_server *server); -#endif /* __GRPC_INTERNAL_SURFACE_SERVER_H__ */ +#endif /* __GRPC_INTERNAL_SURFACE_SERVER_H__ */ diff --git a/src/core/surface/server_chttp2.c b/src/core/surface/server_chttp2.c index a0961bd449..47fca827f3 100644 --- a/src/core/surface/server_chttp2.c +++ b/src/core/surface/server_chttp2.c @@ -76,6 +76,8 @@ int grpc_server_add_http2_port(grpc_server *server, const char *addr) { grpc_tcp_server *tcp = NULL; size_t i; int count = 0; + int port_num = -1; + int port_temp; resolved = grpc_blocking_resolve_address(addr, "http"); if (!resolved) { @@ -88,9 +90,15 @@ int grpc_server_add_http2_port(grpc_server *server, const char *addr) { } for (i = 0; i < resolved->naddrs; i++) { - if (grpc_tcp_server_add_port(tcp, - (struct sockaddr *)&resolved->addrs[i].addr, - resolved->addrs[i].len)) { + port_temp = grpc_tcp_server_add_port( + tcp, (struct sockaddr *)&resolved->addrs[i].addr, + resolved->addrs[i].len); + if (port_temp >= 0) { + if (port_num == -1) { + port_num = port_temp; + } else { + GPR_ASSERT(port_num == port_temp); + } count++; } } @@ -108,7 +116,7 @@ int grpc_server_add_http2_port(grpc_server *server, const char *addr) { /* Register with the server only upon success */ grpc_server_add_listener(server, tcp, start, destroy); - return 1; + return port_num; /* Error path: cleanup and return */ error: diff --git a/src/core/surface/surface_trace.h b/src/core/surface/surface_trace.h index f6f9acfd9c..df1aea9669 100644 --- a/src/core/surface/surface_trace.h +++ b/src/core/surface/surface_trace.h @@ -51,4 +51,4 @@ } while (0) #endif -#endif /* __GRPC_INTERNAL_SURFACE_SURFACE_TRACE_H__ */ +#endif /* __GRPC_INTERNAL_SURFACE_SURFACE_TRACE_H__ */ |