r22090: fix error handling in cldap client library to cope with bad host names
authorAndrew Tridgell <tridge@samba.org>
Thu, 5 Apr 2007 07:37:21 +0000 (07:37 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:49:51 +0000 (14:49 -0500)
source/libcli/cldap/cldap.c
source/libcli/cldap/cldap.h

index 96b60da25f1110cd104991e0852eae8bd9874823..c68a037552f16dd283b268fa04d862753752e457 100644 (file)
@@ -165,7 +165,8 @@ static void cldap_request_timeout(struct event_context *event_ctx,
                return;
        }
 
-       req->state = CLDAP_REQUEST_TIMEOUT;
+       req->state = CLDAP_REQUEST_ERROR;
+       req->status = NT_STATUS_IO_TIMEOUT;
        if (req->async.fn) {
                req->async.fn(req);
        }
@@ -186,10 +187,14 @@ static void cldap_socket_send(struct cldap_socket *cldap)
                status = socket_sendto(cldap->sock, &req->encoded, &len,
                                       req->dest);
                if (NT_STATUS_IS_ERR(status)) {
-                       DEBUG(3,("Failed to send cldap request of length %u to %s:%d\n",
+                       DEBUG(0,("Failed to send cldap request of length %u to %s:%d\n",
                                 (unsigned)req->encoded.length, req->dest->addr, req->dest->port));
                        DLIST_REMOVE(cldap->send_queue, req);
-                       talloc_free(req);
+                       req->state = CLDAP_REQUEST_ERROR;
+                       req->status = status;
+                       if (req->async.fn) {
+                               req->async.fn(req);
+                       }
                        continue;
                }
 
@@ -442,9 +447,10 @@ NTSTATUS cldap_search_recv(struct cldap_request *req,
                }
        }
 
-       if (req->state == CLDAP_REQUEST_TIMEOUT) {
+       if (req->state == CLDAP_REQUEST_ERROR) {
+               status = req->status;
                talloc_free(req);
-               return NT_STATUS_IO_TIMEOUT;
+               return status;
        }
 
        ldap_msg = talloc(mem_ctx, struct ldap_message);
index 8bae2aa41b37632a9602560b644cb429fd464e54..928cf1f3e4efd39b78e69bcdb1f328777c6c67dd 100644 (file)
@@ -28,7 +28,7 @@ struct ldap_message;
 enum cldap_request_state {CLDAP_REQUEST_SEND, 
                          CLDAP_REQUEST_WAIT, 
                          CLDAP_REQUEST_DONE,
-                         CLDAP_REQUEST_TIMEOUT};
+                         CLDAP_REQUEST_ERROR};
 
 /*
   a cldap request packet
@@ -39,6 +39,7 @@ struct cldap_request {
        struct cldap_socket *cldap;
 
        enum cldap_request_state state;
+       NTSTATUS status;
 
        /* where to send the request */
        struct socket_address *dest;