diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-05-14 18:51:26 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-01-12 23:34:24 +0100 |
commit | ae5f9c701bcdae8f65e15b9f56ffd6bc7354a8fd (patch) | |
tree | 414168271c2dddf1c1eaa2d47f293b74a42dae9a | |
parent | 043563d2e9d21616884d917499b575305368ef80 (diff) |
Wg-user: Send in socket tx hook
-rw-r--r-- | sysdep/unix/wg_user.c | 22 |
1 files 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; |