changeset 1512:bd36920f32d4

don't bother to save expired cookies
author corvid <corvid@lavabit.com>
date Tue, 12 Jan 2010 00:27:14 +0000
parents df7b789ea491
children caf2d219c769
files dpi/cookies.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dpi/cookies.c	Mon Jan 11 21:52:49 2010 +0100
+++ b/dpi/cookies.c	Tue Jan 12 00:27:14 2010 +0000
@@ -343,6 +343,7 @@
    int i, fd;
    CookieNode *node;
    CookieData_t *cookie;
+   time_t now;
 
 #ifndef HAVE_LOCKF
    struct flock lck;
@@ -351,6 +352,8 @@
    if (disabled)
       return;
 
+   now = time(NULL);
+
    rewind(file_stream);
    fd = fileno(file_stream);
    if (ftruncate(fd, 0) == -1)
@@ -360,7 +363,7 @@
    /* Iterate cookies per domain, saving and freeing */
    while ((node = dList_nth_data(cookies, 0))) {
       for (i = 0; (cookie = dList_nth_data(node->dlist, i)); ++i) {
-         if (!cookie->session_only) {
+         if (!cookie->session_only && (cookie->expires_at > now)) {
             fprintf(file_stream, "%s\tTRUE\t%s\t%s\t%ld\t%s\t%s\n",
                     cookie->domain,
                     cookie->path,