mirror of
https://github.com/schoebel/mars
synced 2025-01-01 11:52:25 +00:00
net: find out current tcp send buffer space available
This commit is contained in:
parent
7f86c52f7c
commit
d607e422d4
@ -374,6 +374,27 @@ done:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mars_socket_is_alive);
|
||||
|
||||
long mars_socket_send_space_available(struct mars_socket *msock)
|
||||
{
|
||||
struct socket *raw_sock = msock->s_socket;
|
||||
long res = 0;
|
||||
if (!msock->s_alive || !raw_sock || !raw_sock->sk)
|
||||
goto done;
|
||||
if (unlikely(atomic_read(&msock->s_count) <= 0)) {
|
||||
MARS_ERR("#%d bad nesting on msock = %p sock = %p\n", msock->s_debug_nr, msock, msock->s_socket);
|
||||
goto done;
|
||||
}
|
||||
|
||||
res = raw_sock->sk->sk_sndbuf - raw_sock->sk->sk_wmem_queued;
|
||||
if (res < 0)
|
||||
res = 0;
|
||||
res += msock->s_pos;
|
||||
|
||||
done:
|
||||
return res;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mars_socket_send_space_available);
|
||||
|
||||
static
|
||||
int _mars_send_raw(struct mars_socket *msock, const void *buf, int len)
|
||||
{
|
||||
|
@ -125,6 +125,7 @@ extern bool mars_get_socket(struct mars_socket *msock);
|
||||
extern void mars_put_socket(struct mars_socket *msock);
|
||||
extern void mars_shutdown_socket(struct mars_socket *msock);
|
||||
extern bool mars_socket_is_alive(struct mars_socket *msock);
|
||||
extern long mars_socket_send_space_available(struct mars_socket *msock);
|
||||
|
||||
extern int mars_send_raw(struct mars_socket *msock, const void *buf, int len, bool cork);
|
||||
extern int mars_recv_raw(struct mars_socket *msock, void *buf, int minlen, int maxlen);
|
||||
|
Loading…
Reference in New Issue
Block a user