MEDIUM: connection: remove the FD_POLL_* flags only once

It's inappropriate to remove FD_POLL_IN and FD_POLL_OUT in the IO callback
handlers, first because they shouldn't care about this, and second because
it will make it harder to chain multiple callers.

So let's flush these flags only once for all in the connection handler.
Right now, the HUP and ERR flags are still flushed in each IO handler to
avoid multiple calls. This will probably have to be fixed later.
diff --git a/src/connection.c b/src/connection.c
index 696525d..089ad89 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -42,5 +42,7 @@
 		if (!conn->data->write(fd))
 			ret |= FD_WAIT_WRITE;
 
+	/* remove the events before leaving */
+	fdtab[fd].ev &= ~(FD_POLL_IN | FD_POLL_OUT | FD_POLL_HUP | FD_POLL_ERR);
 	return ret;
 }