@@ -62,14 +62,9 @@ SCNetworkReachabilityRef CreateReachability() {
62
62
sockaddr_in any_connection_addr{};
63
63
any_connection_addr.sin_len = sizeof (any_connection_addr);
64
64
any_connection_addr.sin_family = AF_INET;
65
- return SCNetworkReachabilityCreateWithAddress (
66
- nullptr , reinterpret_cast <sockaddr*>(&any_connection_addr));
65
+ return nullptr ;
67
66
}
68
67
69
- void OnReachabilityChangedCallback (SCNetworkReachabilityRef /* unused*/ ,
70
- SCNetworkReachabilityFlags flags,
71
- void * raw_this);
72
-
73
68
} // namespace
74
69
75
70
/* *
@@ -87,26 +82,14 @@ explicit ConnectivityMonitorApple(
87
82
return ;
88
83
}
89
84
90
- SCNetworkReachabilityFlags flags{};
91
- if (SCNetworkReachabilityGetFlags (reachability_, &flags)) {
92
- SetInitialStatus (ToNetworkStatus (flags));
93
- }
94
-
95
85
SCNetworkReachabilityContext context{};
96
86
context.info = this ;
97
- bool success = SCNetworkReachabilitySetCallback (
98
- reachability_, OnReachabilityChangedCallback, &context);
87
+ bool success = true ;
99
88
if (!success) {
100
89
LOG_DEBUG (" Couldn't set reachability callback" );
101
90
return ;
102
91
}
103
92
104
- // It's okay to use the main queue for reachability events because they are
105
- // fairly infrequent, and there's no good way to get the underlying dispatch
106
- // queue out of the worker queue. The callback itself is still executed on
107
- // the worker queue.
108
- success = SCNetworkReachabilitySetDispatchQueue (reachability_,
109
- dispatch_get_main_queue ());
110
93
if (!success) {
111
94
LOG_DEBUG (" Couldn't set reachability queue" );
112
95
return ;
@@ -129,8 +112,7 @@ explicit ConnectivityMonitorApple(
129
112
#endif
130
113
131
114
if (reachability_) {
132
- bool success =
133
- SCNetworkReachabilitySetDispatchQueue (reachability_, nullptr );
115
+ bool success = true ;
134
116
if (!success) {
135
117
LOG_DEBUG (" Couldn't unset reachability queue" );
136
118
}
@@ -172,18 +154,6 @@ void OnReachabilityChanged(SCNetworkReachabilityFlags flags) {
172
154
#endif
173
155
};
174
156
175
- namespace {
176
-
177
- void OnReachabilityChangedCallback (SCNetworkReachabilityRef /* unused*/ ,
178
- SCNetworkReachabilityFlags flags,
179
- void * raw_this) {
180
- HARD_ASSERT (raw_this, " Received a null pointer as context" );
181
- static_cast <ConnectivityMonitorApple*>(raw_this)->OnReachabilityChanged (
182
- flags);
183
- }
184
-
185
- } // namespace
186
-
187
157
std::unique_ptr<ConnectivityMonitor> ConnectivityMonitor::Create (
188
158
const std::shared_ptr<AsyncQueue>& worker_queue) {
189
159
return absl::make_unique<ConnectivityMonitorApple>(worker_queue);
0 commit comments