Pass parameter got_sigterm by reference
This commit is contained in:
parent
eb23829117
commit
c599280cf1
@ -1,6 +1,10 @@
|
||||
ChangeLog for davfs2
|
||||
--------------------
|
||||
|
||||
2014-06-20 Werner Baumann (werner.baumann@onlinehome.de)
|
||||
* cache.c, cache.h, mount_davfs.c:
|
||||
Pass parameter got_sigterm by reference.
|
||||
|
||||
2014-06-19 Werner Baumann (werner.baumann@onlinehome.de)
|
||||
* Mount_davfs.c, main:
|
||||
Only log error if still is mounted.
|
||||
|
@ -22,7 +22,7 @@
|
||||
de:de/davfs2.conf.5 add_de:de/davfs2.conf.5.translator \
|
||||
es:es/davfs2.conf.5 \
|
||||
opt_de:"-L UTF-8 -A UTF-8" \
|
||||
opt_es:"-k 74 -L UTF-8"
|
||||
opt_es:"-k 70 -L UTF-8"
|
||||
|
||||
[type:man] mount.davfs.8 \
|
||||
de:de/mount.davfs.8 add_de:de/mount.davfs.8.translator \
|
||||
|
16
src/cache.c
16
src/cache.c
@ -265,7 +265,7 @@ static void
|
||||
backup_node(dav_node *orig);
|
||||
|
||||
static void
|
||||
clean_tree(dav_node *node, int upload);
|
||||
clean_tree(dav_node *node, volatile int *got_sigterm);
|
||||
|
||||
static void
|
||||
delete_node(dav_node *node);
|
||||
@ -684,14 +684,14 @@ dav_init_cache(const dav_args *args, const char *mpoint)
|
||||
|
||||
|
||||
void
|
||||
dav_close_cache(int got_sigterm)
|
||||
dav_close_cache(volatile int *got_sigterm)
|
||||
{
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "Closing cache");
|
||||
|
||||
write_dir_entry = &write_dir_entry_dummy;
|
||||
|
||||
clean_tree(root, !got_sigterm);
|
||||
clean_tree(root, got_sigterm);
|
||||
|
||||
char *new_index = xasprintf("%s/%s.new",cache_dir, DAV_INDEX);
|
||||
if (debug)
|
||||
@ -1616,7 +1616,7 @@ backup_node(dav_node *orig)
|
||||
|
||||
|
||||
/* Scans the directory tree starting from node and
|
||||
- if upload == 1: saves dirty files to the server and unlocks them.
|
||||
- if *got_sigterm == 1: saves dirty files to the server and unlocks them.
|
||||
If it can not be safed, a local backup is created and the node is deleted.
|
||||
- removes any file nodes without cached file
|
||||
- removes all dir nodes that have not at least one file node below.
|
||||
@ -1627,7 +1627,7 @@ backup_node(dav_node *orig)
|
||||
Kernel will *not* be notified about changes.
|
||||
Member nref of directories will be adjusted. */
|
||||
static void
|
||||
clean_tree(dav_node *node, int upload)
|
||||
clean_tree(dav_node *node, volatile int *got_sigterm)
|
||||
{
|
||||
if (node == backup) {
|
||||
delete_cache_file(backup);
|
||||
@ -1639,7 +1639,7 @@ clean_tree(dav_node *node, int upload)
|
||||
dav_node *child = node->childs;
|
||||
while (child) {
|
||||
dav_node *next = child->next;
|
||||
clean_tree(child, upload);
|
||||
clean_tree(child, got_sigterm);
|
||||
child = next;
|
||||
}
|
||||
if (!node->childs && node != root && node != backup) {
|
||||
@ -1652,13 +1652,13 @@ clean_tree(dav_node *node, int upload)
|
||||
|
||||
} else if (!is_cached(node) || access(node->cache_path, F_OK) != 0) {
|
||||
|
||||
if (is_locked(node) && upload)
|
||||
if (is_locked(node) && !*got_sigterm)
|
||||
dav_unlock(node->path, &node->lock_expire);
|
||||
remove_from_tree(node);
|
||||
remove_from_table(node);
|
||||
delete_node(node);
|
||||
|
||||
} else if ((is_dirty(node) || is_created(node)) && upload) {
|
||||
} else if ((is_dirty(node) || is_created(node)) && !*got_sigterm) {
|
||||
|
||||
int ret = dav_put(node->path, node->cache_path,
|
||||
&node->remote_exists, &node->lock_expire,
|
||||
|
@ -192,10 +192,10 @@ dav_init_cache(const dav_args *args, const char *mpoint);
|
||||
a local backup file is created. All local copies of files and the necessary
|
||||
directories are stored in the permanent cache. A new index file of the
|
||||
permanent cache is created.
|
||||
If got_sigterm is 1, dirty files will not be stored back to the server.
|
||||
If *got_sigterm is 1, dirty files will not be stored back to the server.
|
||||
Finally it frees all nodes. */
|
||||
void
|
||||
dav_close_cache(int got_sigterm);
|
||||
dav_close_cache(volatile int *got_sigterm);
|
||||
|
||||
|
||||
/* Registers the kernel_interface.
|
||||
|
@ -358,7 +358,7 @@ main(int argc, char *argv[])
|
||||
|
||||
if (debug)
|
||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "Closing");
|
||||
dav_close_cache(got_sigterm);
|
||||
dav_close_cache(&got_sigterm);
|
||||
dav_close_webdav();
|
||||
if (dav_is_mounted()) {
|
||||
char *prog = xasprintf("/bin/umount -il %s", mpoint);
|
||||
|
Loading…
Reference in New Issue
Block a user