Skip to content

Commit

Permalink
change Base.nb_available -> Base.bytesavailable. Fix #122 (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
samoconnor authored and quinnj committed Mar 8, 2018
1 parent e6b366c commit 21210b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
julia 0.6
BinaryProvider
Compat 0.48.0
Compat 0.52.0
16 changes: 11 additions & 5 deletions src/ssl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ end

function f_recv(c_ctx, c_msg, sz)
jl_ctx = unsafe_pointer_to_objref(c_ctx)
n = nb_available(jl_ctx)
n = bytesavailable(jl_ctx)
if n == 0
return Cint(MBEDTLS_ERR_SSL_WANT_READ)
end
Expand Down Expand Up @@ -246,11 +246,11 @@ function Base.readbytes!(ctx::SSLContext, buf::Vector{UInt8}, nbytes::UInt)
return Int(nr::UInt)
end

Base.readavailable(ctx::SSLContext) = read(ctx, nb_available(ctx))
Base.readavailable(ctx::SSLContext) = read(ctx, bytesavailable(ctx))

function Base.eof(ctx::SSLContext)
nb_available(ctx)>0 && return false
return eof(ctx.bio) && nb_available(ctx) == 0
bytesavailable(ctx)>0 && return false
return eof(ctx.bio) && bytesavailable(ctx) == 0
end

function Base.close(ctx::SSLContext)
Expand Down Expand Up @@ -291,7 +291,13 @@ function get_ciphersuite(ctx::SSLContext)
return unsafe_string(data)
end

function Base.nb_available(ctx::SSLContext)
@static if isdefined(Base, :bytesavailable)
Base.bytesavailable(ctx::SSLContext) = _bytesavailable(ctx)
else
Base.nb_available(ctx::SSLContext) = _bytesavailable(ctx)
end

function _bytesavailable(ctx::SSLContext)

@lockdata ctx begin

Expand Down

0 comments on commit 21210b7

Please sign in to comment.