Stop rs_request_send() from leaking RSE_TIMEOUT_CONN and RSE_TIMEOUT_IO.
[libradsec.git] / lib / request.c
index 9ad7843..40ac56d 100644 (file)
@@ -1,5 +1,5 @@
-/* Copyright 20102011 NORDUnet A/S. All rights reserved.
-   See LICENSE for licensing information.  */
+/* Copyright 2010-2011 NORDUnet A/S. All rights reserved.
+   See LICENSE for licensing information. */
 
 #if defined HAVE_CONFIG_H
 #include <config.h>
@@ -51,8 +51,7 @@ int
 rs_request_create_authn (struct rs_connection *conn,
                         struct rs_request **req_out,
                         const char *user_name,
-                        const char *user_pw,
-                         const char *secret)
+                        const char *user_pw)
 {
   struct rs_request *req = NULL;
   assert (req_out);
@@ -60,7 +59,7 @@ rs_request_create_authn (struct rs_connection *conn,
   if (rs_request_create (conn, &req))
     return -1;
 
-  if (rs_packet_create_authn_request (conn, &req->req_msg, user_name, user_pw, secret))
+  if (rs_packet_create_authn_request (conn, &req->req_msg, user_name, user_pw))
     return -1;
 
   if (req_out)
@@ -120,17 +119,19 @@ rs_request_send (struct rs_request *request, struct rs_packet **resp_msg)
                                      resp_msg);
          if (r == RSE_OK)
            break;              /* Success.  */
-
-         if (r != RSE_TIMEOUT_CONN && r != RSE_TIMEOUT_IO)
-           break;              /* Error.  */
        }
-      else if (r != RSE_TIMEOUT_CONN && r != RSE_TIMEOUT_IO)
+      if (r != RSE_TIMEOUT_CONN && r != RSE_TIMEOUT_IO)
        break;                  /* Error.  */
 
+      /* Timing out reading or writing. Pop the timeout error from the
+         stack and continue the loop. */
+      rs_err_conn_pop (request->conn);
+
       gettimeofday (&now, NULL);
       if (++count > MRC || timercmp (&now, &end, >))
        {
-         r = RSE_TIMEOUT;
+         r = rs_err_conn_push_fl (request->conn, RSE_TIMEOUT,
+                                   __FILE__, __LINE__, NULL);
          break;                /* Timeout.  */
        }