lib/tsocket: add a fast path to tsocket_writev_send/recv()
[ira/wip.git] / lib / tsocket / tsocket_writev.c
index 27f28a60e46206c76880dc28c2a5c5c79d2f1f50..8c5cd40385aa6baace1efa6bb9af76ec5dfcc62c 100644 (file)
@@ -103,6 +103,16 @@ struct tevent_req *tsocket_writev_send(struct tsocket_context *sock,
                goto post;
        }
 
+       /*
+        * this is a fast path, not waiting for the
+        * socket to become explicit writeable gains
+        * about 10%-20% performance in benchmark tests.
+        */
+       tsocket_writev_handler(sock, req);
+       if (!tevent_req_is_in_progress(req)) {
+               goto post;
+       }
+
        talloc_set_destructor(state, tsocket_writev_state_destructor);
 
        ret = tsocket_set_writeable_handler(sock,