Skip to content

Commit c0aa435

Browse files
committed
The ssl::context is now owned by the connection.
1 parent 6f9fd5b commit c0aa435

29 files changed

+75
-108
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ include_directories(include)
6161
add_library(test_common STATIC
6262
tests/common.cpp
6363
)
64+
target_link_libraries(test_common PUBLIC OpenSSL::Crypto OpenSSL::SSL)
6465
target_compile_features(test_common PUBLIC cxx_std_17)
6566
if (MSVC)
6667
target_compile_options(test_common PRIVATE /bigobj)

examples/cpp17_intro.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ auto main(int argc, char * argv[]) -> int
3232
response<std::string> resp;
3333

3434
net::io_context ioc;
35-
net::ssl::context ctx{net::ssl::context::tls_client};
36-
connection conn{ioc, ctx};
35+
connection conn{ioc};
3736

3837
conn.async_run(cfg, {}, net::detached);
3938

examples/cpp17_intro_sync.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ auto main(int argc, char * argv[]) -> int
2828
cfg.addr.port = argv[2];
2929
}
3030

31-
net::ssl::context ctx{net::ssl::context::tls_client};
32-
sync_connection conn{ctx};
31+
sync_connection conn;
3332
conn.run(cfg);
3433

3534
request req;

examples/cpp20_chat_room.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,12 @@ auto publisher(std::shared_ptr<stream_descriptor> in, std::shared_ptr<connection
7575
auto co_main(config cfg) -> net::awaitable<void>
7676
{
7777
auto ex = co_await net::this_coro::executor;
78-
auto ctx = std::make_shared<net::ssl::context>(net::ssl::context::tls_client);
79-
auto conn = std::make_shared<connection>(ex, *ctx);
78+
auto conn = std::make_shared<connection>(ex);
8079
auto stream = std::make_shared<stream_descriptor>(ex, ::dup(STDIN_FILENO));
8180

8281
net::co_spawn(ex, receiver(conn), net::detached);
8382
net::co_spawn(ex, publisher(stream, conn), net::detached);
84-
conn->async_run(cfg, {}, net::consign(net::detached, conn, ctx));
83+
conn->async_run(cfg, {}, net::consign(net::detached, conn));
8584

8685
signal_set sig_set{ex, SIGINT, SIGTERM};
8786
co_await sig_set.async_wait();

examples/cpp20_containers.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ auto transaction(std::shared_ptr<connection> conn) -> net::awaitable<void>
9191
// Called from the main function (see main.cpp)
9292
net::awaitable<void> co_main(config cfg)
9393
{
94-
auto ctx = std::make_shared<net::ssl::context>(net::ssl::context::tls_client);
95-
auto conn = std::make_shared<connection>(co_await net::this_coro::executor, *ctx);
96-
conn->async_run(cfg, {}, net::consign(net::detached, conn, ctx));
94+
auto conn = std::make_shared<connection>(co_await net::this_coro::executor);
95+
conn->async_run(cfg, {}, net::consign(net::detached, conn));
9796

9897
co_await store(conn);
9998
co_await transaction(conn);

examples/cpp20_echo_server.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ auto listener(std::shared_ptr<connection> conn) -> net::awaitable<void>
5858
auto co_main(config cfg) -> net::awaitable<void>
5959
{
6060
auto ex = co_await net::this_coro::executor;
61-
auto ctx = std::make_shared<net::ssl::context>(net::ssl::context::tls_client);
62-
auto conn = std::make_shared<connection>(ex, *ctx);
61+
auto conn = std::make_shared<connection>(ex);
6362
net::co_spawn(ex, listener(conn), net::detached);
64-
conn->async_run(cfg, {}, net::consign(net::detached, conn, ctx));
63+
conn->async_run(cfg, {}, net::consign(net::detached, conn));
6564

6665
signal_set sig_set(ex, SIGINT, SIGTERM);
6766
co_await sig_set.async_wait();

examples/cpp20_intro.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ using connection = net::deferred_t::as_default_on_t<boost::redis::connection>;
2323
// Called from the main function (see main.cpp)
2424
auto co_main(config cfg) -> net::awaitable<void>
2525
{
26-
auto ctx = std::make_shared<net::ssl::context>(net::ssl::context::tls_client);
27-
auto conn = std::make_shared<connection>(co_await net::this_coro::executor, *ctx);
28-
conn->async_run(cfg, {}, net::consign(net::detached, conn, ctx));
26+
auto conn = std::make_shared<connection>(co_await net::this_coro::executor);
27+
conn->async_run(cfg, {}, net::consign(net::detached, conn));
2928

3029
// A request containing only a ping command.
3130
request req;

examples/cpp20_intro_tls.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ auto co_main(config cfg) -> net::awaitable<void>
3434
cfg.addr.host = "db.occase.de";
3535
cfg.addr.port = "6380";
3636

37-
auto ctx = std::make_shared<net::ssl::context>(net::ssl::context::tls_client);
38-
auto conn = std::make_shared<connection>(co_await net::this_coro::executor, *ctx);
39-
conn->async_run(cfg, {}, net::consign(net::detached, conn, ctx));
37+
auto conn = std::make_shared<connection>(co_await net::this_coro::executor);
38+
conn->async_run(cfg, {}, net::consign(net::detached, conn));
4039

4140
request req;
4241
req.push("PING");

examples/cpp20_json.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ void boost_redis_from_bulk(user& u, std::string_view sv, boost::system::error_co
4848
auto co_main(config cfg) -> net::awaitable<void>
4949
{
5050
auto ex = co_await net::this_coro::executor;
51-
auto ctx = std::make_shared<net::ssl::context>(net::ssl::context::tls_client);
52-
auto conn = std::make_shared<connection>(ex, *ctx);
53-
conn->async_run(cfg, {}, net::consign(net::detached, conn, ctx));
51+
auto conn = std::make_shared<connection>(ex);
52+
conn->async_run(cfg, {}, net::consign(net::detached, conn));
5453

5554
// user object that will be stored in Redis in json format.
5655
user const u{"Joao", "58", "Brazil"};

examples/cpp20_protobuf.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ using tutorial::boost_redis_from_bulk;
4747
net::awaitable<void> co_main(config cfg)
4848
{
4949
auto ex = co_await net::this_coro::executor;
50-
auto ctx = std::make_shared<net::ssl::context>(net::ssl::context::tls_client);
51-
auto conn = std::make_shared<connection>(ex, *ctx);
52-
conn->async_run(cfg, {}, net::consign(net::detached, conn, ctx));
50+
auto conn = std::make_shared<connection>(ex);
51+
conn->async_run(cfg, {}, net::consign(net::detached, conn));
5352

5453
person p;
5554
p.set_name("Louis");

0 commit comments

Comments
 (0)