FreeBSD Bugzilla – Attachment 231650 Details for
Bug 260116
[sctp] POLLOUT/EVFILT_WRITE is always true for poll/kqueue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch v2
0001-Handle-POLLOUT-EVFILT_WRITE-when-send-buffer-is-full.patch (text/plain), 4.82 KB, created by
Björn Svensson
on 2022-02-08 17:47:03 UTC
(
hide
)
Description:
Proposed patch v2
Filename:
MIME Type:
Creator:
Björn Svensson
Created:
2022-02-08 17:47:03 UTC
Size:
4.82 KB
patch
obsolete
>From 3249a0209307366d14bbee5471129eed1443657e Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Bj=C3=B6rn=20Svensson?= <bjorn.a.svensson@est.tech> >Date: Tue, 25 Jan 2022 10:35:30 +0000 >Subject: [PATCH 1/1] Handle POLLOUT/EVFILT_WRITE when send buffer is full > >Since the socket buffer counter sb_cc has been split into sb_ccc and >sb_acc, and both are used, there is a need to update both counters >for 1-to-1 style sockets. Currently sb_acc is used as sb_cc to enable >select(), but sb_ccc is required to be updated as well for the >poll() events or the kevent() filters. > >This adds a macro for unifying the sb_acc and sb_ccc counters where >there is a need to update both counter values. > >The macro can be changed for upstream users in a similar way as for >the use of sb_cc, i.e. it can be disabled/empty when there is a need >to keep the old way of only using sb_cc. >--- > sys/netinet/sctp_input.c | 1 + > sys/netinet/sctp_os_bsd.h | 5 +++++ > sys/netinet/sctp_output.c | 1 + > sys/netinet/sctp_usrreq.c | 3 +++ > sys/netinet/sctputil.c | 1 + > sys/netinet/sctputil.h | 3 +++ > 6 files changed, 14 insertions(+) > >diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c >index ce017b74b67..18b4f26c5ae 100644 >--- a/sys/netinet/sctp_input.c >+++ b/sys/netinet/sctp_input.c >@@ -995,6 +995,7 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED, > if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || > (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) { > stcb->sctp_socket->so_snd.sb_cc = 0; >+ SCTP_UNIFY_SB_CC(stcb->sctp_socket->so_snd); > } > sctp_ulp_notify(SCTP_NOTIFY_ASSOC_DOWN, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); > } >diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h >index 39c0a8cb5c2..b39ded5587f 100644 >--- a/sys/netinet/sctp_os_bsd.h >+++ b/sys/netinet/sctp_os_bsd.h >@@ -378,6 +378,11 @@ typedef struct callout sctp_os_timer_t; > * with SCTP sockets. > */ > #define sb_cc sb_acc >+/* Macro to unify sendbuffer counters sb_acc and sb_ccc. >+ * Both counters are required to be set to receive correct events via >+ * poll()/kevent() when send buffer is full on 1-to-1 style sockets. >+ */ >+#define SCTP_UNIFY_SB_CC(sb) (atomic_store_int(&(sb).sb_ccc, (sb).sb_acc)) > /* reserve sb space for a socket */ > #define SCTP_SORESERVE(so, send, recv) soreserve(so, send, recv) > /* wakeup a socket */ >diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c >index 277a6625aa1..fd5a95a093d 100644 >--- a/sys/netinet/sctp_output.c >+++ b/sys/netinet/sctp_output.c >@@ -7258,6 +7258,7 @@ sctp_move_to_outqueue(struct sctp_tcb *stcb, > ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || > (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { > atomic_subtract_int(&stcb->sctp_socket->so_snd.sb_cc, sp->length); >+ SCTP_UNIFY_SB_CC(stcb->sctp_socket->so_snd); > } > if (sp->data) { > sctp_m_freem(sp->data); >diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c >index 2dad0b41a30..c1a6eb28beb 100644 >--- a/sys/netinet/sctp_usrreq.c >+++ b/sys/netinet/sctp_usrreq.c >@@ -437,6 +437,7 @@ sctp_abort(struct socket *so) > SCTP_CALLED_AFTER_CMPSET_OFCLOSE); > SOCK_LOCK(so); > SCTP_SB_CLEAR(so->so_snd); >+ SCTP_UNIFY_SB_CC(so->so_snd); > /* > * same for the rcv ones, they are only here for the > * accounting/select. >@@ -548,6 +549,7 @@ sctp_close(struct socket *so) > */ > SOCK_LOCK(so); > SCTP_SB_CLEAR(so->so_snd); >+ SCTP_UNIFY_SB_CC(so->so_snd); > /* > * same for the rcv ones, they are only here for the > * accounting/select. >@@ -838,6 +840,7 @@ sctp_flush(struct socket *so, int how) > * except maybe the count > */ > so->so_snd.sb_cc = 0; >+ SCTP_UNIFY_SB_CC(so->so_snd); > so->so_snd.sb_mbcnt = 0; > so->so_snd.sb_mb = NULL; > } >diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c >index 42e91e10a0d..0fb1f194275 100644 >--- a/sys/netinet/sctputil.c >+++ b/sys/netinet/sctputil.c >@@ -5045,6 +5045,7 @@ sctp_free_bufspace(struct sctp_tcb *stcb, struct sctp_association *asoc, > } else { > stcb->sctp_socket->so_snd.sb_cc = 0; > } >+ SCTP_UNIFY_SB_CC(stcb->sctp_socket->so_snd); > } > } > >diff --git a/sys/netinet/sctputil.h b/sys/netinet/sctputil.h >index 3319eb4f455..db568fc1638 100644 >--- a/sys/netinet/sctputil.h >+++ b/sys/netinet/sctputil.h >@@ -264,6 +264,7 @@ do { \ > } else { \ > stcb->sctp_socket->so_snd.sb_cc = 0; \ > } \ >+ SCTP_UNIFY_SB_CC(stcb->sctp_socket->so_snd); \ > } \ > } \ > } while (0) >@@ -285,6 +286,7 @@ do { \ > } else { \ > stcb->sctp_socket->so_snd.sb_cc = 0; \ > } \ >+ SCTP_UNIFY_SB_CC(stcb->sctp_socket->so_snd); \ > } \ > } \ > } while (0) >@@ -296,6 +298,7 @@ do { \ > ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \ > (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \ > atomic_add_int(&stcb->sctp_socket->so_snd.sb_cc,sz); \ >+ SCTP_UNIFY_SB_CC(stcb->sctp_socket->so_snd); \ > } \ > } while (0) > >-- >2.34.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 260116
:
229791
|
231307
| 231650