summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-01-27 18:57:37 +0100
committerLennart Poettering <lennart@poettering.net>2012-01-27 18:57:37 +0100
commitbb99a35a873c35e80b0b47fe045081022660374d (patch)
tree63dc43ca84690ee6abff7548293c3619aef1587a /src/util.c
parent632117b71fdd2d1b9da7418d00ec21c18d60dedd (diff)
log: increase socket buffers for logging by default
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index c9ad831c6c..5fe22d2e50 100644
--- a/src/util.c
+++ b/src/util.c
@@ -6279,3 +6279,39 @@ void* memdup(const void *p, size_t l) {
memcpy(r, p, l);
return r;
}
+
+int fd_inc_sndbuf(int fd, size_t n) {
+ int r, value;
+ socklen_t l = sizeof(value);
+
+ r = getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &value, &l);
+ if (r >= 0 &&
+ l == sizeof(value) &&
+ (size_t) value >= n*2)
+ return 0;
+
+ value = (int) n;
+ r = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &value, sizeof(value));
+ if (r < 0)
+ return -errno;
+
+ return 1;
+}
+
+int fd_inc_rcvbuf(int fd, size_t n) {
+ int r, value;
+ socklen_t l = sizeof(value);
+
+ r = getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &value, &l);
+ if (r >= 0 &&
+ l == sizeof(value) &&
+ (size_t) value >= n*2)
+ return 0;
+
+ value = (int) n;
+ r = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &value, sizeof(value));
+ if (r < 0)
+ return -errno;
+
+ return 1;
+}