Fix ekr_loop. (#326)
* fix it so we, when doing the pdapi, wakeup when we
have added.
* Improve testing.
* Sync FBSDID.
diff --git a/programs/ekr_loop.c b/programs/ekr_loop.c
index 5988450..21e323b 100644
--- a/programs/ekr_loop.c
+++ b/programs/ekr_loop.c
@@ -53,6 +53,7 @@
#define MAX_PACKET_SIZE (1<<16)
#define LINE_LENGTH (1<<20)
#define DISCARD_PPID 39
+#define NUMBER_OF_STEPS 10
#ifdef _WIN32
static DWORD WINAPI
@@ -272,7 +273,7 @@
#else
pthread_t tid_c, tid_s;
#endif
- int cur_buf_size, snd_buf_size, rcv_buf_size;
+ int i, cur_buf_size, snd_buf_size, rcv_buf_size;
socklen_t opt_len;
struct sctp_sndinfo sndinfo;
char *line;
@@ -476,21 +477,32 @@
}
memset(line, 'A', LINE_LENGTH);
sndinfo.snd_sid = 1;
- sndinfo.snd_flags = 0; /* SCTP_UNORDERED */
sndinfo.snd_ppid = htonl(DISCARD_PPID);
sndinfo.snd_context = 0;
sndinfo.snd_assoc_id = 0;
- /* Send a 1 MB ordered message */
- if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
- (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
- perror("usrsctp_sendv");
- exit(EXIT_FAILURE);
- }
- /* Send a 1 MB ordered message */
- if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
- (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
- perror("usrsctp_sendv");
- exit(EXIT_FAILURE);
+ for (i = 1; i < NUMBER_OF_STEPS; i++) {
+ if (i % 2) {
+ sndinfo.snd_flags = SCTP_UNORDERED;
+ } else {
+ sndinfo.snd_flags = 0;
+ }
+ /* Send a 1 MB ordered message */
+ if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
+ (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
+ perror("usrsctp_sendv");
+ exit(EXIT_FAILURE);
+ }
+ /* Send a 1 MB ordered message */
+ if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
+ (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
+ perror("usrsctp_sendv");
+ exit(EXIT_FAILURE);
+ }
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
}
free(line);
usrsctp_shutdown(s_c, SHUT_WR);
diff --git a/usrsctplib/netinet/sctp_indata.c b/usrsctplib/netinet/sctp_indata.c
index ea29731..de18d7a 100755
--- a/usrsctplib/netinet/sctp_indata.c
+++ b/usrsctplib/netinet/sctp_indata.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 345494 2019-03-25 09:47:22Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 350216 2019-07-22 18:11:35Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -928,6 +928,12 @@
break;
}
}
+ if (cnt_added && strm->pd_api_started) {
+#if defined(__Userspace__)
+ sctp_invoke_recv_callback(stcb->sctp_ep, stcb, control, SCTP_READ_LOCK_NOT_HELD);
+#endif
+ sctp_wakeup_the_read_socket(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
+ }
if ((control->length > pd_point) && (strm->pd_api_started == 0)) {
strm->pd_api_started = 1;
control->pdapi_started = 1;