[zeromq-dev] Assert if setsockopt wrong used

MinRK benjaminrk at gmail.com
Thu Mar 29 06:43:21 CEST 2012


On Wed, Mar 28, 2012 at 21:27, Pieter Hintjens <ph at imatix.com> wrote:

> Hi all,
>
> Problem: people using setsockopt wrongly get weird downstream
> behaviours that can take time to debug if they don't systematically
> check their return codes.
>
> Solution: libzmq should assert if passed an invalid getsockopt or
> setsockopt.
>
> Thoughts? Seems a valid use for assertions. I'll write this up as an
> issue there's consensus.
>

Holy crap, no.  returncodes are a perfectly fine API in C, and higher level
language bindings should wrap returncodes into native exceptions (as
appropriate).

The comment on-list you are referring to was a Python Exception (wrapping
zmq_errno/strerror) being raised, specifically as a result of checking
return codes.  So the change proposed here wouldn't help that case in the
slightest, other than providing a less informative and more distressing
failure, from which recovery is artificially prohibited.

I think the previously professed policy of all asserts hit indicating a bug
in libzmq itself is a good one, and much friendlier to languages that do
not expect libraries to murder the entire process in perfectly recoverable
situations.

Please do not do this,

-MinRK


>
> -Pieter
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120328/79eb5de9/attachment.htm>


More information about the zeromq-dev mailing list