From ae5f9c701bcdae8f65e15b9f56ffd6bc7354a8fd Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Thu, 14 May 2020 18:51:26 +0200 Subject: Wg-user: Send in socket tx hook --- sysdep/unix/wg_user.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/sysdep/unix/wg_user.c b/sysdep/unix/wg_user.c index 34d456d5..6920d9ef 100644 --- a/sysdep/unix/wg_user.c +++ b/sysdep/unix/wg_user.c @@ -59,6 +59,24 @@ static void user_tx_hook(struct birdsock *bs) { DBG(L_TRACE "WG: TX %p %d", bs, bs->tpos - bs->ttx); + + uint size = (uintptr_t)bs->data; + + if (size > 0) + { + int res = sk_send(bs, bs->tbsize - size); + + /* Send data, <0=err, >0=ok, 0=sleep */ + log(L_TRACE "WG: send %d", res); + + if (res != 0) + { + //rfree(sock); + //shutdown(sock->fd, SHUT_WR); + } + + bs->data = NULL; + } } /* errno or zero if EOF */ @@ -258,9 +276,7 @@ wg_user_set_device(struct pool *pool, rfree(sock); return -1; } - res = sk_send(sock, tbsize - size); - /* Send data, <0=err, >0=ok, 0=sleep */ - DBG(L_TRACE "WG: send %d", res); + sock->data = (void*)(uintptr_t)size; /* abort(); */ return -1; -- cgit v1.2.3