@@ -45,69 +45,6 @@ namespace ws_websocketpp {
45
45
namespace transport {
46
46
namespace asio {
47
47
48
- /* **
49
- * In current versions of libstdc++, the error_constants.h code associated to mingw32
50
- * does not define certain standard enum values for `std::errc`. (In C++11 standard,
51
- * sections 19.5.2, 19.5.3.) Asio uses these for lib::asio::errc when it is compiled
52
- * as a stand-alone library, so because of the libstdc++ defect, code below referring
53
- * to lib::asio::errc::operation_canceled fails to compile on mingw.
54
- *
55
- * This workaround detects the defect using SFINAE and returns 'false' for the check
56
- * if operation_canceled is not defined, instead of failing to compile.
57
- *
58
- * If upstream patches this later by defining those enum values, then the workaround
59
- * will stop having any effect.
60
- *
61
- * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68307
62
- */
63
- namespace _workaround_gcc_libstdcpp_issue_68307_missing_values {
64
- /* **
65
- * Same as std::enable_if, but don't want to introduce dependency on <type_traits>
66
- * since that's C++11 only
67
- */
68
- template <bool B, class T = void >
69
- struct enable_if {};
70
-
71
- template <class T >
72
- struct enable_if <true , T> { typedef T type; };
73
-
74
- /* **
75
- * Metafunction to test "operation_canceled" value
76
- */
77
- template <typename T, typename ENABLE=void >
78
- struct op_canceled_helper {
79
- template <typename U>
80
- static inline bool is_op_canceled (const U & u) { return false ; }
81
- };
82
-
83
- template <typename T>
84
- struct op_canceled_helper <T, enable_if<T::operation_canceled == T::operation_canceled, void > > {
85
- template <typename U>
86
- static inline bool is_op_canceled (const U & u) { return u == T::operation_canceled; }
87
- };
88
-
89
- /* **
90
- * This function is intended to be a drop-in replacement for
91
- * (asio_ec == lib::asio::errc::operation_canceled)
92
- *
93
- * except that if lib::asio::errc::operation_canceled does not exist, it returns false,
94
- * instead of failing to compile.
95
- *
96
- * When using boost and not asio standalone, then lib::asio::errc is a namespace, not an enum class.
97
- * So the template code will fail to compile and we need to block it from being instantiated, with this
98
- * ifdef. When using boost the standard library symbol definitions aren't relevant afaik.
99
- */
100
- #ifdef ASIO_STANDALONE
101
- static inline bool is_op_canceled (const lib::asio::error_code & asio_ec) {
102
- return op_canceled_helper<lib::asio::errc, void >::is_op_canceled (asio_ec);
103
- }
104
- #else
105
- static inline bool is_op_canceled (const lib::asio::error_code & asio_ec) {
106
- return asio_ec == lib::asio::errc::operation_canceled;
107
- }
108
- #endif
109
- } // namespace _workaround
110
-
111
48
// / Asio based endpoint transport component
112
49
/* *
113
50
* transport::asio::endpoint implements an endpoint transport component using
@@ -224,7 +161,7 @@ class endpoint : public config::socket_type {
224
161
rhs.m_acceptor = NULL;
225
162
rhs.m_listen_backlog = lib::asio::socket_base::max_connections;
226
163
rhs.m_state = UNINITIALIZED;
227
-
164
+
228
165
// TODO: this needs to be updated
229
166
}
230
167
return *this;
@@ -258,8 +195,7 @@ class endpoint : public config::socket_type {
258
195
259
196
m_io_service = ptr;
260
197
m_external_io_service = true ;
261
- m_acceptor = lib::make_shared<lib::asio::ip::tcp::acceptor>(
262
- lib::ref (*m_io_service));
198
+ m_acceptor.reset (new lib::asio::ip::tcp::acceptor (*m_io_service));
263
199
264
200
m_state = READY;
265
201
ec = lib::error_code ();
@@ -289,7 +225,7 @@ class endpoint : public config::socket_type {
289
225
* @param ec Set to indicate what error occurred, if any.
290
226
*/
291
227
void init_asio (lib::error_code & ec) {
292
- // Use a smart pointer until the call is successful and ownership has
228
+ // Use a smart pointer until the call is successful and ownership has
293
229
// successfully been taken. Use unique_ptr when available.
294
230
// TODO: remove the use of auto_ptr when C++98/03 support is no longer
295
231
// necessary.
@@ -311,7 +247,7 @@ class endpoint : public config::socket_type {
311
247
* @see init_asio(io_service_ptr ptr)
312
248
*/
313
249
void init_asio () {
314
- // Use a smart pointer until the call is successful and ownership has
250
+ // Use a smart pointer until the call is successful and ownership has
315
251
// successfully been taken. Use unique_ptr when available.
316
252
// TODO: remove the use of auto_ptr when C++98/03 support is no longer
317
253
// necessary.
@@ -442,15 +378,15 @@ class endpoint : public config::socket_type {
442
378
lib::asio::io_service & get_io_service () {
443
379
return *m_io_service;
444
380
}
445
-
381
+
446
382
// / Get local TCP endpoint
447
383
/* *
448
384
* Extracts the local endpoint from the acceptor. This represents the
449
385
* address that WebSocket++ is listening on.
450
386
*
451
387
* Sets a bad_descriptor error if the acceptor is not currently listening
452
388
* or otherwise unavailable.
453
- *
389
+ *
454
390
* @since 0.7.0
455
391
*
456
392
* @param ec Set to indicate what error occurred, if any.
@@ -489,10 +425,10 @@ class endpoint : public config::socket_type {
489
425
490
426
m_acceptor->open (ep.protocol (),bec);
491
427
if (bec) {ec = clean_up_listen_after_error (bec);return ;}
492
-
428
+
493
429
m_acceptor->set_option (lib::asio::socket_base::reuse_address (m_reuse_addr),bec);
494
430
if (bec) {ec = clean_up_listen_after_error (bec);return ;}
495
-
431
+
496
432
// if a TCP pre-bind handler is present, run it
497
433
if (m_tcp_pre_bind_handler) {
498
434
ec = m_tcp_pre_bind_handler (m_acceptor);
@@ -501,13 +437,13 @@ class endpoint : public config::socket_type {
501
437
return ;
502
438
}
503
439
}
504
-
440
+
505
441
m_acceptor->bind (ep,bec);
506
442
if (bec) {ec = clean_up_listen_after_error (bec);return ;}
507
-
443
+
508
444
m_acceptor->listen (m_listen_backlog,bec);
509
445
if (bec) {ec = clean_up_listen_after_error (bec);return ;}
510
-
446
+
511
447
// Success
512
448
m_state = LISTENING;
513
449
ec = lib::error_code ();
@@ -751,9 +687,7 @@ class endpoint : public config::socket_type {
751
687
* @since 0.3.0
752
688
*/
753
689
void start_perpetual () {
754
- m_work = lib::make_shared<lib::asio::io_service::work>(
755
- lib::ref (*m_io_service)
756
- );
690
+ m_work.reset (new lib::asio::io_service::work (*m_io_service));
757
691
}
758
692
759
693
// / Clears the endpoint's perpetual flag, allowing it to exit when empty
@@ -891,15 +825,15 @@ class endpoint : public config::socket_type {
891
825
m_elog = e;
892
826
}
893
827
894
- void handle_accept (accept_handler callback, lib::asio::error_code const &
828
+ void handle_accept (accept_handler callback, lib::asio::error_code const &
895
829
asio_ec)
896
830
{
897
831
lib::error_code ret_ec;
898
832
899
833
m_alog->write (log::alevel::devel, " asio::handle_accept" );
900
834
901
835
if (asio_ec) {
902
- if (_workaround_gcc_libstdcpp_issue_68307_missing_values::is_op_canceled (asio_ec) ) {
836
+ if (asio_ec == lib::asio::errc::operation_canceled ) {
903
837
ret_ec = make_error_code (ws_websocketpp::error::operation_canceled);
904
838
} else {
905
839
log_err (log::elevel::info," asio handle_accept" ,asio_ec);
@@ -917,8 +851,7 @@ class endpoint : public config::socket_type {
917
851
918
852
// Create a resolver
919
853
if (!m_resolver) {
920
- m_resolver = lib::make_shared<lib::asio::ip::tcp::resolver>(
921
- lib::ref (*m_io_service));
854
+ m_resolver.reset (new lib::asio::ip::tcp::resolver (*m_io_service));
922
855
}
923
856
924
857
tcon->set_uri (u);
0 commit comments