Skip to content
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

Server helper: Suppress error of UDPServer over max_bytes on Windows #4131

Merged

Conversation

daipom
Copy link
Contributor

@daipom daipom commented Apr 7, 2023

Which issue(s) this PR fixes:
None.
This fixes the problem revealed in the following PR.

What this PR does / why we need it:
This PR just suppresses error message of UDPServer over max_bytes on Windows.

Suppressed error message on Windows:
(Please see #4117 (comment) for details)

unexpected error in processing UDP data error_class=Errno::EMSGSIZE error="A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself. - recvfrom(2)"

New info message on Windows:

A received data was ignored since it was too large.

On Windows, UDPSocket::recv and UDPSocket::recvfrom can raise Errno::EMSGSIZE error when the receiving data size is larger than the maxlen, the value specified as the method's argument.
(On non-Windows, this error doesn't happen, and we can receive data that is cut off to the specified size.)

On Windows, we can't cut data off the same way as Non-Windows.
So the data is simply ignored on Windows.
It is not a big problem since cutting data off usually causes a failure of parsing and the data is eventually ignored.

We want information about what data is ignored, but it is difficult to know it.
That is an issue for the future.

Ref

Docs Changes:
TODO. We should add a document about this Windows specification.

Release Note:
Same as the title.

@daipom daipom force-pushed the fix-udp-server-error-over-max_bytes-on-windows branch 2 times, most recently from 93dbdcd to 8aed97a Compare April 7, 2023 14:28
This fix just suppresses the error message and output a info level log.

On Windows, `UDPSocket::recv` and `UDPSocket::recvfrom` can
raise `Errno::EMSGSIZE` error when the receiving data size is
larger than the `maxlen`, the value specified as the method's
argument.
(On non-Windows, this error doesn't happen, and we can receive data
that is cut off to the specified size.)

We need to consider this case since this causes an unexpected
error message as follows.

     unexpected error in processing UDP data
     error_class=Errno::EMSGSIZE
     error="A message sent on a datagram socket was larger than
     the internal message buffer or some other network limit,
     or the buffer used to receive a datagram into was smaller
     than the datagram itself. - recvfrom(2)"

On Windows, we can't cut data off the same way as Non-Windows.
So, the data is simply ignored on Windows.
It is not a big problem since cutting data off usually causes a
failure of parsing and the data is eventually ignored.

We want information about what data is ignored, but it is
difficult to know it. That is an issue for the future.

Ref: `winsock` specification

* https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recvfrom
* https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2

Ref: Ruby implementation

* https://github.com/ruby/ruby/blob/e51014f9c05aa65cbf203442d37fef7c12390015/win32/win32.c#L3540-L3589
* https://github.com/ruby/ruby/blob/e51014f9c05aa65cbf203442d37fef7c12390015/win32/win32.c#L3730-L3782

Signed-off-by: Daijiro Fukuda <[email protected]>
@daipom daipom force-pushed the fix-udp-server-error-over-max_bytes-on-windows branch from 8aed97a to 1bd8b00 Compare April 10, 2023 09:22
Copy link
Member

@ashie ashie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting CI...

@ashie ashie merged commit 9170cda into fluent:master Apr 10, 2023
@ashie
Copy link
Member

ashie commented Apr 10, 2023

Thanks!

@daipom daipom deleted the fix-udp-server-error-over-max_bytes-on-windows branch April 10, 2023 12:14
@daipom
Copy link
Contributor Author

daipom commented Apr 10, 2023

Thanks for your review!

@ashie ashie added this to the v1.16.1 milestone Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants