[WIP] Adjust socket buffer sizes on FreeBSD
Needs ReviewPublic

Authored by adridg on Apr 15 2018, 7:21 PM.



The default socket buffer size on FreeBSD is 8192, while it is much
larger on Linux. It seems that the small socket buffer is what causes
the "world is going to end" problems with communicating over the local
sockets with Akonadi.

There are two approaches possible:

  • change the system default socket buffer size (there's a sysctl for it)
  • change the socket buffer size for Akonadi

This -- right now still kinda hacky and debuggerish -- patch changes the
socket size on connect and on creation, for Akonadi clients and the server.
It uses 64kibyte socket buffers.

Test Plan

With this patch, "akonadictl start" no longer complains about the world
ending. KMail can connect to the Akonadi server and read more than one
mailbox. Without the patch, changing the system default socket buffer
size does it, too.

Diff Detail

R165 Akonadi
No Linters Available
No Unit Test Coverage
adridg created this revision.Apr 15 2018, 7:21 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptApr 15 2018, 7:21 PM
Restricted Application added a subscriber: KDE PIM. · View Herald Transcript
adridg requested review of this revision.Apr 15 2018, 7:21 PM

Wouldn't it make sense to use a constant for 65536?

Interesting, thanks for debugging this Ade! I'm fine with merging this, but as @tcberner said, please use a named constant for the buffer size, instead of a magical numerical constant, move the adjustSocketBuffer() functions to src/private/datastream_p.cpp to avoid having two implementations of it (the library is shared by both the Akonadi Server and the client libraries), and drop some of the extra qDebugs().

Technically, Akonadi should be able to cope with messages larger than the buffer size but looks like there's a problem somewhere in the DataStream (or maybe Qt?). Knowing this is an issue, I should be able to investigate further (assuming I can get FreeBSD with Akonadi to run in a VM :-)) and make a proper fix in Akonadi someday.

The real insight is in https://bugs.kde.org/show_bug.cgi?id=381850 from Alexandre Martins. I'm mostly messing around trying to auto-set the socketbuffer size correctly.

If you use sysctl to up the buffer size, kmail seems to work just fine on FreeBSD. With this patch, I have been having weird issues -- possibly I'm not catching *all* of the creations of a socket, so this patch needs more debugging (and a constant, and a refactoring, etc.) anyway. "Weird issues" here means that sending mail hangs, for instance.