Skip to content

Commit c141df7

Browse files
committed
Make SSL support work when the Boost.DateTime library is disabled.
1 parent 77e27ea commit c141df7

File tree

2 files changed

+46
-10
lines changed

2 files changed

+46
-10
lines changed

asio/include/asio/ssl/detail/io.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ class io_op
148148
// cannot allow more than one read operation at a time on the
149149
// underlying transport. The pending_read_ timer's expiry is set to
150150
// pos_infin if a read is in progress, and neg_infin otherwise.
151-
if (core_.pending_read_.expires_at() == boost::posix_time::neg_infin)
151+
if (core_.pending_read_.expires_at() == core_.neg_infin())
152152
{
153153
// Prevent other read operations from being started.
154-
core_.pending_read_.expires_at(boost::posix_time::pos_infin);
154+
core_.pending_read_.expires_at(core_.pos_infin());
155155

156156
// Start reading some data from the underlying transport.
157157
next_layer_.async_read_some(
@@ -175,10 +175,10 @@ class io_op
175175
// cannot allow more than one write operation at a time on the
176176
// underlying transport. The pending_write_ timer's expiry is set to
177177
// pos_infin if a write is in progress, and neg_infin otherwise.
178-
if (core_.pending_write_.expires_at() == boost::posix_time::neg_infin)
178+
if (core_.pending_write_.expires_at() == core_.neg_infin())
179179
{
180180
// Prevent other write operations from being started.
181-
core_.pending_write_.expires_at(boost::posix_time::pos_infin);
181+
core_.pending_write_.expires_at(core_.pos_infin());
182182

183183
// Start writing all the data to the underlying transport.
184184
asio::async_write(next_layer_,
@@ -233,23 +233,23 @@ class io_op
233233
core_.input_ = core_.engine_.put_input(core_.input_);
234234

235235
// Release any waiting read operations.
236-
core_.pending_read_.expires_at(boost::posix_time::neg_infin);
236+
core_.pending_read_.expires_at(core_.neg_infin());
237237

238238
// Try the operation again.
239239
continue;
240240

241241
case engine::want_output_and_retry:
242242

243243
// Release any waiting write operations.
244-
core_.pending_write_.expires_at(boost::posix_time::neg_infin);
244+
core_.pending_write_.expires_at(core_.neg_infin());
245245

246246
// Try the operation again.
247247
continue;
248248

249249
case engine::want_output:
250250

251251
// Release any waiting write operations.
252-
core_.pending_write_.expires_at(boost::posix_time::neg_infin);
252+
core_.pending_write_.expires_at(core_.neg_infin());
253253

254254
// Fall through to call handler.
255255

asio/include/asio/ssl/detail/stream_core.hpp

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
#include "asio/detail/config.hpp"
1919

2020
#if !defined(ASIO_ENABLE_OLD_SSL)
21-
# include "asio/deadline_timer.hpp"
21+
# if defined(ASIO_HAS_BOOST_DATE_TIME)
22+
# include "asio/deadline_timer.hpp"
23+
# else // defined(ASIO_HAS_BOOST_DATE_TIME)
24+
# include "asio/steady_timer.hpp"
25+
# endif // defined(ASIO_HAS_BOOST_DATE_TIME)
2226
# include "asio/ssl/detail/engine.hpp"
2327
# include "asio/buffer.hpp"
2428
#endif // !defined(ASIO_ENABLE_OLD_SSL)
@@ -46,8 +50,8 @@ struct stream_core
4650
input_buffer_space_(max_tls_record_size),
4751
input_buffer_(asio::buffer(input_buffer_space_))
4852
{
49-
pending_read_.expires_at(boost::posix_time::neg_infin);
50-
pending_write_.expires_at(boost::posix_time::neg_infin);
53+
pending_read_.expires_at(neg_infin());
54+
pending_write_.expires_at(neg_infin());
5155
}
5256

5357
~stream_core()
@@ -57,12 +61,44 @@ struct stream_core
5761
// The SSL engine.
5862
engine engine_;
5963

64+
#if defined(ASIO_HAS_BOOST_DATE_TIME)
6065
// Timer used for storing queued read operations.
6166
asio::deadline_timer pending_read_;
6267

6368
// Timer used for storing queued write operations.
6469
asio::deadline_timer pending_write_;
6570

71+
// Helper function for obtaining a time value that always fires.
72+
static asio::deadline_timer::time_type neg_infin()
73+
{
74+
return boost::posix_time::neg_infin;
75+
}
76+
77+
// Helper function for obtaining a time value that never fires.
78+
static asio::deadline_timer::time_type pos_infin()
79+
{
80+
return boost::posix_time::pos_infin;
81+
}
82+
#else // defined(ASIO_HAS_BOOST_DATE_TIME)
83+
// Timer used for storing queued read operations.
84+
asio::steady_timer pending_read_;
85+
86+
// Timer used for storing queued write operations.
87+
asio::steady_timer pending_write_;
88+
89+
// Helper function for obtaining a time value that always fires.
90+
static asio::steady_timer::time_point neg_infin()
91+
{
92+
return asio::steady_timer::time_point::min();
93+
}
94+
95+
// Helper function for obtaining a time value that never fires.
96+
static asio::steady_timer::time_point pos_infin()
97+
{
98+
return asio::steady_timer::time_point::max();
99+
}
100+
#endif // defined(ASIO_HAS_BOOST_DATE_TIME)
101+
66102
// Buffer space used to prepare output intended for the transport.
67103
std::vector<unsigned char> output_buffer_space_;
68104

0 commit comments

Comments
 (0)