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

JuliaLang / julia / #37997

29 Jan 2025 02:08AM UTC coverage: 17.283% (-68.7%) from 85.981%
#37997

push

local

web-flow
bpart: Start enforcing min_world for global variable definitions (#57150)

This is the analog of #57102 for global variables. Unlike for consants,
there is no automatic global backdate mechanism. The reasoning for this
is that global variables can be declared at any time, unlike constants
which can only be decalared once their value is available. As a result
code patterns using `Core.eval` to declare globals are rarer and likely
incorrect.

1 of 22 new or added lines in 3 files covered. (4.55%)

31430 existing lines in 188 files now uncovered.

7903 of 45728 relevant lines covered (17.28%)

98663.7 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
UNCOV
7
    function PipeServer(handle::Ptr{Cvoid}, status)
×
UNCOV
8
        p = new(handle,
×
9
                status,
10
                Base.ThreadSynchronizer())
UNCOV
11
        associate_julia_struct(p.handle, p)
×
UNCOV
12
        finalizer(uvfinalize, p)
×
UNCOV
13
        return p
×
14
    end
15
end
16

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

27
## server functions ##
28

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

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

UNCOV
50
function bind(server::PipeServer, name::AbstractString)
×
UNCOV
51
    iolock_begin()
×
UNCOV
52
    @assert server.status == StatusInit
×
UNCOV
53
    err = ccall(:uv_pipe_bind, Int32, (Ptr{Cvoid}, Cstring),
×
54
                server, name)
UNCOV
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
UNCOV
64
    server.status = StatusOpen
×
UNCOV
65
    iolock_end()
×
UNCOV
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
"""
UNCOV
77
function listen(path::AbstractString)
×
UNCOV
78
    sock = PipeServer()
×
UNCOV
79
    bind(sock, path) || throw(ArgumentError("could not listen on path $path"))
×
UNCOV
80
    return listen(sock)
×
81
end
82

UNCOV
83
function connect!(sock::PipeEndpoint, path::AbstractString)
×
UNCOV
84
    iolock_begin()
×
UNCOV
85
    @assert sock.status == StatusInit
×
UNCOV
86
    req = Libc.malloc(Base._sizeof_uv_connect)
×
UNCOV
87
    uv_req_set_data(req, C_NULL)
×
UNCOV
88
    ccall(:uv_pipe_connect, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), req, sock.handle, path,
×
UNCOV
89
          @cfunction(uv_connectcb, Cvoid, (Ptr{Cvoid}, Cint)))
×
UNCOV
90
    sock.status = StatusConnecting
×
UNCOV
91
    iolock_end()
×
UNCOV
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
"""
UNCOV
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

© 2026 Coveralls, Inc