Skip to content

Unix sockets are UDP-esque, not TCP. #6

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

Closed
wants to merge 10 commits into from

Conversation

robholland
Copy link
Contributor

No description provided.

Rob Holland added 2 commits January 9, 2014 10:35
syslog expects that it will receive one message per datagram, so we
can't send arbitrary amounts of data from a buffer as we do for TCP.

This change iterates over the log lines and sends each one on it's own.
@agentzh
Copy link
Contributor

agentzh commented Jan 9, 2014

@robholland There are two different types of unix domain sockets, stream type and datagram type. I think the existing stream typed unix domain sockets are important to retain. You're welcome, however, to submit a patch to add support for an additional option to control which type of unix domain socket to use.

@robholland
Copy link
Contributor Author

Ok, I'll change the code to be enabled by a datagram option, rather than presuming that to be the case based on the presence of path.

Rob Holland and others added 3 commits January 9, 2014 17:35
This allows people to still use SOCK_STREAM style unix sockets.

Please note I haven't tested SOCK_STREAM sockets, so that will work as
well as it did (or not) regardless of this patch :)
@calio
Copy link
Contributor

calio commented Jan 9, 2014

  1. The reason we have a separate send_buffer is that the current lua thread will be switched out when we call sock:send, and another lua thread may run and write something to the log buffer. If we use the same buffer for storing purpose and sending purpose, then if send operation succeeds and we clear the log buffer, some newly come log messages may also be cleared. I made send_buffer a lua table in https://github.com/cloudflare/lua-resty-logger-socket/tree/send_buffer_table, you can do something further on top of this.
  2. sock:setpeername also accept host and port as arguments, so I think you can add udp support for both regular socket and unix domain socket.

@robholland
Copy link
Contributor Author

Ok, I'll take a look at that branch, thanks. I'll also test plain UDP.

Rob Holland and others added 4 commits January 9, 2014 21:01
@robholland
Copy link
Contributor Author

This code currently reads ok to me, but testing in production it's behaving strangely in datagram mode, both connected to a unix domain socket and plain UDP. I'll do more testing tomorrow.

@flisky
Copy link

flisky commented Nov 3, 2016

The cosocket has already support udp unix socket. I think PR #20 fixed this.

@robholland robholland closed this Nov 23, 2017
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.

4 participants