From a55e100b563637c6bb574471529756151be0bb83 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sat, 6 Oct 2007 21:45:24 -0400 Subject: [PATCH] Fixed send_cache_status() sending the wrong total. --- src/commands.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/commands.c b/src/commands.c index 2bc5c2cd..c5838e83 100644 --- a/src/commands.c +++ b/src/commands.c @@ -148,7 +148,7 @@ gint open_file(const gchar *filename, struct stat *st) return fd; } -static void cleanup(struct client_s *client) +static void cleanup_client(struct client_s *client) { assuan_context_t ctx = client->ctx; @@ -320,7 +320,7 @@ static int open_command(assuan_context_t ctx, char *line) } if (client->state == STATE_OPEN) - cleanup(client); + cleanup_client(client); MUTEX_LOCK; client->freed = FALSE; @@ -328,7 +328,7 @@ static int open_command(assuan_context_t ctx, char *line) if ((gcryerrno = gcry_cipher_open(&client->gh, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC, 0))) { g_strfreev(req); log_write("%s(%i): %s", __FUNCTION__, __LINE__, gcry_strerror(gcryerrno)); - cleanup(client); + cleanup_client(client); return send_error(ctx, gcryerrno); } @@ -336,7 +336,7 @@ static int open_command(assuan_context_t ctx, char *line) if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode)) { log_write("%s: %s", filename, pwmd_strerror(EPWMD_INVALID_FILENAME)); g_strfreev(req); - cleanup(client); + cleanup_client(client); return send_error(ctx, EPWMD_INVALID_FILENAME); } @@ -353,14 +353,14 @@ static int open_command(assuan_context_t ctx, char *line) error = errno; log_write("%s: %s", filename, strerror(errno)); g_strfreev(req); - cleanup(client); + cleanup_client(client); return send_syserror(ctx, error); } new_doc: if ((client->xml = new_document()) == NULL) { log_write("%s", strerror(ENOMEM)); g_strfreev(req); - cleanup(client); + cleanup_client(client); return send_syserror(ctx, ENOMEM); } @@ -372,7 +372,7 @@ new_doc: if (cache_add_file(client->md5file, NULL) == FALSE) { log_write("%s(%i): %s", __FILE__, __LINE__, pwmd_strerror(EPWMD_MAX_SLOTS)); g_strfreev(req); - cleanup(client); + cleanup_client(client); return send_error(ctx, EPWMD_MAX_SLOTS); } @@ -381,7 +381,7 @@ new_doc: if (!client->filename) { g_strfreev(req); - cleanup(client); + cleanup_client(client); log_write("%s(%i): %s", __FILE__, __LINE__, strerror(ENOMEM)); return send_syserror(ctx, ENOMEM); } @@ -399,7 +399,7 @@ new_doc: error = errno; log_write("%s: %s", filename, strerror(errno)); g_strfreev(req); - cleanup(client); + cleanup_client(client); return send_syserror(ctx, error); } @@ -415,7 +415,7 @@ new_doc: if (!req[1] || !*req[1]) { close(fd); g_strfreev(req); - cleanup(client); + cleanup_client(client); return send_error(ctx, EPWMD_KEY); } } @@ -431,7 +431,7 @@ new_doc: close(fd); memset(shakey, 0, sizeof(shakey)); g_strfreev(req); - cleanup(client); + cleanup_client(client); return send_error(ctx, error); } @@ -442,7 +442,7 @@ new_doc: memset(shakey, 0, sizeof(shakey)); log_write("%s(%i): %s", __FILE__, __LINE__, strerror(ENOMEM)); g_strfreev(req); - cleanup(client); + cleanup_client(client); return send_syserror(ctx, ENOMEM); } @@ -452,7 +452,7 @@ update_cache: memset(shakey, 0, sizeof(shakey)); log_write("%s(%i): %s", __FILE__, __LINE__, pwmd_strerror(EPWMD_MAX_SLOTS)); g_strfreev(req); - cleanup(client); + cleanup_client(client); return send_error(ctx, EPWMD_MAX_SLOTS); } @@ -2090,11 +2090,13 @@ static int iscached_command(assuan_context_t ctx, char *line) void send_cache_status(assuan_context_t ctx) { - char *tmp; + gchar *tmp; + gint i = MUTEX_OFFSET; MUTEX_LOCK; - tmp = print_fmt("%li %li", - cache_file_count(), cache_size / sizeof(file_cache_t) - cache_file_count()); + tmp = print_fmt("%i %i", + cache_file_count(), + (i / sizeof(file_cache_t)) - cache_file_count()); MUTEX_UNLOCK; if (ctx) @@ -2126,7 +2128,6 @@ static int clearcache_command(assuan_context_t ctx, char *line) static int cachetimeout_command(assuan_context_t ctx, char *line) { guchar md5file[16]; - MUTEX_UNLOCK; glong timeout; gchar **req = split_input_line(line, " ", 0); gchar *p; @@ -2206,7 +2207,7 @@ void cleanup_assuan(assuan_context_t ctx) { struct client_s *cl = assuan_get_pointer(ctx); - cleanup(cl); + cleanup_client(cl); } gpg_error_t register_commands(assuan_context_t ctx) -- 2.11.4.GIT