Ticket #3958: asio_ssl_strand.patch

File asio_ssl_strand.patch, 2.8 KB (added by tianhao.qiu@…, 12 years ago)

http://permalink.gmane.org/gmane.comp.lib.boost.asio.user/4099

  • boost/asio/ssl/detail/openssl_stream_service.hpp

     
    161161    ::SSL* ssl;
    162162    ::BIO* ext_bio;
    163163    net_buffer recv_buf;
     164    boost::asio::io_service::strand* strand;
    164165  } * impl_type;
    165166
    166167  // Construct a new stream socket service for the specified io_service.
    167168  explicit openssl_stream_service(boost::asio::io_service& io_service)
    168     : boost::asio::detail::service_base<openssl_stream_service>(io_service),
    169       strand_(io_service)
     169    : boost::asio::detail::service_base<openssl_stream_service>(io_service)
    170170  {
    171171  }
    172172
     
    194194    impl->ext_bio = 0;
    195195    ::BIO_new_bio_pair(&int_bio, 8192, &impl->ext_bio, 8192);
    196196    ::SSL_set_bio(impl->ssl, int_bio, int_bio);
     197    impl->strand = new boost::asio::io_service::strand(get_io_service());
    197198  }
    198199
    199200  // Destroy a stream implementation.
     
    204205    {
    205206      ::BIO_free(impl->ext_bio);
    206207      ::SSL_free(impl->ssl);
     208      delete impl->strand;
    207209      delete impl;
    208210      impl = 0;
    209211    }
     
    262264        boost::arg<1>(),
    263265        boost::arg<2>()
    264266      ),
    265       strand_
     267      *(impl->strand)
    266268    );
    267269    local_handler->set_operation(op);
    268270
    269     strand_.post(boost::bind(&openssl_operation<Stream>::start, op));
     271    impl->strand->post(boost::bind(&openssl_operation<Stream>::start, op));
    270272  }
    271273
    272274  // Shut down SSL on the stream.
     
    317319        boost::arg<1>(),
    318320        boost::arg<2>()
    319321      ),
    320       strand_
     322      *(impl->strand)
    321323    );
    322324    local_handler->set_operation(op);
    323325
    324     strand_.post(boost::bind(&openssl_operation<Stream>::start, op));       
     326    impl->strand->post(boost::bind(&openssl_operation<Stream>::start, op));       
    325327  }
    326328
    327329  // Write some data to the stream.
     
    410412        boost::arg<1>(),
    411413        boost::arg<2>()
    412414      ),
    413       strand_
     415      *(impl->strand)
    414416    );
    415417    local_handler->set_operation(op);
    416418
    417     strand_.post(boost::bind(&openssl_operation<Stream>::start, op));       
     419    impl->strand->post(boost::bind(&openssl_operation<Stream>::start, op));       
    418420  }
    419421
    420422  // Read some data from the stream.
     
    503505        boost::arg<1>(),
    504506        boost::arg<2>()
    505507      ),
    506       strand_
     508      *(impl->strand)
    507509    );
    508510    local_handler->set_operation(op);
    509511
    510     strand_.post(boost::bind(&openssl_operation<Stream>::start, op));       
     512    impl->strand->post(boost::bind(&openssl_operation<Stream>::start, op));       
    511513  }
    512514
    513515  // Peek at the incoming data on the stream.
     
    529531  }
    530532
    531533private: 
    532   boost::asio::io_service::strand strand_;
    533 
    534534  typedef boost::asio::detail::mutex mutex_type;
    535535 
    536536  template<typename Mutex>