s3: Move setting the name_query timeout
authorVolker Lendecke <vl@samba.org>
Mon, 25 Apr 2011 15:37:08 +0000 (17:37 +0200)
committerVolker Lendecke <vlendec@samba.org>
Mon, 25 Apr 2011 16:39:20 +0000 (18:39 +0200)
An async caller might want a different timeout behaviour

source3/libsmb/namequery.c

index ef7aab6a6aacb44dcd531d4204404beee4df9fce..9489878ce495e355a77f80ab416955edec733c14 100644 (file)
@@ -1177,7 +1177,6 @@ struct tevent_req *name_query_send(TALLOC_CTX *mem_ctx,
        struct packet_struct p;
        struct nmb_packet *nmb = &p.packet.nmb;
        struct sockaddr_in *in_addr;
-       struct timeval timeout;
 
        req = tevent_req_create(mem_ctx, &state, struct name_query_state);
        if (req == NULL) {
@@ -1243,14 +1242,6 @@ struct tevent_req *name_query_send(TALLOC_CTX *mem_ctx,
                DEBUG(10, ("nb_trans_send failed\n"));
                return tevent_req_post(req, ev);
        }
-       if (bcast) {
-               timeout = timeval_current_ofs(0, 250000);
-       } else {
-               timeout = timeval_current_ofs(2, 0);
-       }
-       if (!tevent_req_set_endtime(req, ev, timeout)) {
-               return tevent_req_post(req, ev);
-       }
        tevent_req_set_callback(subreq, name_query_done, req);
        return req;
 }
@@ -1433,6 +1424,7 @@ NTSTATUS name_query(const char *name, int name_type,
        TALLOC_CTX *frame = talloc_stackframe();
        struct tevent_context *ev;
        struct tevent_req *req;
+       struct timeval timeout;
        NTSTATUS status = NT_STATUS_NO_MEMORY;
 
        ev = tevent_context_init(frame);
@@ -1443,6 +1435,14 @@ NTSTATUS name_query(const char *name, int name_type,
        if (req == NULL) {
                goto fail;
        }
+       if (bcast) {
+               timeout = timeval_current_ofs(0, 250000);
+       } else {
+               timeout = timeval_current_ofs(2, 0);
+       }
+       if (!tevent_req_set_endtime(req, ev, timeout)) {
+               goto fail;
+       }
        if (!tevent_req_poll_ntstatus(req, ev, &status)) {
                goto fail;
        }