internal_errqueue.cc
Go to the documentation of this file.
1 // Copyright 2018 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
16 
18 
19 #include <grpc/impl/codegen/log.h>
20 
22 
23 #ifdef GRPC_POSIX_SOCKET_TCP
24 
25 #include <errno.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <sys/utsname.h>
29 
30 namespace grpc_core {
31 
32 bool KernelSupportsErrqueue() {
33  static const bool errqueue_supported = []() {
34 #ifdef GRPC_LINUX_ERRQUEUE
35  // Both-compile time and run-time linux kernel versions should be at
36  // least 4.0.0
37  struct utsname buffer;
38  if (uname(&buffer) != 0) {
39  gpr_log(GPR_ERROR, "uname: %s", strerror(errno));
40  return false;
41  }
42  char* release = buffer.release;
43  if (release == nullptr) {
44  return false;
45  }
46 
47  if (strtol(release, nullptr, 10) >= 4) {
48  return true;
49  } else {
50  gpr_log(GPR_DEBUG, "ERRQUEUE support not enabled");
51  }
52 #endif // GRPC_LINUX_ERRQUEUE
53  return false;
54  }();
55  return errqueue_supported;
56 }
57 } // namespace grpc_core
58 
59 #endif // GRPC_POSIX_SOCKET_TCP
grpc_core
Definition: call_metric_recorder.h:31
string.h
log.h
internal_errqueue.h
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
buffer
char buffer[1024]
Definition: libuv/docs/code/idle-compute/main.c:8
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
port.h
release
return ret release()
Definition: doc/python/sphinx/conf.py:37
GPR_DEBUG
#define GPR_DEBUG
Definition: include/grpc/impl/codegen/log.h:55
errno.h
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:21