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

JuliaLang / julia / 1405

29 Aug 2025 03:48AM UTC coverage: 74.829% (-1.3%) from 76.086%
1405

push

buildkite

web-flow
make NEWS-update.jl more robust in trimming existing links (#59305)

The `NEWS-update.jl` script trims away any existing links from the end
of the `NEWS.md` file, so that it is safe to run multiple times. This PR
makes that trimming a bit more robust by trimming only `[#...]:`
patterns that start at the beginning of a line.

(I ran into this in re-using the same script for another project.)

63849 of 85327 relevant lines covered (74.83%)

21422751.51 hits per line

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

83.87
/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,
2✔
9
                status,
10
                Base.ThreadSynchronizer())
11
        associate_julia_struct(p.handle, p)
2✔
12
        finalizer(uvfinalize, p)
2✔
13
        return p
2✔
14
    end
15
end
16

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

27
function PipeServer(handle::OS_HANDLE)
2✔
28
    pipe = PipeServer()
2✔
29
    return Base.open_pipe!(pipe, handle)
2✔
30
end
31

32
function Base.open_pipe!(p::PipeServer, handle::OS_HANDLE)
33
    iolock_begin()
2✔
34
    if p.status != StatusInit
2✔
35
        error("pipe is already in use or has been closed")
×
36
    end
37
    err = ccall(:uv_pipe_open, Int32, (Ptr{Cvoid}, OS_HANDLE), p.handle, handle)
2✔
38
    uv_error("pipe_open", err)
2✔
39
    p.status = StatusOpen
2✔
40
    iolock_end()
2✔
41
    return p
2✔
42
end
43

44
## server functions ##
45

46
accept(server::PipeServer) = accept(server, PipeEndpoint())
1,894✔
47

48
function accept_nonblock(server::PipeServer, client::PipeEndpoint)
49
    iolock_begin()
4✔
50
    if client.status != StatusInit
4✔
51
        error("client is already in use or has been closed")
×
52
    end
53
    err = ccall(:uv_accept, Int32, (Ptr{Cvoid}, Ptr{Cvoid}), server.handle, client.handle)
4✔
54
    if err == 0
4✔
55
        client.status = StatusOpen
2✔
56
    end
57
    iolock_end()
4✔
58
    return err
4✔
59
end
60

61
function accept_nonblock(server::PipeServer)
×
62
    client = PipeEndpoint()
×
63
    uv_error("accept", accept_nonblock(server, client) != 0)
×
64
    return client
×
65
end
66

67
function bind(server::PipeServer, name::AbstractString)
1,885✔
68
    iolock_begin()
1,885✔
69
    @assert server.status == StatusInit
1,885✔
70
    err = ccall(:uv_pipe_bind, Int32, (Ptr{Cvoid}, Cstring),
1,885✔
71
                server, name)
72
    if err != 0
1,885✔
73
        iolock_end()
×
74
        if err != UV_EADDRINUSE && err != UV_EACCES
×
75
            #TODO: this codepath is currently not tested
76
            throw(_UVError("bind", err))
×
77
        else
78
            return false
×
79
        end
80
    end
81
    server.status = StatusOpen
1,885✔
82
    iolock_end()
1,885✔
83
    return true
1,885✔
84
end
85

86
"""
87
    listen(path::AbstractString) -> PipeServer
88

89
Create and listen on a named pipe / UNIX domain socket.
90

91
!!! note
92
    Path length on Unix is limited to somewhere between 92 and 108 bytes (cf. `man unix`).
93
"""
94
function listen(path::AbstractString)
1,883✔
95
    sock = PipeServer()
1,883✔
96
    bind(sock, path) || throw(ArgumentError("could not listen on path $path"))
1,883✔
97
    return listen(sock)
1,883✔
98
end
99

100
function connect!(sock::PipeEndpoint, path::AbstractString)
2,038✔
101
    iolock_begin()
2,038✔
102
    @assert sock.status == StatusInit
2,038✔
103
    req = Libc.malloc(Base._sizeof_uv_connect)
2,038✔
104
    uv_req_set_data(req, C_NULL)
2,038✔
105
    ccall(:uv_pipe_connect, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), req, sock.handle, path,
2,038✔
106
          @cfunction(uv_connectcb_pipe, Cvoid, (Ptr{Cvoid}, Cint)))
107
    sock.status = StatusConnecting
2,038✔
108
    iolock_end()
2,038✔
109
    return sock
2,038✔
110
end
111

112
"""
113
    connect(path::AbstractString) -> PipeEndpoint
114

115
Connect to the named pipe / UNIX domain socket at `path`.
116

117
!!! note
118
    Path length on Unix is limited to somewhere between 92 and 108 bytes (cf. `man unix`).
119
"""
120
connect(path::AbstractString) = connect(PipeEndpoint(), path)
2,038✔
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