aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-28 07:36:07 -0700
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-28 07:36:07 -0700
commitd1369aa134e8eaab1bde6a5ea36a8ba655c79a57 (patch)
treec1cdc85da9e4a01371edee5dcb99a6069f0c5be8 /src/core
parentfe46136721acc3298a2949a7321d043180daed92 (diff)
parenta3c9fb08136d6a3875b8e400ef4b4137357d6b4a (diff)
Merge github.com:grpc/grpc into scalable-poll
Diffstat (limited to 'src/core')
-rw-r--r--src/core/iomgr/pollset_posix.c7
-rw-r--r--src/core/surface/call.h13
-rw-r--r--src/core/surface/call_log_batch.c16
-rw-r--r--src/core/surface/server.c12
-rw-r--r--src/core/surface/server.h2
-rw-r--r--src/core/transport/chttp2/alpn.c3
-rw-r--r--src/core/tsi/ssl_transport_security.c10
7 files changed, 57 insertions, 6 deletions
diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c
index bdfcba6e5d..a38517908d 100644
--- a/src/core/iomgr/pollset_posix.c
+++ b/src/core/iomgr/pollset_posix.c
@@ -174,6 +174,8 @@ void grpc_pollset_del_fd(grpc_pollset *pollset, grpc_fd *fd) {
int grpc_pollset_work(grpc_pollset *pollset, gpr_timespec deadline) {
/* pollset->mu already held */
gpr_timespec now = gpr_now();
+ /* FIXME(ctiller): see below */
+ gpr_timespec maximum_deadline = gpr_time_add(now, gpr_time_from_seconds(1));
int r;
if (gpr_time_cmp(now, deadline) > 0) {
return 0;
@@ -184,6 +186,11 @@ int grpc_pollset_work(grpc_pollset *pollset, gpr_timespec deadline) {
if (grpc_alarm_check(&pollset->mu, now, &deadline)) {
return 1;
}
+ /* FIXME(ctiller): we should not clamp deadline, however we have some
+ stuck at shutdown bugs that this resolves */
+ if (gpr_time_cmp(deadline, maximum_deadline) > 0) {
+ deadline = maximum_deadline;
+ }
gpr_tls_set(&g_current_thread_poller, (gpr_intptr)pollset);
r = pollset->vtable->maybe_work(pollset, deadline, now, 1);
gpr_tls_set(&g_current_thread_poller, 0);
diff --git a/src/core/surface/call.h b/src/core/surface/call.h
index 60222bf389..9116538948 100644
--- a/src/core/surface/call.h
+++ b/src/core/surface/call.h
@@ -122,6 +122,16 @@ void grpc_call_log_batch(char *file, int line, gpr_log_severity severity,
grpc_call *call, const grpc_op *ops, size_t nops,
void *tag);
+void grpc_server_log_request_call(char *file, int line,
+ gpr_log_severity severity,
+ grpc_server *server,
+ grpc_call **call,
+ grpc_call_details *details,
+ grpc_metadata_array *initial_metadata,
+ grpc_completion_queue *cq_bound_to_call,
+ grpc_completion_queue *cq_for_notification,
+ void *tag);
+
/* Set a context pointer.
No thread safety guarantees are made wrt this value. */
void grpc_call_context_set(grpc_call *call, grpc_context_index elem, void *value,
@@ -132,6 +142,9 @@ void *grpc_call_context_get(grpc_call *call, grpc_context_index elem);
#define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \
if (grpc_trace_batch) grpc_call_log_batch(sev, call, ops, nops, tag)
+#define GRPC_SERVER_LOG_REQUEST_CALL(sev, server, call, details, initial_metadata, cq_bound_to_call, cq_for_notifications, tag) \
+ if (grpc_trace_batch) grpc_server_log_request_call(sev, server, call, details, initial_metadata, cq_bound_to_call, cq_for_notifications, tag)
+
gpr_uint8 grpc_call_is_client(grpc_call *call);
#endif /* GRPC_INTERNAL_CORE_SURFACE_CALL_H */
diff --git a/src/core/surface/call_log_batch.c b/src/core/surface/call_log_batch.c
index e3b3f75b45..9905401bee 100644
--- a/src/core/surface/call_log_batch.c
+++ b/src/core/surface/call_log_batch.c
@@ -119,3 +119,19 @@ void grpc_call_log_batch(char *file, int line, gpr_log_severity severity,
gpr_free(tmp);
}
}
+
+void grpc_server_log_request_call(char *file, int line,
+ gpr_log_severity severity,
+ grpc_server *server,
+ grpc_call **call,
+ grpc_call_details *details,
+ grpc_metadata_array *initial_metadata,
+ grpc_completion_queue *cq_bound_to_call,
+ grpc_completion_queue *cq_for_notification,
+ void *tag) {
+ gpr_log(file, line, severity,
+ "grpc_server_request_call(server=%p, call=%p, details=%p, "
+ "initial_metadata=%p, cq_bound_to_call=%p, cq_for_notification=%p, "
+ "tag=%p)", server, call, details, initial_metadata,
+ cq_bound_to_call, cq_for_notification, tag);
+}
diff --git a/src/core/surface/server.c b/src/core/surface/server.c
index 24a23ae5c4..a60d5f7717 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -1010,6 +1010,9 @@ grpc_call_error grpc_server_request_call(
grpc_completion_queue *cq_bound_to_call,
grpc_completion_queue *cq_for_notification, void *tag) {
requested_call rc;
+ GRPC_SERVER_LOG_REQUEST_CALL(GPR_INFO, server, call, details,
+ initial_metadata, cq_bound_to_call,
+ cq_for_notification, tag);
grpc_cq_begin_op(cq_for_notification, NULL);
rc.type = BATCH_CALL;
rc.tag = tag;
@@ -1128,3 +1131,12 @@ static void publish_registered_or_batch(grpc_call *call, int success,
const grpc_channel_args *grpc_server_get_channel_args(grpc_server *server) {
return server->channel_args;
}
+
+int grpc_server_has_open_connections(grpc_server *server) {
+ int r;
+ gpr_mu_lock(&server->mu);
+ r = server->root_channel_data.next != &server->root_channel_data;
+ gpr_mu_unlock(&server->mu);
+ return r;
+}
+
diff --git a/src/core/surface/server.h b/src/core/surface/server.h
index c6331033e0..58f17272a4 100644
--- a/src/core/surface/server.h
+++ b/src/core/surface/server.h
@@ -62,4 +62,6 @@ grpc_transport_setup_result grpc_server_setup_transport(
const grpc_channel_args *grpc_server_get_channel_args(grpc_server *server);
+int grpc_server_has_open_connections(grpc_server *server);
+
#endif /* GRPC_INTERNAL_CORE_SURFACE_SERVER_H */
diff --git a/src/core/transport/chttp2/alpn.c b/src/core/transport/chttp2/alpn.c
index 11901a58a0..3ccd5796ba 100644
--- a/src/core/transport/chttp2/alpn.c
+++ b/src/core/transport/chttp2/alpn.c
@@ -36,7 +36,8 @@
#include <grpc/support/useful.h>
/* in order of preference */
-static const char *const supported_versions[] = {"h2-16", "h2-15", "h2-14"};
+static const char *const supported_versions[] = {"h2", "h2-17", "h2-16",
+ "h2-15", "h2-14"};
int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size) {
size_t i;
diff --git a/src/core/tsi/ssl_transport_security.c b/src/core/tsi/ssl_transport_security.c
index 9718a0b048..63b4c42131 100644
--- a/src/core/tsi/ssl_transport_security.c
+++ b/src/core/tsi/ssl_transport_security.c
@@ -639,7 +639,7 @@ static tsi_result ssl_protector_protect(tsi_frame_protector* self,
tsi_result result = TSI_OK;
/* First see if we have some pending data in the SSL BIO. */
- size_t pending_in_ssl = BIO_ctrl_pending(impl->from_ssl);
+ size_t pending_in_ssl = BIO_pending(impl->from_ssl);
if (pending_in_ssl > 0) {
*unprotected_bytes_size = 0;
read_from_ssl = BIO_read(impl->from_ssl, protected_output_frames,
@@ -694,7 +694,7 @@ static tsi_result ssl_protector_protect_flush(
impl->buffer_offset = 0;
}
- *still_pending_size = BIO_ctrl_pending(impl->from_ssl);
+ *still_pending_size = BIO_pending(impl->from_ssl);
if (*still_pending_size == 0) return TSI_OK;
read_from_ssl = BIO_read(impl->from_ssl, protected_output_frames,
@@ -704,7 +704,7 @@ static tsi_result ssl_protector_protect_flush(
return TSI_INTERNAL_ERROR;
}
*protected_output_frames_size = read_from_ssl;
- *still_pending_size = BIO_ctrl_pending(impl->from_ssl);
+ *still_pending_size = BIO_pending(impl->from_ssl);
return TSI_OK;
}
@@ -782,7 +782,7 @@ static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self,
}
}
*bytes_size = (size_t)bytes_read_from_ssl;
- return BIO_ctrl_pending(impl->from_ssl) == 0 ? TSI_OK : TSI_INCOMPLETE_DATA;
+ return BIO_pending(impl->from_ssl) == 0 ? TSI_OK : TSI_INCOMPLETE_DATA;
}
static tsi_result ssl_handshaker_get_result(tsi_handshaker* self) {
@@ -818,7 +818,7 @@ static tsi_result ssl_handshaker_process_bytes_from_peer(
ssl_result = SSL_get_error(impl->ssl, ssl_result);
switch (ssl_result) {
case SSL_ERROR_WANT_READ:
- if (BIO_ctrl_pending(impl->from_ssl) == 0) {
+ if (BIO_pending(impl->from_ssl) == 0) {
/* We need more data. */
return TSI_INCOMPLETE_DATA;
} else {