• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37999

02 Feb 2025 07:22AM UTC coverage: 17.218% (-8.3%) from 25.515%
#37999

push

local

web-flow
bpart: Start tracking backedges for bindings (#57213)

This PR adds limited backedge support for Bindings. There are two
classes of bindings that get backedges:

1. Cross-module `GlobalRef` bindings (new in this PR)
2. Any globals accesses through intrinsics (i.e. those with forward
edges from #57009)

This is a time/space trade-off for invalidation. As a result of the
first category, invalidating a binding now only needs to scan all the
methods defined in the same module as the binding. At the same time, it
is anticipated that most binding references are to bindings in the same
module, keeping the list of bindings that need explicit (back)edges
small.

7 of 30 new or added lines in 3 files covered. (23.33%)

4235 existing lines in 124 files now uncovered.

7882 of 45779 relevant lines covered (17.22%)

98289.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/stdlib/Sockets/src/PipeServer.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
mutable struct PipeServer <: LibuvServer
4
    handle::Ptr{Cvoid}
5
    status::Int
6
    cond::Base.ThreadSynchronizer
7
    function PipeServer(handle::Ptr{Cvoid}, status)
×
8
        p = new(handle,
×
9
                status,
10
                Base.ThreadSynchronizer())
11
        associate_julia_struct(p.handle, p)
×
12
        finalizer(uvfinalize, p)
×
13
        return p
×
14
    end
15
end
16

17
function PipeServer()
×
18
    pipe = PipeServer(Libc.malloc(Base._sizeof_uv_named_pipe), StatusUninit)
×
19
    iolock_begin()
×
20
    err = ccall(:uv_pipe_init, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cint), eventloop(), pipe.handle, 0)
×
21
    uv_error("failed to create pipe server", err)
×
22
    pipe.status = StatusInit
×
23
    iolock_end()
×
24
    return pipe
×
25
end
26

27
## server functions ##
28

29
accept(server::PipeServer) = accept(server, PipeEndpoint())
×
30

UNCOV
31
function accept_nonblock(server::PipeServer, client::PipeEndpoint)
×
32
    iolock_begin()
×
33
    if client.status != StatusInit
×
34
        error("client is already in use or has been closed")
×
35
    end
36
    err = ccall(:uv_accept, Int32, (Ptr{Cvoid}, Ptr{Cvoid}), server.handle, client.handle)
×
37
    if err == 0
×
38
        client.status = StatusOpen
×
39
    end
40
    iolock_end()
×
41
    return err
×
42
end
43

44
function accept_nonblock(server::PipeServer)
×
45
    client = PipeEndpoint()
×
46
    uv_error("accept", accept_nonblock(server, client) != 0)
×
47
    return client
×
48
end
49

50
function bind(server::PipeServer, name::AbstractString)
×
51
    iolock_begin()
×
52
    @assert server.status == StatusInit
×
53
    err = ccall(:uv_pipe_bind, Int32, (Ptr{Cvoid}, Cstring),
×
54
                server, name)
55
    if err != 0
×
56
        iolock_end()
×
57
        if err != UV_EADDRINUSE && err != UV_EACCES
×
58
            #TODO: this codepath is currently not tested
59
            throw(_UVError("bind", err))
×
60
        else
61
            return false
×
62
        end
63
    end
64
    server.status = StatusOpen
×
65
    iolock_end()
×
66
    return true
×
67
end
68

69
"""
70
    listen(path::AbstractString) -> PipeServer
71

72
Create and listen on a named pipe / UNIX domain socket.
73

74
!!! note
75
    Path length on Unix is limited to somewhere between 92 and 108 bytes (cf. `man unix`).
76
"""
77
function listen(path::AbstractString)
×
78
    sock = PipeServer()
×
79
    bind(sock, path) || throw(ArgumentError("could not listen on path $path"))
×
80
    return listen(sock)
×
81
end
82

83
function connect!(sock::PipeEndpoint, path::AbstractString)
×
84
    iolock_begin()
×
85
    @assert sock.status == StatusInit
×
86
    req = Libc.malloc(Base._sizeof_uv_connect)
×
87
    uv_req_set_data(req, C_NULL)
×
88
    ccall(:uv_pipe_connect, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), req, sock.handle, path,
×
89
          @cfunction(uv_connectcb, Cvoid, (Ptr{Cvoid}, Cint)))
×
90
    sock.status = StatusConnecting
×
91
    iolock_end()
×
92
    return sock
×
93
end
94

95
"""
96
    connect(path::AbstractString) -> PipeEndpoint
97

98
Connect to the named pipe / UNIX domain socket at `path`.
99

100
!!! note
101
    Path length on Unix is limited to somewhere between 92 and 108 bytes (cf. `man unix`).
102
"""
103
connect(path::AbstractString) = connect(PipeEndpoint(), path)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc