Преглед изворни кода

Merge remote-tracking branch 'upstream/master'

David Garcia Quintas пре 10 година
родитељ
комит
d41cbdba22
37 измењених фајлова са 238 додато и 611 уклоњено
  1. 7 0
      .travis.yml
  2. 2 2
      BUILD
  3. 17 480
      Makefile
  4. 3 3
      build.json
  5. 0 1
      examples/pubsub/main.cc
  6. 19 9
      include/grpc++/client_context.h
  7. 8 5
      include/grpc++/completion_queue.h
  8. 8 9
      include/grpc++/credentials.h
  9. 9 4
      include/grpc++/server_context.h
  10. 58 3
      include/grpc++/time.h
  11. 1 1
      include/grpc/support/tls.h
  12. 1 1
      src/core/iomgr/pollset_multipoller_with_poll_posix.c
  13. 22 6
      src/core/iomgr/pollset_posix.c
  14. 0 4
      src/core/iomgr/resolve_address_windows.c
  15. 1 1
      src/core/iomgr/tcp_server_windows.c
  16. 1 0
      src/core/surface/server.c
  17. 1 0
      src/core/tsi/ssl_transport_security.c
  18. 3 4
      src/cpp/client/channel.cc
  19. 1 0
      src/cpp/client/channel.h
  20. 2 13
      src/cpp/client/client_context.cc
  21. 6 6
      src/cpp/client/secure_credentials.cc
  22. 1 8
      src/cpp/common/completion_queue.cc
  23. 2 2
      src/cpp/server/server.cc
  24. 4 4
      src/cpp/server/server_context.cc
  25. 6 1
      src/cpp/util/time.cc
  26. 2 9
      templates/Makefile.template
  27. 1 1
      test/cpp/client/credentials_test.cc
  28. 2 3
      test/cpp/end2end/async_end2end_test.cc
  29. 8 9
      test/cpp/end2end/end2end_test.cc
  30. 1 2
      test/cpp/end2end/generic_end2end_test.cc
  31. 4 2
      test/cpp/interop/client_helper.cc
  32. 1 4
      test/cpp/util/time_test.cc
  33. 13 1
      tools/run_tests/build_csharp.sh
  34. 11 6
      tools/run_tests/run_csharp.sh
  35. 8 3
      tools/run_tests/run_tests.py
  36. 1 1
      vsprojects/grpc++/grpc++.vcxproj
  37. 3 3
      vsprojects/grpc++/grpc++.vcxproj.filters

+ 7 - 0
.travis.yml

@@ -2,13 +2,19 @@ language: cpp
 before_install:
   - sudo add-apt-repository ppa:yjwong/gflags -y
   - sudo add-apt-repository ppa:h-rayflood/llvm -y
+  - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
+  - echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
+  - echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
   - sudo apt-get update -qq
   - sudo apt-get install -qq libgtest-dev libgflags-dev python-virtualenv clang-3.5
   - sudo pip install cpp-coveralls mako simplejson
+  - sudo apt-get install -qq mono-devel nunit
+  - wget www.nuget.org/NuGet.exe -O nuget.exe
 env:
   global:
     - RUBY_VERSION=2.1
     - COVERALLS_PARALLEL=true
+    - NUGET="mono nuget.exe"
   matrix:
     - CONFIG=opt TEST=sanity
     - CONFIG=dbg TEST=c
@@ -18,6 +24,7 @@ env:
     - CONFIG=opt TEST=node
     - CONFIG=opt TEST=ruby
     - CONFIG=opt TEST=python
+    - CONFIG=opt TEST=csharp
     - CONFIG=gcov TEST=c
     - CONFIG=gcov TEST=c++
     - USE_GCC=4.4 CONFIG=opt TEST=build

+ 2 - 2
BUILD

@@ -579,7 +579,6 @@ cc_library(
     "src/cpp/client/channel.h",
     "src/cpp/proto/proto_utils.h",
     "src/cpp/server/thread_pool.h",
-    "src/cpp/util/time.h",
     "src/cpp/client/secure_credentials.cc",
     "src/cpp/server/secure_server_credentials.cc",
     "src/cpp/client/channel.cc",
@@ -641,6 +640,7 @@ cc_library(
     "include/grpc++/status_code_enum.h",
     "include/grpc++/stream.h",
     "include/grpc++/thread_pool_interface.h",
+    "include/grpc++/time.h",
   ],
   includes = [
     "include",
@@ -660,7 +660,6 @@ cc_library(
     "src/cpp/client/channel.h",
     "src/cpp/proto/proto_utils.h",
     "src/cpp/server/thread_pool.h",
-    "src/cpp/util/time.h",
     "src/cpp/client/channel.cc",
     "src/cpp/client/channel_arguments.cc",
     "src/cpp/client/client_context.cc",
@@ -720,6 +719,7 @@ cc_library(
     "include/grpc++/status_code_enum.h",
     "include/grpc++/stream.h",
     "include/grpc++/thread_pool_interface.h",
+    "include/grpc++/time.h",
   ],
   includes = [
     "include",

Разлика између датотеке није приказан због своје велике величине
+ 17 - 480
Makefile


+ 3 - 3
build.json

@@ -47,13 +47,13 @@
         "include/grpc++/status.h",
         "include/grpc++/status_code_enum.h",
         "include/grpc++/stream.h",
-        "include/grpc++/thread_pool_interface.h"
+        "include/grpc++/thread_pool_interface.h",
+        "include/grpc++/time.h"
       ],
       "headers": [
         "src/cpp/client/channel.h",
         "src/cpp/proto/proto_utils.h",
-        "src/cpp/server/thread_pool.h",
-        "src/cpp/util/time.h"
+        "src/cpp/server/thread_pool.h"
       ],
       "src": [
         "src/cpp/client/channel.cc",

+ 0 - 1
examples/pubsub/main.cc

@@ -31,7 +31,6 @@
  *
  */
 
-#include <chrono>
 #include <fstream>
 #include <memory>
 #include <sstream>

+ 19 - 9
include/grpc++/client_context.h

@@ -34,15 +34,14 @@
 #ifndef GRPCXX_CLIENT_CONTEXT_H
 #define GRPCXX_CLIENT_CONTEXT_H
 
-#include <chrono>
 #include <map>
+#include <memory>
 #include <string>
 
 #include <grpc/support/log.h>
 #include <grpc/support/time.h>
 #include <grpc++/config.h>
-
-using std::chrono::system_clock;
+#include <grpc++/time.h>
 
 struct grpc_call;
 struct grpc_completion_queue;
@@ -87,8 +86,19 @@ class ClientContext {
     return trailing_metadata_;
   }
 
-  void set_absolute_deadline(const system_clock::time_point& deadline);
-  system_clock::time_point absolute_deadline();
+  template <typename T>
+  void set_deadline(const T& deadline) {
+    TimePoint<T> deadline_tp(deadline);
+    deadline_ = deadline_tp.raw_time();
+  }
+
+#ifndef GRPC_CXX0X_NO_CHRONO
+  std::chrono::system_clock::time_point deadline() {
+    return Timespec2Timepoint(deadline_);
+  }
+#endif  // !GRPC_CXX0X_NO_CHRONO
+
+  gpr_timespec raw_deadline() { return deadline_; }
 
   void set_authority(const grpc::string& authority) { authority_ = authority; }
 
@@ -117,22 +127,22 @@ class ClientContext {
   friend class ::grpc::ClientAsyncResponseReader;
 
   grpc_call* call() { return call_; }
-  void set_call(grpc_call* call) {
+  void set_call(grpc_call* call, const std::shared_ptr<ChannelInterface>& channel) {
     GPR_ASSERT(call_ == nullptr);
     call_ = call;
+    channel_ = channel;
   }
 
   grpc_completion_queue* cq() { return cq_; }
   void set_cq(grpc_completion_queue* cq) { cq_ = cq; }
 
-  gpr_timespec RawDeadline() { return absolute_deadline_; }
-
   grpc::string authority() { return authority_; }
 
   bool initial_metadata_received_;
+  std::shared_ptr<ChannelInterface> channel_;
   grpc_call* call_;
   grpc_completion_queue* cq_;
-  gpr_timespec absolute_deadline_;
+  gpr_timespec deadline_;
   grpc::string authority_;
   std::multimap<grpc::string, grpc::string> send_initial_metadata_;
   std::multimap<grpc::string, grpc::string> recv_initial_metadata_;

+ 8 - 5
include/grpc++/completion_queue.h

@@ -34,10 +34,10 @@
 #ifndef GRPCXX_COMPLETION_QUEUE_H
 #define GRPCXX_COMPLETION_QUEUE_H
 
-#include <chrono>
+#include <grpc/support/time.h>
 #include <grpc++/impl/client_unary_call.h>
 #include <grpc++/impl/grpc_library.h>
-#include <grpc/support/time.h>
+#include <grpc++/time.h>
 
 struct grpc_completion_queue;
 
@@ -83,10 +83,13 @@ class CompletionQueue : public GrpcLibrary {
 
   // Nonblocking (until deadline) read from queue.
   // Cannot rely on result of tag or ok if return is TIMEOUT
-  NextStatus AsyncNext(void** tag, bool* ok,
-                       std::chrono::system_clock::time_point deadline);
+  template<typename T>
+  NextStatus AsyncNext(void** tag, bool* ok, const T& deadline) {
+    TimePoint<T> deadline_tp(deadline);
+    return AsyncNextInternal(tag, ok, deadline_tp.raw_time());
+  }
 
-  // Blocking (until deadline) read from queue.
+  // Blocking read from queue.
   // Returns false if the queue is ready for destruction, true if event
 
   bool Next(void** tag, bool* ok) {

+ 8 - 9
include/grpc++/credentials.h

@@ -34,7 +34,6 @@
 #ifndef GRPCXX_CREDENTIALS_H
 #define GRPCXX_CREDENTIALS_H
 
-#include <chrono>
 #include <memory>
 
 #include <grpc++/config.h>
@@ -99,20 +98,20 @@ std::unique_ptr<Credentials> ComputeEngineCredentials();
 // Builds service account credentials.
 // json_key is the JSON key string containing the client's private key.
 // scope is a space-delimited list of the requested permissions.
-// token_lifetime is the lifetime of each token acquired through this service
-// account credentials. It should be positive and should not exceed
-// grpc_max_auth_token_lifetime or will be cropped to this value.
+// token_lifetime_seconds is the lifetime in seconds of each token acquired
+// through this service account credentials. It should be positive and should
+// not exceed grpc_max_auth_token_lifetime or will be cropped to this value.
 std::unique_ptr<Credentials> ServiceAccountCredentials(
     const grpc::string& json_key, const grpc::string& scope,
-    std::chrono::seconds token_lifetime);
+    long token_lifetime_seconds);
 
 // Builds JWT credentials.
 // json_key is the JSON key string containing the client's private key.
-// token_lifetime is the lifetime of each Json Web Token (JWT) created with
-// this credentials.  It should not exceed grpc_max_auth_token_lifetime or
-// will be cropped to this value.
+// token_lifetime_seconds is the lifetime in seconds of each Json Web Token
+// (JWT) created with this credentials. It should not exceed
+// grpc_max_auth_token_lifetime or will be cropped to this value.
 std::unique_ptr<Credentials> JWTCredentials(
-    const grpc::string& json_key, std::chrono::seconds token_lifetime);
+    const grpc::string& json_key, long token_lifetime_seconds);
 
 // Builds refresh token credentials.
 // json_refresh_token is the JSON string containing the refresh token along

+ 9 - 4
include/grpc++/server_context.h

@@ -34,10 +34,11 @@
 #ifndef GRPCXX_SERVER_CONTEXT_H
 #define GRPCXX_SERVER_CONTEXT_H
 
-#include <chrono>
 #include <map>
 
+#include <grpc/support/time.h>
 #include <grpc++/config.h>
+#include <grpc++/time.h>
 
 struct gpr_timespec;
 struct grpc_metadata;
@@ -71,9 +72,13 @@ class ServerContext {
   ServerContext();  // for async calls
   ~ServerContext();
 
-  std::chrono::system_clock::time_point absolute_deadline() {
-    return deadline_;
+#ifndef GRPC_CXX0X_NO_CHRONO
+  std::chrono::system_clock::time_point deadline() {
+    return Timespec2Timepoint(deadline_);
   }
+#endif  // !GRPC_CXX0X_NO_CHRONO
+
+  gpr_timespec raw_deadline() { return deadline_; }
 
   void AddInitialMetadata(const grpc::string& key, const grpc::string& value);
   void AddTrailingMetadata(const grpc::string& key, const grpc::string& value);
@@ -110,7 +115,7 @@ class ServerContext {
 
   CompletionOp* completion_op_;
 
-  std::chrono::system_clock::time_point deadline_;
+  gpr_timespec deadline_;
   grpc_call* call_;
   CompletionQueue* cq_;
   bool sent_initial_metadata_;

+ 58 - 3
src/cpp/util/time.h → include/grpc++/time.h

@@ -31,8 +31,50 @@
  *
  */
 
-#ifndef GRPC_INTERNAL_CPP_UTIL_TIME_H
-#define GRPC_INTERNAL_CPP_UTIL_TIME_H
+#ifndef GRPCXX_TIME_H
+#define GRPCXX_TIME_H
+
+#include <grpc++/config.h>
+
+namespace grpc {
+
+/* If you are trying to use CompletionQueue::AsyncNext with a time class that
+   isn't either gpr_timespec or std::chrono::system_clock::time_point, you
+   will most likely be looking at this comment as your compiler will have
+   fired an error below. In order to fix this issue, you have two potential
+   solutions:
+
+     1. Use gpr_timespec or std::chrono::system_clock::time_point instead
+     2. Specialize the TimePoint class with whichever time class that you
+        want to use here. See below for two examples of how to do this.
+ */
+
+template <typename T>
+class TimePoint {
+ public:
+  TimePoint(const T& time) {
+    you_need_a_specialization_of_TimePoint();
+  }
+  gpr_timespec raw_time() {
+    gpr_timespec t;
+    return t;
+  }
+ private:
+  void you_need_a_specialization_of_TimePoint();
+};
+
+template<>
+class TimePoint<gpr_timespec> {
+ public:
+  TimePoint(const gpr_timespec& time) : time_(time) { }
+  gpr_timespec raw_time() { return time_; }
+ private:
+  gpr_timespec time_;
+};
+
+}  // namespace grpc
+
+#ifndef GRPC_CXX0X_NO_CHRONO
 
 #include <chrono>
 
@@ -46,6 +88,19 @@ void Timepoint2Timespec(const std::chrono::system_clock::time_point& from,
 
 std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t);
 
+template <>
+class TimePoint<std::chrono::system_clock::time_point> {
+ public:
+  TimePoint(const std::chrono::system_clock::time_point& time) {
+	Timepoint2Timespec(time, &time_);
+  }
+  gpr_timespec raw_time() const { return time_; }
+ private:
+  gpr_timespec time_;
+};
+
 }  // namespace grpc
 
-#endif  // GRPC_INTERNAL_CPP_UTIL_TIME_H
+#endif  // !GRPC_CXX0X_NO_CHRONO
+
+#endif  // GRPCXX_TIME_H

+ 1 - 1
include/grpc/support/tls.h

@@ -44,7 +44,7 @@
    Thread locals have type gpr_intptr.
 
    Declaring a thread local variable 'foo':
-     GPR_TLS_DECL(foo, initial_value);
+     GPR_TLS_DECL(foo);
    Thread locals always have static scope.
 
    Initializing a thread local (must be done at library initialization 

+ 1 - 1
src/core/iomgr/pollset_multipoller_with_poll_posix.c

@@ -203,7 +203,7 @@ static int multipoll_with_poll_pollset_maybe_work(
 }
 
 static void multipoll_with_poll_pollset_kick(grpc_pollset *p) {
-  grpc_pollset_kick_kick(&p->kick_state);
+  grpc_pollset_force_kick(p);
 }
 
 static void multipoll_with_poll_pollset_destroy(grpc_pollset *pollset) {

+ 22 - 6
src/core/iomgr/pollset_posix.c

@@ -47,9 +47,11 @@
 #include "src/core/iomgr/fd_posix.h"
 #include "src/core/iomgr/iomgr_internal.h"
 #include "src/core/iomgr/socket_utils_posix.h"
+#include "src/core/profiling/timers.h"
 #include <grpc/support/alloc.h>
 #include <grpc/support/log.h>
 #include <grpc/support/thd.h>
+#include <grpc/support/tls.h>
 #include <grpc/support/useful.h>
 
 static grpc_pollset g_backup_pollset;
@@ -57,6 +59,8 @@ static int g_shutdown_backup_poller;
 static gpr_event g_backup_poller_done;
 static gpr_event g_backup_pollset_shutdown_done;
 
+GPR_TLS_DECL(g_current_thread_poller);
+
 static void backup_poller(void *p) {
   gpr_timespec delta = gpr_time_from_millis(100);
   gpr_timespec last_poll = gpr_now();
@@ -76,17 +80,21 @@ static void backup_poller(void *p) {
 }
 
 void grpc_pollset_kick(grpc_pollset *p) {
-  if (p->counter) {
+  if (gpr_tls_get(&g_current_thread_poller) != (gpr_intptr)p && p->counter) {
     p->vtable->kick(p);
   }
 }
 
 void grpc_pollset_force_kick(grpc_pollset *p) {
-  grpc_pollset_kick_kick(&p->kick_state);
+  if (gpr_tls_get(&g_current_thread_poller) != (gpr_intptr)p) {
+    grpc_pollset_kick_kick(&p->kick_state);
+  }
 }
 
 static void kick_using_pollset_kick(grpc_pollset *p) {
-  grpc_pollset_kick_kick(&p->kick_state);
+  if (gpr_tls_get(&g_current_thread_poller) != (gpr_intptr)p) {
+    grpc_pollset_kick_kick(&p->kick_state);
+  }
 }
 
 /* global state management */
@@ -96,6 +104,8 @@ grpc_pollset *grpc_backup_pollset(void) { return &g_backup_pollset; }
 void grpc_pollset_global_init(void) {
   gpr_thd_id id;
 
+  gpr_tls_init(&g_current_thread_poller);
+
   /* Initialize kick fd state */
   grpc_pollset_kick_global_init();
 
@@ -129,6 +139,8 @@ void grpc_pollset_global_shutdown(void) {
 
   /* destroy the kick pipes */
   grpc_pollset_kick_global_destroy();
+
+  gpr_tls_destroy(&g_current_thread_poller);
 }
 
 /* main interface */
@@ -161,8 +173,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;
-  now = gpr_now();
+  gpr_timespec now = gpr_now();
+  int r;
   if (gpr_time_cmp(now, deadline) > 0) {
     return 0;
   }
@@ -172,7 +184,10 @@ int grpc_pollset_work(grpc_pollset *pollset, gpr_timespec deadline) {
   if (grpc_alarm_check(&pollset->mu, now, &deadline)) {
     return 1;
   }
-  return pollset->vtable->maybe_work(pollset, deadline, now, 1);
+  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);
+  return r;
 }
 
 void grpc_pollset_shutdown(grpc_pollset *pollset,
@@ -396,6 +411,7 @@ static int unary_poll_pollset_maybe_work(grpc_pollset *pollset,
   pfd[1].events = grpc_fd_begin_poll(fd, pollset, POLLIN, POLLOUT, &fd_watcher);
 
   r = poll(pfd, GPR_ARRAY_SIZE(pfd), timeout);
+  GRPC_TIMER_MARK(POLL_FINISHED, r);
 
   grpc_fd_end_poll(&fd_watcher);
 

+ 0 - 4
src/core/iomgr/resolve_address_windows.c

@@ -65,7 +65,6 @@ grpc_resolved_addresses *grpc_blocking_resolve_address(
   int s;
   size_t i;
   grpc_resolved_addresses *addrs = NULL;
-  const gpr_timespec start_time = gpr_now();
 
   /* parse name, splitting it into host and port parts */
   gpr_split_host_port(name, &host, &port);
@@ -108,9 +107,6 @@ grpc_resolved_addresses *grpc_blocking_resolve_address(
   }
 
   {
-    const gpr_timespec delay = gpr_time_sub(gpr_now(), start_time);
-    const int delay_ms =
-        delay.tv_sec * GPR_MS_PER_SEC + delay.tv_nsec / GPR_NS_PER_MS;
     for (i = 0; i < addrs->naddrs; i++) {
       char *buf;
       grpc_sockaddr_to_string(&buf, (struct sockaddr *)&addrs->addrs[i].addr,

+ 1 - 1
src/core/iomgr/tcp_server_windows.c

@@ -192,7 +192,7 @@ static void start_accept(server_port *port) {
   }
 
   /* TODO(jtattermusch): probably a race here, we regularly get use-after-free on server shutdown */
-  GPR_ASSERT(port->socket != 0xfeeefeee);
+  GPR_ASSERT(port->socket != (grpc_winsocket*)0xfeeefeee);
   success = port->AcceptEx(port->socket->socket, sock, port->addresses, 0,
                            addrlen, addrlen, &bytes_received,
                            &port->socket->read_info.overlapped);

+ 1 - 0
src/core/surface/server.c

@@ -1083,6 +1083,7 @@ static void begin_call(grpc_server *server, call_data *calld,
             &rc->data.batch.details->host_capacity, calld->host);
       cpstr(&rc->data.batch.details->method,
             &rc->data.batch.details->method_capacity, calld->path);
+      rc->data.batch.details->deadline = calld->deadline;
       grpc_call_set_completion_queue(calld->call, rc->data.batch.cq_bind);
       *rc->data.batch.call = calld->call;
       r->op = GRPC_IOREQ_RECV_INITIAL_METADATA;

+ 1 - 0
src/core/tsi/ssl_transport_security.c

@@ -34,6 +34,7 @@
 #include "src/core/tsi/ssl_transport_security.h"
 
 #include <limits.h>
+#include <string.h>
 
 #include <grpc/support/log.h>
 #include <grpc/support/sync.h>

+ 3 - 4
src/cpp/client/channel.cc

@@ -33,7 +33,6 @@
 
 #include "src/cpp/client/channel.h"
 
-#include <chrono>
 #include <memory>
 
 #include <grpc/grpc.h>
@@ -65,14 +64,14 @@ Call Channel::CreateCall(const RpcMethod& method, ClientContext* context,
       method.channel_tag()
           ? grpc_channel_create_registered_call(c_channel_, cq->cq(),
                                                 method.channel_tag(),
-                                                context->RawDeadline())
+                                                context->raw_deadline())
           : grpc_channel_create_call(c_channel_, cq->cq(), method.name(),
                                      context->authority().empty()
                                          ? target_.c_str()
                                          : context->authority().c_str(),
-                                     context->RawDeadline());
+                                     context->raw_deadline());
   GRPC_TIMER_MARK(CALL_CREATED, c_call);
-  context->set_call(c_call);
+  context->set_call(c_call, shared_from_this());
   return Call(c_call, this, cq);
 }
 

+ 1 - 0
src/cpp/client/channel.h

@@ -51,6 +51,7 @@ class Credentials;
 class StreamContextInterface;
 
 class Channel GRPC_FINAL : public GrpcLibrary,
+                           public std::enable_shared_from_this<Channel>,
                            public ChannelInterface {
  public:
   Channel(const grpc::string& target, grpc_channel* c_channel);

+ 2 - 13
src/cpp/client/client_context.cc

@@ -34,9 +34,7 @@
 #include <grpc++/client_context.h>
 
 #include <grpc/grpc.h>
-#include "src/cpp/util/time.h"
-
-using std::chrono::system_clock;
+#include <grpc++/time.h>
 
 namespace grpc {
 
@@ -44,7 +42,7 @@ ClientContext::ClientContext()
     : initial_metadata_received_(false),
       call_(nullptr),
       cq_(nullptr),
-      absolute_deadline_(gpr_inf_future) {}
+      deadline_(gpr_inf_future) {}
 
 ClientContext::~ClientContext() {
   if (call_) {
@@ -64,15 +62,6 @@ ClientContext::~ClientContext() {
   }
 }
 
-void ClientContext::set_absolute_deadline(
-    const system_clock::time_point& deadline) {
-  Timepoint2Timespec(deadline, &absolute_deadline_);
-}
-
-system_clock::time_point ClientContext::absolute_deadline() {
-  return Timespec2Timepoint(absolute_deadline_);
-}
-
 void ClientContext::AddMetadata(const grpc::string& meta_key,
                                 const grpc::string& meta_value) {
   send_initial_metadata_.insert(std::make_pair(meta_key, meta_value));

+ 6 - 6
src/cpp/client/secure_credentials.cc

@@ -81,27 +81,27 @@ std::unique_ptr<Credentials> ComputeEngineCredentials() {
 // Builds service account credentials.
 std::unique_ptr<Credentials> ServiceAccountCredentials(
     const grpc::string& json_key, const grpc::string& scope,
-    std::chrono::seconds token_lifetime) {
-  if (token_lifetime.count() <= 0) {
+    long token_lifetime_seconds) {
+  if (token_lifetime_seconds <= 0) {
     gpr_log(GPR_ERROR,
             "Trying to create ServiceAccountCredentials "
             "with non-positive lifetime");
     return WrapCredentials(nullptr);
   }
-  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime.count());
+  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime_seconds);
   return WrapCredentials(grpc_service_account_credentials_create(
       json_key.c_str(), scope.c_str(), lifetime));
 }
 
 // Builds JWT credentials.
 std::unique_ptr<Credentials> JWTCredentials(
-    const grpc::string& json_key, std::chrono::seconds token_lifetime) {
-  if (token_lifetime.count() <= 0) {
+    const grpc::string& json_key, long token_lifetime_seconds) {
+  if (token_lifetime_seconds <= 0) {
     gpr_log(GPR_ERROR,
             "Trying to create JWTCredentials with non-positive lifetime");
     return WrapCredentials(nullptr);
   }
-  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime.count());
+  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime_seconds);
   return WrapCredentials(
       grpc_jwt_credentials_create(json_key.c_str(), lifetime));
 }

+ 1 - 8
src/cpp/common/completion_queue.cc

@@ -36,7 +36,7 @@
 
 #include <grpc/grpc.h>
 #include <grpc/support/log.h>
-#include "src/cpp/util/time.h"
+#include <grpc++/time.h>
 
 namespace grpc {
 
@@ -77,13 +77,6 @@ CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal(
   }
 }
 
-CompletionQueue::NextStatus CompletionQueue::AsyncNext(
-    void** tag, bool* ok, std::chrono::system_clock::time_point deadline) {
-  gpr_timespec gpr_deadline;
-  Timepoint2Timespec(deadline, &gpr_deadline);
-  return AsyncNextInternal(tag, ok, gpr_deadline);
-}
-
 bool CompletionQueue::Pluck(CompletionQueueTag* tag) {
   std::unique_ptr<grpc_event, EventDeleter> ev;
 

+ 2 - 2
src/cpp/server/server.cc

@@ -45,10 +45,10 @@
 #include <grpc++/server_context.h>
 #include <grpc++/server_credentials.h>
 #include <grpc++/thread_pool_interface.h>
+#include <grpc++/time.h>
 
 #include "src/core/profiling/timers.h"
 #include "src/cpp/proto/proto_utils.h"
-#include "src/cpp/util/time.h"
 
 namespace grpc {
 
@@ -353,7 +353,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
     ServerContext* ctx = ctx_ ? ctx_ : generic_ctx_;
     GPR_ASSERT(ctx);
     if (*status) {
-      ctx->deadline_ = Timespec2Timepoint(call_details_.deadline);
+      ctx->deadline_ = call_details_.deadline;
       for (size_t i = 0; i < array_.count; i++) {
         ctx->client_metadata_.insert(std::make_pair(
             grpc::string(array_.metadata[i].key),

+ 4 - 4
src/cpp/server/server_context.cc

@@ -33,11 +33,11 @@
 
 #include <grpc++/server_context.h>
 
-#include <grpc++/impl/call.h>
-#include <grpc++/impl/sync.h>
 #include <grpc/grpc.h>
 #include <grpc/support/log.h>
-#include "src/cpp/util/time.h"
+#include <grpc++/impl/call.h>
+#include <grpc++/impl/sync.h>
+#include <grpc++/time.h>
 
 namespace grpc {
 
@@ -99,7 +99,7 @@ ServerContext::ServerContext()
 ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata,
                              size_t metadata_count)
     : completion_op_(nullptr),
-      deadline_(Timespec2Timepoint(deadline)),
+      deadline_(deadline),
       call_(nullptr),
       cq_(nullptr),
       sent_initial_metadata_(false) {

+ 6 - 1
src/cpp/util/time.cc

@@ -31,9 +31,12 @@
  *
  */
 
-#include "src/cpp/util/time.h"
+#include <grpc++/config.h>
+
+#ifndef GRPC_CXX0X_NO_CHRONO
 
 #include <grpc/support/time.h>
+#include <grpc++/time.h>
 
 using std::chrono::duration_cast;
 using std::chrono::nanoseconds;
@@ -68,3 +71,5 @@ system_clock::time_point Timespec2Timepoint(gpr_timespec t) {
 }
 
 }  // namespace grpc
+
+#endif  // !GRPC_CXX0X_NO_CHRONO

+ 2 - 9
templates/Makefile.template

@@ -1208,17 +1208,10 @@ endif
 % if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
 endif
 % endif
-
 % for src in lib.src:
-% if not proto_re.match(src):
-$(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
-% for src2 in lib.src:
-% if proto_re.match(src2):
-    ${proto_to_cc(src2)}\
+% if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
+$(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))}
 % endif
-% endfor
-% endif
-
 % endfor
 </%def>
 

+ 1 - 1
test/cpp/client/credentials_test.cc

@@ -47,7 +47,7 @@ class CredentialsTest : public ::testing::Test {
 
 TEST_F(CredentialsTest, InvalidServiceAccountCreds) {
   std::unique_ptr<Credentials> bad1 =
-      ServiceAccountCredentials("", "", std::chrono::seconds(1));
+      ServiceAccountCredentials("", "", 1);
   EXPECT_EQ(nullptr, bad1.get());
 }
 

+ 2 - 3
test/cpp/end2end/async_end2end_test.cc

@@ -31,13 +31,12 @@
  *
  */
 
-#include <chrono>
 #include <memory>
 
+#include "test/core/util/port.h"
 #include "test/core/util/test_config.h"
 #include "test/cpp/util/echo_duplicate.grpc.pb.h"
 #include "test/cpp/util/echo.grpc.pb.h"
-#include "src/cpp/util/time.h"
 #include <grpc++/async_unary_call.h>
 #include <grpc++/channel_arguments.h>
 #include <grpc++/channel_interface.h>
@@ -50,7 +49,7 @@
 #include <grpc++/server_credentials.h>
 #include <grpc++/status.h>
 #include <grpc++/stream.h>
-#include "test/core/util/port.h"
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 #include <grpc/grpc.h>

+ 8 - 9
test/cpp/end2end/end2end_test.cc

@@ -31,13 +31,12 @@
  *
  */
 
-#include <chrono>
 #include <thread>
 
+#include "test/core/util/port.h"
 #include "test/core/util/test_config.h"
 #include "test/cpp/util/echo_duplicate.grpc.pb.h"
 #include "test/cpp/util/echo.grpc.pb.h"
-#include "src/cpp/util/time.h"
 #include "src/cpp/server/thread_pool.h"
 #include <grpc++/channel_arguments.h>
 #include <grpc++/channel_interface.h>
@@ -50,7 +49,7 @@
 #include <grpc++/server_credentials.h>
 #include <grpc++/status.h>
 #include <grpc++/stream.h>
-#include "test/core/util/port.h"
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 #include <grpc/grpc.h>
@@ -72,8 +71,8 @@ void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request,
                        EchoResponse* response) {
   if (request->has_param() && request->param().echo_deadline()) {
     gpr_timespec deadline = gpr_inf_future;
-    if (context->absolute_deadline() != system_clock::time_point::max()) {
-      Timepoint2Timespec(context->absolute_deadline(), &deadline);
+    if (context->deadline() != system_clock::time_point::max()) {
+      Timepoint2Timespec(context->deadline(), &deadline);
     }
     response->mutable_param()->set_request_deadline(deadline.tv_sec);
   }
@@ -245,7 +244,7 @@ TEST_F(End2endTest, RpcDeadlineExpires) {
   ClientContext context;
   std::chrono::system_clock::time_point deadline =
       std::chrono::system_clock::now() + std::chrono::microseconds(10);
-  context.set_absolute_deadline(deadline);
+  context.set_deadline(deadline);
   Status s = stub_->Echo(&context, request, &response);
   EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, s.code());
 }
@@ -260,7 +259,7 @@ TEST_F(End2endTest, RpcLongDeadline) {
   ClientContext context;
   std::chrono::system_clock::time_point deadline =
       std::chrono::system_clock::now() + std::chrono::hours(1);
-  context.set_absolute_deadline(deadline);
+  context.set_deadline(deadline);
   Status s = stub_->Echo(&context, request, &response);
   EXPECT_EQ(response.message(), request.message());
   EXPECT_TRUE(s.IsOk());
@@ -277,7 +276,7 @@ TEST_F(End2endTest, EchoDeadline) {
   ClientContext context;
   std::chrono::system_clock::time_point deadline =
       std::chrono::system_clock::now() + std::chrono::seconds(100);
-  context.set_absolute_deadline(deadline);
+  context.set_deadline(deadline);
   Status s = stub_->Echo(&context, request, &response);
   EXPECT_EQ(response.message(), request.message());
   EXPECT_TRUE(s.IsOk());
@@ -428,7 +427,7 @@ TEST_F(End2endTest, DiffPackageServices) {
 // rpc and stream should fail on bad credentials.
 TEST_F(End2endTest, BadCredentials) {
   std::unique_ptr<Credentials> bad_creds =
-      ServiceAccountCredentials("", "", std::chrono::seconds(1));
+      ServiceAccountCredentials("", "", 1);
   EXPECT_EQ(nullptr, bad_creds.get());
   std::shared_ptr<ChannelInterface> channel =
       CreateChannel(server_address_.str(), bad_creds, ChannelArguments());

+ 1 - 2
test/cpp/end2end/generic_end2end_test.cc

@@ -31,11 +31,9 @@
  *
  */
 
-#include <chrono>
 #include <memory>
 
 #include "src/cpp/proto/proto_utils.h"
-#include "src/cpp/util/time.h"
 #include "test/core/util/port.h"
 #include "test/core/util/test_config.h"
 #include "test/cpp/util/echo.grpc.pb.h"
@@ -55,6 +53,7 @@
 #include <grpc++/slice.h>
 #include <grpc++/status.h>
 #include <grpc++/stream.h>
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 #include <grpc/grpc.h>

+ 4 - 2
test/cpp/interop/client_helper.cc

@@ -85,8 +85,9 @@ std::shared_ptr<ChannelInterface> CreateChannelForTestCase(
     std::unique_ptr<Credentials> creds;
     GPR_ASSERT(FLAGS_enable_ssl);
     grpc::string json_key = GetServiceAccountJsonKey();
+    std::chrono::seconds token_lifetime = std::chrono::hours(1);
     creds = ServiceAccountCredentials(json_key, FLAGS_oauth_scope,
-                                      std::chrono::hours(1));
+                                      token_lifetime.count());
     return CreateTestChannel(host_port, FLAGS_server_host_override,
                              FLAGS_enable_ssl, FLAGS_use_prod_roots, creds);
   } else if (test_case == "compute_engine_creds") {
@@ -99,7 +100,8 @@ std::shared_ptr<ChannelInterface> CreateChannelForTestCase(
     std::unique_ptr<Credentials> creds;
     GPR_ASSERT(FLAGS_enable_ssl);
     grpc::string json_key = GetServiceAccountJsonKey();
-    creds = JWTCredentials(json_key, std::chrono::hours(1));
+    std::chrono::seconds token_lifetime = std::chrono::hours(1);
+    creds = JWTCredentials(json_key, token_lifetime.count());
     return CreateTestChannel(host_port, FLAGS_server_host_override,
                              FLAGS_enable_ssl, FLAGS_use_prod_roots, creds);
   } else {

+ 1 - 4
test/cpp/util/time_test.cc

@@ -31,11 +31,8 @@
  *
  */
 
-#include "src/cpp/util/time.h"
-
-#include <chrono>
-
 #include <grpc/support/time.h>
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 using std::chrono::duration_cast;

+ 13 - 1
tools/run_tests/build_csharp.sh

@@ -30,9 +30,21 @@
 
 set -ex
 
+if [ "$CONFIG" = "dbg" ]
+then
+  MSBUILD_CONFIG="Debug"
+else
+  MSBUILD_CONFIG="Release"
+fi
+
 # change to gRPC repo root
 cd $(dirname $0)/../..
 
 root=`pwd`
 
-xbuild src/csharp/Grpc.sln
+if [ -n "$NUGET" ]
+then
+  $NUGET restore src/csharp/Grpc.sln
+fi
+
+xbuild /p:Configuration=$MSBUILD_CONFIG src/csharp/Grpc.sln

+ 11 - 6
tools/run_tests/run_csharp.sh

@@ -30,17 +30,22 @@
 
 set -ex
 
+CONFIG=${CONFIG:-opt}
+
+if [ "$CONFIG" = "dbg" ]
+then
+  MSBUILD_CONFIG="Debug"
+else
+  MSBUILD_CONFIG="Release"
+fi
+
 # change to gRPC repo root
 cd $(dirname $0)/../..
 
 root=`pwd`
 cd src/csharp
 
-# TODO: All the tests run pretty fast. In the future, we might need to teach
-# run_tests.py about separate tests to make them run in parallel.
-for assembly_name in Grpc.Core.Tests Grpc.Examples.Tests Grpc.IntegrationTesting
-do
-  LD_LIBRARY_PATH=$root/libs/dbg nunit-console -labels $assembly_name/bin/Debug/$assembly_name.dll
-done
+export LD_LIBRARY_PATH=$root/libs/$CONFIG
+nunit-console -labels "$1/bin/$MSBUILD_CONFIG/$1.dll"
 
 

+ 8 - 3
tools/run_tests/run_tests.py

@@ -61,7 +61,7 @@ class SimpleConfig(object):
     self.environ = environ
     self.environ['CONFIG'] = config
 
-  def job_spec(self, cmdline, hash_targets):
+  def job_spec(self, cmdline, hash_targets, shortname=None):
     """Construct a jobset.JobSpec for a test under this config
 
        Args:
@@ -74,6 +74,7 @@ class SimpleConfig(object):
                           be listed
     """
     return jobset.JobSpec(cmdline=cmdline,
+                          shortname=shortname,
                           environ=self.environ,
                           hash_targets=hash_targets
                               if self.allow_hashing else None)
@@ -218,9 +219,13 @@ class RubyLanguage(object):
 
 
 class CSharpLanguage(object):
-
   def test_specs(self, config, travis):
-    return [config.job_spec('tools/run_tests/run_csharp.sh', None)]
+    assemblies = ['Grpc.Core.Tests',
+                  'Grpc.Examples.Tests',
+                  'Grpc.IntegrationTesting']
+    return [config.job_spec(['tools/run_tests/run_csharp.sh', assembly],
+            None, shortname=assembly)
+            for assembly in assemblies ]
 
   def make_targets(self):
     return ['grpc_csharp_ext']

+ 1 - 1
vsprojects/grpc++/grpc++.vcxproj

@@ -116,6 +116,7 @@
     <ClInclude Include="..\..\include\grpc++\status_code_enum.h" />
     <ClInclude Include="..\..\include\grpc++\stream.h" />
     <ClInclude Include="..\..\include\grpc++\thread_pool_interface.h" />
+    <ClInclude Include="..\..\include\grpc++\time.h" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cpp\client\secure_credentials.h" />
@@ -123,7 +124,6 @@
     <ClInclude Include="..\..\src\cpp\client\channel.h" />
     <ClInclude Include="..\..\src\cpp\proto\proto_utils.h" />
     <ClInclude Include="..\..\src\cpp\server\thread_pool.h" />
-    <ClInclude Include="..\..\src\cpp\util\time.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\cpp\client\secure_credentials.cc">

+ 3 - 3
vsprojects/grpc++/grpc++.vcxproj.filters

@@ -180,6 +180,9 @@
     <ClInclude Include="..\..\include\grpc++\thread_pool_interface.h">
       <Filter>include\grpc++</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\include\grpc++\time.h">
+      <Filter>include\grpc++</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cpp\client\secure_credentials.h">
@@ -197,9 +200,6 @@
     <ClInclude Include="..\..\src\cpp\server\thread_pool.h">
       <Filter>src\cpp\server</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\cpp\util\time.h">
-      <Filter>src\cpp\util</Filter>
-    </ClInclude>
   </ItemGroup>
 
   <ItemGroup>

Неке датотеке нису приказане због велике количине промена