lib: Simplify writev_cancel()
authorVolker Lendecke <vl@samba.org>
Thu, 12 Mar 2020 10:42:41 +0000 (11:42 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 25 Mar 2020 09:04:27 +0000 (09:04 +0000)
We can only reasonably cancel a writev request that is still
queued. Once writing has started, cancel is pointless. Simplify the
if-conditions.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/async_req/async_sock.c

index e436d00ac798cd2ff96348ba658da3925a0d5540..e6e5a281a264cc3b3561dd86ac9434b9f17392fa 100644 (file)
@@ -312,25 +312,17 @@ static bool writev_cancel(struct tevent_req *req)
 {
        struct writev_state *state = tevent_req_data(req, struct writev_state);
 
-       TALLOC_FREE(state->queue_entry);
-       TALLOC_FREE(state->fde);
-
-       if (state->count == 0) {
-               /*
-                * already completed.
-                */
-               return false;
-       }
-
-       tevent_req_defer_callback(req, state->ev);
        if (state->total_size > 0) {
                /*
                 * We've already started to write :-(
                 */
-               tevent_req_error(req, EIO);
                return false;
        }
 
+       TALLOC_FREE(state->queue_entry);
+       TALLOC_FREE(state->fde);
+
+       tevent_req_defer_callback(req, state->ev);
        tevent_req_error(req, ECANCELED);
        return true;
 }