mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 13:33:09 +07:00
Increase inotify socket receive buffer size
At startup (and reconf) of systems with lots of services there is a risk of losing inotify events, e.g., PID file creation/delete events. This patch increase the receive buffer (doubles it). On Linux the getsockopt() for SO_RCVBUF returns double the set size, due to housekeeping in the kernel. So we don't have to do any adjustments when setting it. Issue #226 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "finit.h"
|
||||
#include "iwatch.h"
|
||||
@@ -39,6 +40,9 @@ static int initialized = 0;
|
||||
|
||||
int iwatch_init(struct iwatch *iw)
|
||||
{
|
||||
socklen_t len;
|
||||
int sz;
|
||||
|
||||
if (!iw) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
@@ -51,6 +55,16 @@ int iwatch_init(struct iwatch *iw)
|
||||
_pe("Failed creating inotify descriptor");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Double the size of the socket's receive buffer to address
|
||||
* issues with lost events in some cases, e.g. bootstrap and
|
||||
* reconf of systems with lots of services.
|
||||
*/
|
||||
len = sizeof(sz);
|
||||
if (!getsockopt(iw->fd, SOL_SOCKET, SO_RCVBUF, &sz, &len))
|
||||
setsockopt(iw->fd, SOL_SOCKET, SO_RCVBUF, &sz, sizeof(sz));
|
||||
|
||||
initialized = 1;
|
||||
|
||||
return iw->fd;
|
||||
|
||||
Reference in New Issue
Block a user