Allow NULL queue to writev_send
authorVolker Lendecke <vl@samba.org>
Sun, 10 May 2009 08:49:18 +0000 (10:49 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 24 May 2009 11:45:35 +0000 (13:45 +0200)
lib/async_req/async_sock.c

index 543972815dc35acdacfa734856565b40436ffc38..a3a6d75f3a0b0cad522d5e14d0e9b6c4bdc8164f 100644 (file)
@@ -337,11 +337,11 @@ struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
                               struct tevent_queue *queue, int fd,
                               struct iovec *iov, int count)
 {
                               struct tevent_queue *queue, int fd,
                               struct iovec *iov, int count)
 {
-       struct tevent_req *result;
+       struct tevent_req *req;
        struct writev_state *state;
 
        struct writev_state *state;
 
-       result = tevent_req_create(mem_ctx, &state, struct writev_state);
-       if (result == NULL) {
+       req = tevent_req_create(mem_ctx, &state, struct writev_state);
+       if (req == NULL) {
                return NULL;
        }
        state->ev = ev;
                return NULL;
        }
        state->ev = ev;
@@ -354,12 +354,22 @@ struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
                goto fail;
        }
 
                goto fail;
        }
 
-       if (!tevent_queue_add(queue, ev, result, writev_trigger, NULL)) {
+       if (queue == NULL) {
+               struct tevent_fd *fde;
+               fde = tevent_add_fd(state->ev, state, state->fd,
+                                   TEVENT_FD_WRITE, writev_handler, req);
+               if (tevent_req_nomem(fde, req)) {
+                       return tevent_req_post(req, ev);
+               }
+               return req;
+       }
+
+       if (!tevent_queue_add(queue, ev, req, writev_trigger, NULL)) {
                goto fail;
        }
                goto fail;
        }
-       return result;
+       return req;
  fail:
  fail:
-       TALLOC_FREE(result);
+       TALLOC_FREE(req);
        return NULL;
 }
 
        return NULL;
 }