disk-end-of-atomic.c 797 Bytes
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * end-of-atomic.c
 *
 * This is the magic function which is called at the end of every atomic
 * call to the server. It is responisble for
 *	Free:ing all tmp_alloc:ated memory
 *	Throw out some cached data if necessary
 *	Forget some old texts if necessary
 *	Save some items to disk if saving
 *
 * idle is TRUE if the server has no pending calls. That might be a good time
 * to forget old texts.
 */

#include <kom-types.h>
#include "smalloc.h"
#include "text-garb.h"
#include "config.h"
#include "disk-cache.h"
20
#include "cache.h"
Per Cederqvist's avatar
Per Cederqvist committed
21
22
23
24
25
26
27

long
end_of_atomic( Bool  idle )
{
    int timeout = TIMEOUT;

    free_tmp();
28
    cache_limit_size();
Per Cederqvist's avatar
Per Cederqvist committed
29
30
31
32
33
34
35
36
37
38

    if ( idle )
	if ( garb_text() == FALSE )
	    timeout = GARBTIMEOUT;

    if ( sync_part() == FALSE )
	timeout = SYNCTIMEOUT;

    return timeout;
}