mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Merge commit 'acbdc29d' into thread-merge-2.16
This commit is contained in:
commit
b4bd406795
@ -68,9 +68,9 @@ tm_dump(resource *r, unsigned indent UNUSED)
|
||||
if (t->randomize)
|
||||
debug("rand %d, ", t->randomize);
|
||||
if (t->recurrent)
|
||||
debug("recur %d, ", t->recurrent);
|
||||
debug("recur %ld, ", t->recurrent);
|
||||
if (t->expires)
|
||||
debug("in loop %p expires in %d ms)\n", t->loop, (t->expires - current_time()) TO_MS);
|
||||
debug("in loop %p expires in %ld ms)\n", t->loop, (t->expires - current_time()) TO_MS);
|
||||
else
|
||||
debug("inactive)\n");
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ typedef struct timer
|
||||
void *data;
|
||||
|
||||
btime expires; /* 0=inactive */
|
||||
btime recurrent; /* Timer recurrence */
|
||||
uint randomize; /* Amount of randomization */
|
||||
uint recurrent; /* Timer recurrence */
|
||||
|
||||
struct timeloop *loop; /* Loop where the timer is active */
|
||||
|
||||
@ -84,7 +84,7 @@ tm_remains(timer *t)
|
||||
}
|
||||
|
||||
static inline timer *
|
||||
tm_new_init(pool *p, void (*hook)(struct timer *), void *data, uint rec, uint rand)
|
||||
tm_new_init(pool *p, void (*hook)(struct timer *), void *data, btime rec, uint rand)
|
||||
{
|
||||
timer *t = tm_new(p);
|
||||
t->hook = hook;
|
||||
|
@ -668,6 +668,40 @@ sk_set_high_port(sock *s UNUSED)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
sk_set_min_rcvbuf_(sock *s, int bufsize)
|
||||
{
|
||||
int oldsize = 0, oldsize_s = sizeof(oldsize);
|
||||
|
||||
if (getsockopt(s->fd, SOL_SOCKET, SO_RCVBUF, &oldsize, &oldsize_s) < 0)
|
||||
ERR("SO_RCVBUF");
|
||||
|
||||
if (oldsize >= bufsize)
|
||||
return 0;
|
||||
|
||||
bufsize = BIRD_ALIGN(bufsize, 64);
|
||||
if (setsockopt(s->fd, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize)) < 0)
|
||||
ERR("SO_RCVBUF");
|
||||
|
||||
/*
|
||||
int newsize = 0, newsize_s = sizeof(newsize);
|
||||
if (getsockopt(s->fd, SOL_SOCKET, SO_RCVBUF, &newsize, &newsize_s) < 0)
|
||||
ERR("SO_RCVBUF");
|
||||
|
||||
log(L_INFO "Setting rcvbuf on %s from %d to %d",
|
||||
s->iface ? s->iface->name : "*", oldsize, newsize);
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
sk_set_min_rcvbuf(sock *s, int bufsize)
|
||||
{
|
||||
if (sk_set_min_rcvbuf_(s, bufsize) < 0)
|
||||
log(L_WARN "Socket error: %s%#m", s->err);
|
||||
}
|
||||
|
||||
static inline byte *
|
||||
sk_skip_ip_header(byte *pkt, int *len)
|
||||
{
|
||||
@ -999,6 +1033,9 @@ sk_set_rbsize(sock *s, uint val)
|
||||
xfree(s->rbuf_alloc);
|
||||
s->rbuf_alloc = xmalloc(val);
|
||||
s->rpos = s->rbuf = s->rbuf_alloc;
|
||||
|
||||
if ((s->type == SK_UDP) || (s->type == SK_IP))
|
||||
sk_set_min_rcvbuf(s, s->rbsize);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1195,6 +1232,9 @@ sk_setup(sock *s)
|
||||
if (sk_set_priority(s, s->priority) < 0)
|
||||
return -1;
|
||||
|
||||
if ((s->type == SK_UDP) || (s->type == SK_IP))
|
||||
sk_set_min_rcvbuf(s, s->rbsize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user