Coverage Report

Created: 2025-08-29 06:11

/src/libzmq/src/peer.cpp
Line
Count
Source (jump to first uncovered line)
1
/* SPDX-License-Identifier: MPL-2.0 */
2
3
#include "precompiled.hpp"
4
#include "macros.hpp"
5
#include "peer.hpp"
6
#include "pipe.hpp"
7
#include "wire.hpp"
8
#include "random.hpp"
9
#include "likely.hpp"
10
#include "err.hpp"
11
12
zmq::peer_t::peer_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
13
0
    server_t (parent_, tid_, sid_)
14
0
{
15
0
    options.type = ZMQ_PEER;
16
0
    options.can_send_hello_msg = true;
17
0
    options.can_recv_disconnect_msg = true;
18
0
    options.can_recv_hiccup_msg = true;
19
0
}
20
21
uint32_t zmq::peer_t::connect_peer (const char *endpoint_uri_)
22
0
{
23
0
    scoped_optional_lock_t sync_lock (&_sync);
24
25
    // connect_peer cannot work with immediate enabled
26
0
    if (options.immediate == 1) {
27
0
        errno = EFAULT;
28
0
        return 0;
29
0
    }
30
31
0
    int rc = socket_base_t::connect_internal (endpoint_uri_);
32
0
    if (rc != 0)
33
0
        return 0;
34
35
0
    return _peer_last_routing_id;
36
0
}
37
38
void zmq::peer_t::xattach_pipe (pipe_t *pipe_,
39
                                bool subscribe_to_all_,
40
                                bool locally_initiated_)
41
0
{
42
0
    server_t::xattach_pipe (pipe_, subscribe_to_all_, locally_initiated_);
43
0
    _peer_last_routing_id = pipe_->get_server_socket_routing_id ();
44
0
}