Imported Upstream version 1.41.0
[platform/upstream/grpc.git] / src / core / lib / iomgr / tcp_server_windows.cc
index 614ea35..80f4d35 100644 (file)
@@ -22,8 +22,6 @@
 
 #ifdef GRPC_WINSOCK_SOCKET
 
-#include "src/core/lib/iomgr/sockaddr.h"
-
 #include <inttypes.h>
 #include <io.h>
 
@@ -43,6 +41,7 @@
 #include "src/core/lib/iomgr/iocp_windows.h"
 #include "src/core/lib/iomgr/pollset_windows.h"
 #include "src/core/lib/iomgr/resolve_address.h"
+#include "src/core/lib/iomgr/sockaddr.h"
 #include "src/core/lib/iomgr/socket_windows.h"
 #include "src/core/lib/iomgr/tcp_server.h"
 #include "src/core/lib/iomgr/tcp_windows.h"
@@ -97,13 +96,15 @@ struct grpc_tcp_server {
   grpc_closure* shutdown_complete;
 
   grpc_channel_args* channel_args;
+  grpc_slice_allocator_factory* slice_allocator_factory;
 };
 
 /* Public function. Allocates the proper data structures to hold a
    grpc_tcp_server. */
-static grpc_error_handle tcp_server_create(grpc_closure* shutdown_complete,
-                                           const grpc_channel_args* args,
-                                           grpc_tcp_server** server) {
+static grpc_error_handle tcp_server_create(
+    grpc_closure* shutdown_complete, const grpc_channel_args* args,
+    grpc_slice_allocator_factory* slice_allocator_factory,
+    grpc_tcp_server** server) {
   grpc_tcp_server* s = (grpc_tcp_server*)gpr_malloc(sizeof(grpc_tcp_server));
   s->channel_args = grpc_channel_args_copy(args);
   gpr_ref_init(&s->refs, 1);
@@ -116,6 +117,7 @@ static grpc_error_handle tcp_server_create(grpc_closure* shutdown_complete,
   s->shutdown_starting.head = NULL;
   s->shutdown_starting.tail = NULL;
   s->shutdown_complete = shutdown_complete;
+  s->slice_allocator_factory = slice_allocator_factory;
   *server = s;
   return GRPC_ERROR_NONE;
 }
@@ -166,7 +168,7 @@ static void tcp_server_shutdown_starting_add(grpc_tcp_server* s,
 static void tcp_server_destroy(grpc_tcp_server* s) {
   grpc_tcp_listener* sp;
   gpr_mu_lock(&s->mu);
-
+  grpc_slice_allocator_factory_destroy(s->slice_allocator_factory);
   /* First, shutdown all fd's. This will queue abortion calls for all
      of the pending accepts due to the normal operation mechanism. */
   if (s->active_ports == 0) {
@@ -324,7 +326,6 @@ static void on_accept(void* arg, grpc_error_handle error) {
     gpr_mu_unlock(&sp->server->mu);
     return;
   }
-
   /* The IOCP notified us of a completed operation. Let's grab the results,
      and act accordingly. */
   transfered_bytes = 0;
@@ -358,8 +359,11 @@ static void on_accept(void* arg, grpc_error_handle error) {
         gpr_free(utf8_message);
       }
       std::string fd_name = absl::StrCat("tcp_server:", peer_name_string);
-      ep = grpc_tcp_create(grpc_winsocket_create(sock, fd_name.c_str()),
-                           sp->server->channel_args, peer_name_string.c_str());
+      ep = grpc_tcp_create(
+          grpc_winsocket_create(sock, fd_name.c_str()),
+          sp->server->channel_args, peer_name_string.c_str(),
+          grpc_slice_allocator_factory_create_slice_allocator(
+              sp->server->slice_allocator_factory, peer_name_string));
     } else {
       closesocket(sock);
     }