Skip to content

Commit

Permalink
Update AWS CRT to use the new libraries (#22)
Browse files Browse the repository at this point in the history
* Update AWS CRT to use the new libraries

* version bump

* wip

* wip
  • Loading branch information
Octogonapus authored May 10, 2024
1 parent 103cf41 commit 27b679a
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 375 deletions.
16 changes: 7 additions & 9 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
name = "AWSCRT"
uuid = "df31ea59-17a4-4ebd-9d69-4f45266dc2c7"
version = "0.2.0"
version = "0.3.0"

[deps]
AWSCRT_jll = "01db5350-6ea1-5d9a-9a47-8a31a394cb9c"
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
CountDownLatches = "621fb831-fdad-4fff-93ac-1af7b7ed19e3"
ForeignCallbacks = "809b5ff2-8730-47bb-8e19-67299d747c44"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LibAWSCRT = "df7458b6-5204-493f-a0e7-404b4eb72fac"
LibAwsCommon = "c6e421ba-b5f8-4792-a1c4-42948de3ed9d"
LibAwsIO = "a5388770-19df-4151-b103-3d71de896ddf"
LibAwsMqtt = "dbf63f58-971e-4a9b-b153-820e5f7f543b"

[compat]
AWSCRT_jll = "=0.1.2"
AWS = "1.78"
Aqua = "0.8.4"
CEnum = "0.4"
CountDownLatches = "2"
Dates = "1"
Documenter = "1"
ForeignCallbacks = "0.1.1"
JSON = "0.21"
LibAWSCRT = "=0.1.0"
LibAwsCommon = "1"
LibAwsIO = "1"
LibAwsMqtt = "1"
Random = "1"
Test = "1"
julia = "1.9"
Expand Down
8 changes: 4 additions & 4 deletions src/AWSCRT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Environment variables:
- `AWS_CRT_MEMORY_TRACING`: Set to `0`, `1`, or `2` to enable memory tracing. Default is off. See `aws_mem_trace_level`.
- `AWS_CRT_MEMORY_TRACING_FRAMES_PER_STACK`: Set the number of frames per stack for memory tracing. Default is the AWS library's default.
- `AWS_CRT_LOG_LEVEL`: Set to `0` through `6` to enable logging. Default is off. See [`aws_log_level`](https://octogonapus.github.io/LibAWSCRT.jl/dev/#LibAWSCRT.aws_log_level).
- `AWS_CRT_LOG_LEVEL`: Set to `0` through `6` to enable logging. Default is off. See [`aws_log_level`](https://juliaservices.github.io/LibAwsCommon.jl/dev/#LibAwsCommon.aws_log_level).
- `AWS_CRT_LOG_PATH`: Set to the log file path. Must be set if `AWS_CRT_LOG_LEVEL` is set.
Note: all the symbols in this package that begin with underscores are private and are not part of this package's published interface. Please don't use them.
"""
module AWSCRT

using LibAWSCRT, ForeignCallbacks, CountDownLatches, CEnum, JSON
using CountDownLatches, JSON, LibAwsCommon, LibAwsIO, LibAwsMqtt
import Base: lock, unlock
export lock, unlock

Expand All @@ -21,7 +21,7 @@ const _C_ON_ANY_MESSAGE_IDS_LOCK = ReentrantLock()
const _C_ON_ANY_MESSAGE_IDS = IdDict{Any,Any}()

# set during __init__
const _LIBPTR = Ref{Ptr{Cvoid}}(Ptr{Cvoid}(0))
const _LIB_COMMON_PTR = Ref{Ptr{Cvoid}}(Ptr{Cvoid}(0))
const _AWSCRT_ALLOCATOR = Ref{Union{Ptr{aws_allocator},Nothing}}(nothing)

# cfunctions set during __init__
Expand Down Expand Up @@ -104,7 +104,7 @@ export publish_current_state
export wait_until_synced

function __init__()
_LIBPTR[] = Libc.Libdl.dlopen(LibAWSCRT.libawscrt)
_LIB_COMMON_PTR[] = Libc.Libdl.dlopen(LibAwsCommon.libaws_c_common)

_C_ON_CONNECTION_INTERRUPTED[] =
@cfunction(_c_on_connection_interrupted, Cvoid, (Ptr{aws_mqtt_client_connection}, Cint, Ptr{Cvoid}))
Expand Down
33 changes: 16 additions & 17 deletions src/AWSIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,23 +303,22 @@ Arguments:
- `options (TLSContextOptions)`: Configuration options.
"""
function ClientTLSContext(options::TLSContextOptions)
tls_ctx_opt = Ref(aws_tls_ctx_options(ntuple(_ -> UInt8(0), 200)))
# tls_ctx_opt = Ref(
# aws_tls_ctx_options(
# C_NULL,
# options.min_tls_version,
# aws_tls_cipher_pref(0),
# aws_byte_buf(0, C_NULL, 0, C_NULL),
# C_NULL,
# C_NULL,
# aws_byte_buf(0, C_NULL, 0, C_NULL),
# aws_byte_buf(0, C_NULL, 0, C_NULL),
# 0,
# options.verify_peer,
# C_NULL,
# C_NULL,
# ),
# )
tls_ctx_opt = Ref(
aws_tls_ctx_options(
C_NULL,
options.min_tls_version,
aws_tls_cipher_pref(0),
aws_byte_buf(0, C_NULL, 0, C_NULL),
C_NULL,
C_NULL,
aws_byte_buf(0, C_NULL, 0, C_NULL),
aws_byte_buf(0, C_NULL, 0, C_NULL),
0,
options.verify_peer,
C_NULL,
C_NULL,
),
)
GC.@preserve tls_ctx_opt begin
# TODO pkcs11
# TODO pkcs12
Expand Down
4 changes: 2 additions & 2 deletions src/AWSMQTT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1138,8 +1138,8 @@ function resubscribe_existing_topics(connection::MQTTConnection)
out_ch = Channel(1)
ud = _OnResubcribeCompleteUD(
connection.events,
Libc.Libdl.dlsym(_LIBPTR[], :aws_array_list_length),
Libc.Libdl.dlsym(_LIBPTR[], :aws_array_list_get_at),
Libc.Libdl.dlsym(_LIB_COMMON_PTR[], :aws_array_list_length),
Libc.Libdl.dlsym(_LIB_COMMON_PTR[], :aws_array_list_get_at),
(msg) -> put!(out_ch, msg),
)
udp = Base.pointer_from_objref(ud)
Expand Down
Loading

2 comments on commit 27b679a

@Octogonapus
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/106558

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.0 -m "<description of version>" 27b679a0263ce952c929e73d0afe38900a99cf20
git push origin v0.3.0

Please sign in to comment.