Ejemplo n.º 1
0
int zmq::socket_base_t::setsockopt (int option_, const void *optval_,
    size_t optvallen_)
{
    ENTER_MUTEX();

    if (!options.is_valid(option_)) {
        errno = EINVAL;
        EXIT_MUTEX();
        return -1;
    }

    if (unlikely (ctx_terminated)) {
        errno = ETERM;
        EXIT_MUTEX();
        return -1;
    }

    //  First, check whether specific socket type overloads the option.
    int rc = xsetsockopt (option_, optval_, optvallen_);
    if (rc == 0 || errno != EINVAL) {
        EXIT_MUTEX();
        return rc;
    }

    //  If the socket type doesn't support the option, pass it to
    //  the generic option parser.
    rc = options.setsockopt (option_, optval_, optvallen_);
    update_pipe_options(option_);

    EXIT_MUTEX();
    return rc;
}
int zmq::socket_base_t::setsockopt (int option_, const void *optval_,
                                    size_t optvallen_)
{
    if (unlikely (ctx_terminated)) {
        errno = ETERM;
        return -1;
    }

    //  First, check whether specific socket type overloads the option.
    int rc = xsetsockopt (option_, optval_, optvallen_);
    if (rc == 0 || errno != EINVAL)
        return rc;

    //  If the socket type doesn't support the option, pass it to
    //  the generic option parser.
    return options.setsockopt (option_, optval_, optvallen_);
}