Permalink
Browse files

CA-86426: fix a tap-ctl race.

It is possible for a new control connection to be accepted, but before anything is
received on it, for a "detach" message to come in and cause the tapdisk server to
exit. On cleanup, the new, unprocessed connection causes this:
tap-err:tapdisk_ctl_conn_drain: tapdisk-control.c:273: FAILED ASSERTION: 'conn->out.done'

We now simply drop any such connections.
  • Loading branch information...
1 parent e1a392b commit 21320294e82433ac6a741e3f684a845fd0870913 @andreil andreil committed Aug 8, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 drivers/tapdisk-control.c
View
@@ -270,7 +270,14 @@ tapdisk_ctl_conn_drain(struct tapdisk_ctl_conn *conn)
fd_set wfds;
int n, mode;
- ASSERT(conn->out.done);
+ if (!conn->out.done) {
+ /* we accepted this connection but haven't received the message
+ * body yet. Since this tapdisk is on its way out, just drop
+ * the connection. */
+ tapdisk_ctl_conn_close(conn);
+ return;
+ }
+
ASSERT(conn->fd >= 0);
while (tapdisk_ctl_conn_connected(conn)) {
@@ -312,6 +319,7 @@ tapdisk_ctl_conn_open(int fd)
conn->fd = fd;
conn->out.prod = conn->out.buf;
conn->out.cons = conn->out.buf;
+ conn->out.done = 0;
tapdisk_ctl_conn_mask_out(conn);

0 comments on commit 2132029

Please sign in to comment.