Ticket #3702: patch
File patch, 8.5 KB (added by , 13 years ago) |
---|
-
boost/asio/ssl/detail/openssl_stream_service.hpp
21 21 #include <boost/asio/detail/push_options.hpp> 22 22 #include <cstddef> 23 23 #include <climits> 24 #include <memory>25 24 #include <boost/config.hpp> 26 25 #include <boost/noncopyable.hpp> 27 26 #include <boost/function.hpp> 28 27 #include <boost/bind.hpp> 28 #include <boost/shared_ptr.hpp> 29 29 #include <boost/asio/detail/pop_options.hpp> 30 30 31 31 #include <boost/asio/error.hpp> … … 57 57 void (const boost::system::error_code&, size_t)> func_t; 58 58 59 59 base_handler(boost::asio::io_service& io_service) 60 : op_(NULL) 61 , io_service_(io_service) 60 : io_service_(io_service) 62 61 , work_(io_service) 63 62 {} 64 63 … … 67 66 func_(error, size); 68 67 } 69 68 70 void set_operation(openssl_operation<Stream>* op) { op_ = op; }71 69 void set_func(func_t func) { func_ = func; } 72 70 73 ~base_handler()74 {75 delete op_;76 }77 78 71 private: 79 72 func_t func_; 80 openssl_operation<Stream>* op_;81 73 boost::asio::io_service& io_service_; 82 74 boost::asio::io_service::work work_; 83 75 }; // class base_handler … … 101 93 Handler handler_; 102 94 void handler_impl(const boost::system::error_code& error, size_t size) 103 95 { 104 std::auto_ptr<io_handler<Stream, Handler> > this_ptr(this);105 96 handler_(error, size); 106 97 } 107 98 }; // class io_handler … … 125 116 Handler handler_; 126 117 void handler_impl(const boost::system::error_code& error, size_t) 127 118 { 128 std::auto_ptr<handshake_handler<Stream, Handler> > this_ptr(this);129 119 handler_(error); 130 120 } 131 121 … … 150 140 Handler handler_; 151 141 void handler_impl(const boost::system::error_code& error, size_t) 152 142 { 153 std::auto_ptr<shutdown_handler<Stream, Handler> > this_ptr(this);154 143 handler_(error); 155 144 } 156 145 }; // class shutdown_handler … … 244 233 { 245 234 typedef handshake_handler<Stream, Handler> connect_handler; 246 235 247 connect_handler* local_handler =248 new connect_handler(handler, get_io_service()) ;236 boost::shared_ptr<connect_handler> local_handler( 237 new connect_handler(handler, get_io_service())); 249 238 250 openssl_operation<Stream>* op = new openssl_operation<Stream> 251 ( 252 type == stream_base::client ? 253 &ssl_wrap<mutex_type>::SSL_connect: 254 &ssl_wrap<mutex_type>::SSL_accept, 255 next_layer, 256 impl->recv_buf, 257 impl->ssl, 258 impl->ext_bio, 259 boost::bind 239 boost::shared_ptr<openssl_operation<Stream> > op( 240 new openssl_operation<Stream> 260 241 ( 261 &base_handler<Stream>::do_func, 262 local_handler, 263 boost::arg<1>(), 264 boost::arg<2>() 265 ), 266 strand_ 242 type == stream_base::client ? 243 &ssl_wrap<mutex_type>::SSL_connect: 244 &ssl_wrap<mutex_type>::SSL_accept, 245 next_layer, 246 impl->recv_buf, 247 impl->ssl, 248 impl->ext_bio, 249 boost::bind 250 ( 251 &base_handler<Stream>::do_func, 252 local_handler, 253 boost::arg<1>(), 254 boost::arg<2>() 255 ), 256 strand_ 257 ) 267 258 ); 268 local_handler->set_operation(op);269 259 270 260 strand_.post(boost::bind(&openssl_operation<Stream>::start, op)); 271 261 } … … 301 291 { 302 292 typedef shutdown_handler<Stream, Handler> disconnect_handler; 303 293 304 disconnect_handler* local_handler =305 new disconnect_handler(handler, get_io_service()) ;294 boost::shared_ptr<disconnect_handler> local_handler( 295 new disconnect_handler(handler, get_io_service())); 306 296 307 openssl_operation<Stream>* op = new openssl_operation<Stream> 308 ( 309 &ssl_wrap<mutex_type>::SSL_shutdown, 310 next_layer, 311 impl->recv_buf, 312 impl->ssl, 313 impl->ext_bio, 314 boost::bind 297 boost::shared_ptr<openssl_operation<Stream> > op( 298 new openssl_operation<Stream> 315 299 ( 316 &base_handler<Stream>::do_func, 317 local_handler, 318 boost::arg<1>(), 319 boost::arg<2>() 320 ), 321 strand_ 300 &ssl_wrap<mutex_type>::SSL_shutdown, 301 next_layer, 302 impl->recv_buf, 303 impl->ssl, 304 impl->ext_bio, 305 boost::bind 306 ( 307 &base_handler<Stream>::do_func, 308 local_handler, 309 boost::arg<1>(), 310 boost::arg<2>() 311 ), 312 strand_ 313 ) 322 314 ); 323 local_handler->set_operation(op);324 315 325 316 strand_.post(boost::bind(&openssl_operation<Stream>::start, op)); 326 317 } … … 367 358 { 368 359 typedef io_handler<Stream, Handler> send_handler; 369 360 370 send_handler* local_handler = new send_handler(handler, get_io_service()); 361 boost::shared_ptr<send_handler> local_handler( 362 new send_handler(handler, get_io_service())); 371 363 372 364 std::size_t buffer_size = boost::asio::buffer_size(*buffers.begin()); 373 365 if (buffer_size > max_buffer_size) … … 378 370 boost::asio::buffer_cast<const void*>(*buffers.begin()), 379 371 static_cast<int>(buffer_size)); 380 372 381 openssl_operation<Stream>* op = new openssl_operation<Stream> 382 ( 383 send_func, 384 next_layer, 385 impl->recv_buf, 386 impl->ssl, 387 impl->ext_bio, 388 boost::bind 373 boost::shared_ptr<openssl_operation<Stream> > op( 374 new openssl_operation<Stream> 389 375 ( 390 &base_handler<Stream>::do_func, 391 local_handler, 392 boost::arg<1>(), 393 boost::arg<2>() 394 ), 395 strand_ 376 send_func, 377 next_layer, 378 impl->recv_buf, 379 impl->ssl, 380 impl->ext_bio, 381 boost::bind 382 ( 383 &base_handler<Stream>::do_func, 384 local_handler, 385 boost::arg<1>(), 386 boost::arg<2>() 387 ), 388 strand_ 389 ) 396 390 ); 397 local_handler->set_operation(op);398 391 399 392 strand_.post(boost::bind(&openssl_operation<Stream>::start, op)); 400 393 } … … 441 434 { 442 435 typedef io_handler<Stream, Handler> recv_handler; 443 436 444 recv_handler* local_handler = new recv_handler(handler, get_io_service()); 437 boost::shared_ptr<recv_handler> local_handler( 438 new recv_handler(handler, get_io_service())); 445 439 446 440 std::size_t buffer_size = boost::asio::buffer_size(*buffers.begin()); 447 441 if (buffer_size > max_buffer_size) … … 452 446 boost::asio::buffer_cast<void*>(*buffers.begin()), 453 447 static_cast<int>(buffer_size)); 454 448 455 openssl_operation<Stream>* op = new openssl_operation<Stream> 456 ( 457 recv_func, 458 next_layer, 459 impl->recv_buf, 460 impl->ssl, 461 impl->ext_bio, 462 boost::bind 449 boost::shared_ptr<openssl_operation<Stream> > op( 450 new openssl_operation<Stream> 463 451 ( 464 &base_handler<Stream>::do_func, 465 local_handler, 466 boost::arg<1>(), 467 boost::arg<2>() 468 ), 469 strand_ 452 recv_func, 453 next_layer, 454 impl->recv_buf, 455 impl->ssl, 456 impl->ext_bio, 457 boost::bind 458 ( 459 &base_handler<Stream>::do_func, 460 local_handler, 461 boost::arg<1>(), 462 boost::arg<2>() 463 ), 464 strand_ 465 ) 470 466 ); 471 local_handler->set_operation(op);472 467 473 468 strand_.post(boost::bind(&openssl_operation<Stream>::start, op)); 474 469 } -
boost/asio/ssl/detail/openssl_operation.hpp
22 22 #include <boost/assert.hpp> 23 23 #include <boost/bind.hpp> 24 24 #include <boost/asio/detail/pop_options.hpp> 25 #include <boost/enable_shared_from_this.hpp> 25 26 26 27 #include <boost/asio/buffer.hpp> 27 28 #include <boost/asio/placeholders.hpp> … … 80 81 // 81 82 template <typename Stream> 82 83 class openssl_operation 84 : public boost::enable_shared_from_this<openssl_operation<Stream> > 83 85 { 84 86 public: 85 87 … … 321 323 boost::bind 322 324 ( 323 325 &openssl_operation::async_write_handler, 324 this,326 openssl_operation::shared_from_this(), 325 327 is_operation_done, 326 328 rc, 327 329 boost::asio::placeholders::error, … … 386 388 boost::bind 387 389 ( 388 390 &openssl_operation::async_read_handler, 389 this,391 openssl_operation::shared_from_this(), 390 392 boost::asio::placeholders::error, 391 393 boost::asio::placeholders::bytes_transferred 392 394 )