mirror of
https://github.com/troglobit/finit.git
synced 2026-11-03 13:28:27 +00: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:
1 parent
4811f76294
commit
bda3cdd3ad
1 file changed
+14
@@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include "finit.h"
|
#include "finit.h"
|
||||||
#include "iwatch.h"
|
#include "iwatch.h"
|
||||||
@@ -39,6 +40,9 @@ static int initialized = 0;
|
|||||||
|
|
||||||
int iwatch_init(struct iwatch *iw)
|
int iwatch_init(struct iwatch *iw)
|
||||||
{
|
{
|
||||||
|
socklen_t len;
|
||||||
|
int sz;
|
||||||
|
|
||||||
if (!iw) {
|
if (!iw) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -51,6 +55,16 @@ int iwatch_init(struct iwatch *iw)
|
|||||||
_pe("Failed creating inotify descriptor");
|
_pe("Failed creating inotify descriptor");
|
||||||
return -1;
|
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;
|
initialized = 1;
|
||||||
|
|
||||||
return iw->fd;
|
return iw->fd;
|
||||||
|
|||||||
Reference in new issue
Block a user