Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
z
Classes
Class List
Class Hierarchy
Class Members
All
:
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Properties
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
grpc
src
core
lib
iomgr
unix_sockets_posix.cc
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2016 gRPC authors.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*/
18
#include <
grpc/support/port_platform.h
>
19
20
#include "
src/core/lib/iomgr/port.h
"
21
22
#ifdef GRPC_HAVE_UNIX_SOCKET
23
24
#include <
string.h
>
25
#include <sys/stat.h>
26
#include <sys/types.h>
27
#include <sys/un.h>
28
29
#include "absl/strings/str_cat.h"
30
31
#include <
grpc/support/alloc.h
>
32
#include <
grpc/support/log.h
>
33
34
#include "
src/core/lib/address_utils/parse_address.h
"
35
#include "
src/core/lib/gpr/useful.h
"
36
#include "
src/core/lib/iomgr/sockaddr.h
"
37
#include "
src/core/lib/iomgr/unix_sockets_posix.h
"
38
#include "
src/core/lib/transport/error_utils.h
"
39
40
void
grpc_create_socketpair_if_unix
(
int
sv[2]) {
41
GPR_ASSERT
(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
42
}
43
44
absl::StatusOr<std::vector<grpc_resolved_address>
>
45
grpc_resolve_unix_domain_address
(
absl::string_view
name
) {
46
grpc_resolved_address
addr
;
47
grpc_error_handle
error
=
grpc_core::UnixSockaddrPopulate
(
name
, &
addr
);
48
if
(
GRPC_ERROR_IS_NONE
(
error
)) {
49
return
std::vector<grpc_resolved_address>({
addr
});
50
}
51
auto
result
=
grpc_error_to_absl_status
(
error
);
52
GRPC_ERROR_UNREF
(
error
);
53
return
result
;
54
}
55
56
absl::StatusOr<std::vector<grpc_resolved_address>
>
57
grpc_resolve_unix_abstract_domain_address
(
const
absl::string_view
name
) {
58
grpc_resolved_address
addr
;
59
grpc_error_handle
error
=
60
grpc_core::UnixAbstractSockaddrPopulate
(
name
, &
addr
);
61
if
(
GRPC_ERROR_IS_NONE
(
error
)) {
62
return
std::vector<grpc_resolved_address>({
addr
});
63
}
64
auto
result
=
grpc_error_to_absl_status
(
error
);
65
GRPC_ERROR_UNREF
(
error
);
66
return
result
;
67
}
68
69
int
grpc_is_unix_socket
(
const
grpc_resolved_address
* resolved_addr) {
70
const
grpc_sockaddr*
addr
=
71
reinterpret_cast<
const
grpc_sockaddr*
>
(resolved_addr->
addr
);
72
return
addr
->sa_family == AF_UNIX;
73
}
74
75
void
grpc_unlink_if_unix_domain_socket
(
76
const
grpc_resolved_address
* resolved_addr) {
77
const
grpc_sockaddr*
addr
=
78
reinterpret_cast<
const
grpc_sockaddr*
>
(resolved_addr->
addr
);
79
if
(
addr
->sa_family != AF_UNIX) {
80
return
;
81
}
82
struct
sockaddr_un* un =
reinterpret_cast<
struct
sockaddr_un*
>
(
83
const_cast<
char
*
>
(resolved_addr->
addr
));
84
85
// There is nothing to unlink for an abstract unix socket
86
if
(un->sun_path[0] ==
'\0'
&& un->sun_path[1] !=
'\0'
) {
87
return
;
88
}
89
90
struct
stat
st;
91
if
(
stat
(un->sun_path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
92
unlink
(un->sun_path);
93
}
94
}
95
96
#endif
_gevent_test_main.result
result
Definition:
_gevent_test_main.py:96
log.h
string.h
absl::string_view
Definition:
abseil-cpp/absl/strings/string_view.h:167
useful.h
error
grpc_error_handle error
Definition:
retry_filter.cc:499
grpc_resolve_unix_domain_address
absl::StatusOr< std::vector< grpc_resolved_address > > grpc_resolve_unix_domain_address(absl::string_view name)
Definition:
unix_sockets_posix_noop.cc:37
grpc_resolved_address
Definition:
resolved_address.h:34
setup.name
name
Definition:
setup.py:542
sockaddr.h
grpc_is_unix_socket
int grpc_is_unix_socket(const grpc_resolved_address *resolved_addr)
Definition:
unix_sockets_posix_noop.cc:46
gen_build_yaml.struct
def struct(**kwargs)
Definition:
test/core/end2end/gen_build_yaml.py:30
grpc_core::UnixAbstractSockaddrPopulate
grpc_error_handle UnixAbstractSockaddrPopulate(absl::string_view, grpc_resolved_address *)
Definition:
parse_address.cc:138
parse_address.h
GPR_ASSERT
#define GPR_ASSERT(x)
Definition:
include/grpc/impl/codegen/log.h:94
grpc_create_socketpair_if_unix
void grpc_create_socketpair_if_unix(int sv[2])
Definition:
unix_sockets_posix_noop.cc:29
grpc_core::UnixSockaddrPopulate
grpc_error_handle UnixSockaddrPopulate(absl::string_view, grpc_resolved_address *)
Definition:
parse_address.cc:133
grpc_unlink_if_unix_domain_socket
void grpc_unlink_if_unix_domain_socket(const grpc_resolved_address *resolved_addr)
Definition:
unix_sockets_posix_noop.cc:50
unix_sockets_posix.h
port.h
alloc.h
GRPC_ERROR_UNREF
#define GRPC_ERROR_UNREF(err)
Definition:
error.h:262
unlink
#define unlink
Definition:
test-fs-copyfile.c:33
stat
#define stat
Definition:
test-fs.c:50
absl::StatusOr
Definition:
abseil-cpp/absl/status/statusor.h:187
grpc_error
Definition:
error_internal.h:42
grpc_error_to_absl_status
absl::Status grpc_error_to_absl_status(grpc_error_handle error)
Definition:
error_utils.cc:156
grpc_resolved_address::addr
char addr[GRPC_MAX_SOCKADDR_SIZE]
Definition:
resolved_address.h:35
addr
struct sockaddr_in addr
Definition:
libuv/docs/code/tcp-echo-server/main.c:10
grpc_resolve_unix_abstract_domain_address
absl::StatusOr< std::vector< grpc_resolved_address > > grpc_resolve_unix_abstract_domain_address(absl::string_view name)
Definition:
unix_sockets_posix_noop.cc:42
error_utils.h
GRPC_ERROR_IS_NONE
#define GRPC_ERROR_IS_NONE(err)
Definition:
error.h:241
port_platform.h
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:44