nbrownus / mlogger

Log to syslog from the command line, just like `logger` but more massive
21 stars 3 forks source link

Allow sending large messages with unix sockets. #2

Closed agordon closed 10 years ago

nbrownus commented 10 years ago

Looks like this will impose the SO_SNDBUF limit on non DGRAM sockets, which should cover the current 64k limit that is there now but not beyond that (at least on my system).

agordon commented 10 years ago

Not sure I understood your message.

I see three code paths:

  1. using "syslog(1)": openlog() + syslog()
  2. using UDP socket: udpopenlog() + mysyslog()
  3. Using Unix socket: myopenlog() + mysyslog()

Case 1 is not modified by this patch.

Case 2 remains the same, the message limit is still 400 bytes,.

Case 3 is the modified one, "myopenlog" modifies the limit, and sets it to SO_SNDBUF. later, mysyslog() takes the minimum between MAX_LINE and SO_SNDBUF - so which ever is lower is the limit. In the current code (without this patch), case 3 is also limited to 400 bytes.

Do you see a problem with this on your system?

nbrownus commented 10 years ago

In case 3, if the socket is a stream, the max line length will be limited to the send buffer of that socket. This appears to needlessly trim the message since the send buffer could be less than the max line and the transport is reliable.

agordon commented 10 years ago

Ah, I see.

From a theoretical point-of-view, you are correct. I'll send a better patch.

From the real-code point-of-view, case 3 was always limited to 400 characters, so it didn't matter :)

nbrownus commented 10 years ago

Certainly agree this is better than it was before. Just wanted to make sure it wasn't limiting anything else :)

agordon commented 10 years ago

Here's a better version.