Coverage Report

Created: 2026-01-25 06:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libzmq/src/sub.cpp
Line
Count
Source
1
/* SPDX-License-Identifier: MPL-2.0 */
2
3
#include "precompiled.hpp"
4
#include "sub.hpp"
5
#include "msg.hpp"
6
7
zmq::sub_t::sub_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
8
0
    xsub_t (parent_, tid_, sid_)
9
0
{
10
0
    options.type = ZMQ_SUB;
11
12
    //  Switch filtering messages on (as opposed to XSUB which where the
13
    //  filtering is off).
14
0
    options.filter = true;
15
0
}
16
17
zmq::sub_t::~sub_t ()
18
0
{
19
0
}
20
21
int zmq::sub_t::xsetsockopt (int option_,
22
                             const void *optval_,
23
                             size_t optvallen_)
24
0
{
25
0
    if (option_ != ZMQ_SUBSCRIBE && option_ != ZMQ_UNSUBSCRIBE) {
26
0
        errno = EINVAL;
27
0
        return -1;
28
0
    }
29
30
    //  Create the subscription message.
31
0
    msg_t msg;
32
0
    int rc;
33
0
    const unsigned char *data = static_cast<const unsigned char *> (optval_);
34
0
    if (option_ == ZMQ_SUBSCRIBE) {
35
0
        rc = msg.init_subscribe (optvallen_, data);
36
0
    } else {
37
0
        rc = msg.init_cancel (optvallen_, data);
38
0
    }
39
0
    errno_assert (rc == 0);
40
41
    //  Pass it further on in the stack.
42
0
    rc = xsub_t::xsend (&msg);
43
0
    return close_and_return (&msg, rc);
44
0
}
45
46
int zmq::sub_t::xsend (msg_t *)
47
0
{
48
    //  Override the XSUB's send.
49
0
    errno = ENOTSUP;
50
0
    return -1;
51
0
}
52
53
bool zmq::sub_t::xhas_out ()
54
0
{
55
    //  Override the XSUB's send.
56
0
    return false;
57
0
}