diff options
author | Greg Hudson <ghudson@mit.edu> | 2012-06-16 11:23:14 -0400 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2012-06-22 11:46:57 -0400 |
commit | f07760088b72a11c54dd72efbc5739f231a4d4b0 (patch) | |
tree | 397da301f4ba086a69d3f945471cdc76ffebf23c /src | |
parent | db83abc7dcfe369bd4467c78eebb7028ba0c0e0d (diff) | |
download | krb5-f07760088b72a11c54dd72efbc5739f231a4d4b0.tar.gz krb5-f07760088b72a11c54dd72efbc5739f231a4d4b0.tar.xz krb5-f07760088b72a11c54dd72efbc5739f231a4d4b0.zip |
Flatten KDC lookaside cache entries
Use krb5_data structures instead of pointers in the entry structure,
reducing the number of memory allocations.
Diffstat (limited to 'src')
-rw-r--r-- | src/kdc/replay.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/kdc/replay.c b/src/kdc/replay.c index 225320e7eb..ac51b830fd 100644 --- a/src/kdc/replay.c +++ b/src/kdc/replay.c @@ -36,8 +36,8 @@ struct entry { TAILQ_ENTRY(entry) expire_links; int num_hits; krb5_timestamp timein; - krb5_data *req_packet; - krb5_data *reply_packet; + krb5_data req_packet; + krb5_data reply_packet; }; #ifndef LOOKASIDE_HASH_SIZE @@ -104,8 +104,8 @@ discard_entry(krb5_context context, struct entry *entry) { LIST_REMOVE(entry, bucket_links); TAILQ_REMOVE(&expiration_queue, entry, expire_links); - krb5_free_data(context, entry->req_packet); - krb5_free_data(context, entry->reply_packet); + krb5_free_data_contents(context, &entry->req_packet); + krb5_free_data_contents(context, &entry->reply_packet); free(entry); } @@ -117,7 +117,7 @@ find_entry(krb5_data *req_packet) struct entry *e; LIST_FOREACH(e, &hash_table[hash], bucket_links) { - if (data_eq(*e->req_packet, *req_packet)) + if (data_eq(e->req_packet, *req_packet)) return e; } return NULL; @@ -175,7 +175,7 @@ kdc_check_lookaside(krb5_data *req_packet, krb5_data **reply_packet_out) e->num_hits++; hits++; - return (krb5_copy_data(kdc_context, e->reply_packet, + return (krb5_copy_data(kdc_context, &e->reply_packet, reply_packet_out) == 0); } @@ -196,12 +196,14 @@ kdc_insert_lookaside(krb5_data *req_packet, krb5_data *reply_packet) if (e == NULL) return; e->timein = timenow; - if (krb5_copy_data(kdc_context, req_packet, &e->req_packet)) { + if (krb5int_copy_data_contents(kdc_context, req_packet, &e->req_packet)) { free(e); return; } - if (krb5_copy_data(kdc_context, reply_packet, &e->reply_packet)) { - krb5_free_data(kdc_context, e->req_packet); + if (reply_packet != NULL && + krb5int_copy_data_contents(kdc_context, reply_packet, + &e->reply_packet)) { + krb5_free_data_contents(kdc_context, &e->req_packet); free(e); return; } |