-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect errno #164
Comments
Forget about the previous comment. It's all wrong. An interrupted signal call gives a EINTR, not a EAGAIN. I undid the changes. So what is the problem exactly? Provide code that demonstrates. |
@pebbe Look at the definition of this function: It returns just the errno - but from the context of the library itself. In my case I have libzmq.dll built with MSVC, but I use gcc from MSYS2 for CGO. Therefore there may be the problem with proper propagation of the
by godoc So this The problem is - I understand that this problem is why The problem itselfI run I am sure that there is no message in queue - I should receive By debugging your code I can see that: So, |
And look at this quote from zmq.h:
|
I think I may have a fix. Can you try the latest version, please? |
The same situation happens when Binding to the same TCP port for the second time - it silently fails, but without an error. Therefore the process thinks that it can accept messages, while the underlying socket is dead. This occurs in Bind (zmq4.go963):
I have downloaded your latest version and it seems fixed - this case (binding) now correctly returns error (though I am not sure why is it error 100 -> Cannot create another system semaphore, but this must be libzmq thing). |
The problem
I issue non-blocking read on
DEALER
socket connected toROUTER
socket.data, err := client.RecvMessage(zmq.DONTWAIT)
ROUTER
takes at least 1 second to complete the task (due tosleep()
) and I do the read immediately.I expected to get
EAGAIN
error, but instead I goterr == nil
andlen(data) == 0
- proper empty read.Situation
By debugging the library it seems to me, that this call starts the error (RecvBytes, zmq4.go:1077):
size, err = C.zmq_msg_recv(&msg, soc.soc, C.int(flags))
Here,
size == -1
buterr == nil
.Therefore
errget(err)
withnil
returnsnil
instead of true error.Maybe
errget
should do something when it is call withnil
argument?I believe that the root cause of this particular problem is not using
zmq_errno
.In the documentation of that function it is said, that it should be used to properly get
errno
, when for example in a situation, where the application links to different C runtime, than the libzmq.This is probably my case, because this happens on Windows, I have libzmq.dll built with MSVC and then generated stub libzmq.a using gcc dlltools. So the setup is exotic (but hey, welcome to compiling C libs on Windows + Go + Cgo).
What's more, during
C.
calls in Go, it returns plainerrno
and it is essentialy wrong in this case.When I tried
e := C.zmq_errno()
just after the failed read - I get the correct EAGAIN (11) error.Solutions?
While I probably could check
C.zmq_errno()
after each call, but I am not sure if it is sufficient enough and will the errors be cleared after succesful calls?EDIT:
No, the error is not cleared. And since the returned err is nil, there is no way to now that
C.zmq_errno()
result is valid in this situation (+ all the threading issues possible).One solution may be to drop all err from
_, err := C. ...
and callC.zmq_errno()
instead? But it will require changes in many places.Maybe modifications to
errget
will be sufficient? For example if argumenterr
isnil
the check theC.zmq_errno()
?The text was updated successfully, but these errors were encountered: