qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gmur...@apache.org
Subject qpid-dispatch git commit: DISPATCH-266 - Added a free_user_id bool to qd_connection_t and set it to true when we malloc user_id so we can free it later on
Date Fri, 08 Apr 2016 19:33:31 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master deeb0316b -> b3d62eb90


DISPATCH-266 - Added a free_user_id bool to qd_connection_t and set it to true when we malloc
user_id so we can free it later on


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/b3d62eb9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/b3d62eb9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/b3d62eb9

Branch: refs/heads/master
Commit: b3d62eb90f4ac90655c294d3ad6d617e4919a8ce
Parents: deeb031
Author: Ganesh Murthy <gmurthy@redhat.com>
Authored: Fri Apr 8 15:32:09 2016 -0400
Committer: Ganesh Murthy <gmurthy@redhat.com>
Committed: Fri Apr 8 15:32:09 2016 -0400

----------------------------------------------------------------------
 src/server.c         | 11 ++++++++++-
 src/server_private.h |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b3d62eb9/src/server.c
----------------------------------------------------------------------
diff --git a/src/server.c b/src/server.c
index 69a880b..21a8865 100644
--- a/src/server.c
+++ b/src/server.c
@@ -98,6 +98,9 @@ static void free_qd_connection(qd_connection_t *ctx)
         ctx->collector = NULL;
     }
 
+    if (ctx->free_user_id)
+        free((char*)ctx->user_id);
+
     free_qd_connection_t(ctx);
 }
 
@@ -243,6 +246,11 @@ static const char *qd_transport_get_user(qd_connection_t *conn, pn_transport_t
*
 
         if(uid_length > 0) {
             char *user_id = malloc((uid_length + semi_colon_count + 1) * sizeof(char)); //
the +1 is for the '\0' character
+            //
+            // We have allocated memory for user_id. We are responsible for freeing this
memory. Set conn->free_user_id
+            // to true so that we know that we have to free the user_id
+            //
+            conn->free_user_id = true;
             memset(user_id, 0, uid_length + semi_colon_count + 1);
 
             // The components in the user id string must appear in the same order as it appears
in the component string. that is
@@ -318,7 +326,6 @@ void qd_connection_set_user(qd_connection_t *conn)
         conn->user_id = pn_transport_get_user(tport);
         // We want to set the user name only if it is not already set and the selected sasl
mechanism is EXTERNAL
         if (mech && strcmp(mech, MECH_EXTERNAL) == 0) {
-            // TODO - Make sure you free the user_id when conn is freed ?
             const char *user_id = qd_transport_get_user(conn, tport);
             if (user_id)
                 conn->user_id = user_id;
@@ -510,6 +517,7 @@ static void thread_process_listeners_LH(qd_server_t *qd_server)
         ctx->link_context  = 0;
         ctx->ufd           = 0;
         ctx->user_id       = 0;
+        ctx->free_user_id  = false;
         ctx->connection_id = qd_server->next_connection_id++; // Increment the connection
id so the next connection can use it
         ctx->policy_settings = 0;
         ctx->n_senders       = 0;
@@ -1059,6 +1067,7 @@ static void cxtr_try_open(void *context)
     ctx->link_context = 0;
     ctx->ufd          = 0;
     ctx->user_id      = 0;
+    ctx->free_user_id = false;
     ctx->policy_settings = 0;
     ctx->n_senders       = 0;
     ctx->n_receivers     = 0;

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b3d62eb9/src/server_private.h
----------------------------------------------------------------------
diff --git a/src/server_private.h b/src/server_private.h
index 562feb5..0a8d701 100644
--- a/src/server_private.h
+++ b/src/server_private.h
@@ -100,6 +100,7 @@ struct qd_connection_t {
     qd_user_fd_t             *ufd;
     uint64_t                  connection_id; // A unique identifier for the qd_connection_t.
The underlying pn_connection already has one but it is long and clunky.
     const char               *user_id; // A unique identifier for the user on the connection.
This is currently populated  from the client ssl cert. See ssl_uid_format in server.h for
more info
+    bool                      free_user_id;
     qd_policy_settings_t     *policy_settings;
     int                       n_sessions;
     int                       n_senders;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message