From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: kostja@tarantool.org
Subject: [tarantool-patches] [PATCH 2/5] test: on close of swim fake fd send its packets, not drop
Date: Tue, 9 Apr 2019 21:12:09 +0300 [thread overview]
Message-ID: <da98b81d323f8e9d3435c61ba254e524535327c4.1554833062.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1554833062.git.v.shpilevoy@tarantool.org>
In-Reply-To: <cover.1554833062.git.v.shpilevoy@tarantool.org>
The packets originator has already got an OK status and expects
these messages sent even if the originator is closed right after
that. This commit does the TCP-way and sends all the pending
messages before actually closing the fake fd.
Part of #3234
---
test/unit/swim_test_transport.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/test/unit/swim_test_transport.c b/test/unit/swim_test_transport.c
index e563185ee..f30000135 100644
--- a/test/unit/swim_test_transport.c
+++ b/test/unit/swim_test_transport.c
@@ -135,6 +135,10 @@ swim_fd_open(struct swim_fd *fd)
return 0;
}
+/** Send one packet to destination's recv queue. */
+static inline void
+swim_fd_send_packet(struct swim_fd *fd);
+
/** Close a fake file descriptor. */
static inline void
swim_fd_close(struct swim_fd *fd)
@@ -144,8 +148,8 @@ swim_fd_close(struct swim_fd *fd)
struct swim_test_packet *i, *tmp;
rlist_foreach_entry_safe(i, &fd->recv_queue, in_queue, tmp)
swim_test_packet_delete(i);
- rlist_foreach_entry_safe(i, &fd->send_queue, in_queue, tmp)
- swim_test_packet_delete(i);
+ while (! rlist_empty(&fd->send_queue))
+ swim_fd_send_packet(fd);
rlist_del_entry(fd, in_active);
fd->is_opened = false;
}
@@ -285,12 +289,10 @@ swim_test_is_drop(double rate)
return ((double) rand() / RAND_MAX) * 100 < rate;
}
-/** Send one packet to destination's recv queue. */
static inline void
swim_fd_send_packet(struct swim_fd *fd)
{
- if (rlist_empty(&fd->send_queue))
- return;
+ assert(! rlist_empty(&fd->send_queue));
struct swim_test_packet *p =
rlist_shift_entry(&fd->send_queue, struct swim_test_packet,
in_queue);
@@ -311,7 +313,8 @@ swim_transport_do_loop_step(struct ev_loop *loop)
* order. So this reverse + libev reverse = normal order.
*/
rlist_foreach_entry_reverse(fd, &swim_fd_active, in_active) {
- swim_fd_send_packet(fd);
+ if (! rlist_empty(&fd->send_queue))
+ swim_fd_send_packet(fd);
ev_feed_fd_event(loop, fd->evfd, EV_WRITE);
}
rlist_foreach_entry_reverse(fd, &swim_fd_active, in_active) {
--
2.17.2 (Apple Git-113)
next prev parent reply other threads:[~2019-04-09 18:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-09 18:12 [tarantool-patches] [PATCH 0/5] swim member 'left' status Vladislav Shpilevoy
2019-04-09 18:12 ` [tarantool-patches] [PATCH 1/5] test: allow to remove swim nodes from the cluster Vladislav Shpilevoy
2019-04-10 7:15 ` [tarantool-patches] " Konstantin Osipov
2019-04-09 18:12 ` Vladislav Shpilevoy [this message]
2019-04-10 7:16 ` [tarantool-patches] Re: [PATCH 2/5] test: on close of swim fake fd send its packets, not drop Konstantin Osipov
2019-04-09 18:12 ` [tarantool-patches] [PATCH 3/5] test: process IO swim test events before protocol's ones Vladislav Shpilevoy
2019-04-10 7:17 ` [tarantool-patches] " Konstantin Osipov
2019-04-09 18:12 ` [tarantool-patches] [PATCH 4/5] swim: introduce quit message Vladislav Shpilevoy
2019-04-10 7:21 ` [tarantool-patches] " Konstantin Osipov
2019-04-09 18:12 ` [tarantool-patches] [PATCH 5/5] swim: make UUID update smoother and faster Vladislav Shpilevoy
2019-04-10 7:22 ` [tarantool-patches] " Konstantin Osipov
2019-04-10 10:29 ` [tarantool-patches] Re: [PATCH 0/5] swim member 'left' status Vladislav Shpilevoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da98b81d323f8e9d3435c61ba254e524535327c4.1554833062.git.v.shpilevoy@tarantool.org \
--to=v.shpilevoy@tarantool.org \
--cc=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH 2/5] test: on close of swim fake fd send its packets, not drop' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox