mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
VFS: use mc_timer for timestamps.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
a94dd7d2de
commit
9581c263b2
@ -63,7 +63,6 @@
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#include <sys/time.h> /* gettimeofday() */
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -71,6 +70,7 @@
|
||||
|
||||
#include "lib/tty/tty.h" /* enable/disable interrupt key */
|
||||
#include "lib/util.h" /* custom_canonicalize_pathname() */
|
||||
#include "lib/timer.h"
|
||||
#if 0
|
||||
#include "lib/widget.h" /* message() */
|
||||
#endif
|
||||
@ -863,7 +863,7 @@ vfs_s_free (vfsid id)
|
||||
static int
|
||||
vfs_s_dir_uptodate (struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
{
|
||||
struct timeval tim;
|
||||
guint64 tim;
|
||||
|
||||
if (me->flush)
|
||||
{
|
||||
@ -871,9 +871,9 @@ vfs_s_dir_uptodate (struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
return 0;
|
||||
}
|
||||
|
||||
gettimeofday (&tim, NULL);
|
||||
tim = mc_timer_elapsed (mc_global.timer);
|
||||
|
||||
return (tim.tv_sec < ino->timestamp.tv_sec ? 1 : 0);
|
||||
return (tim < ino->timestamp ? 1 : 0);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -91,7 +91,7 @@ struct vfs_s_inode
|
||||
struct stat st; /* Parameters of this inode */
|
||||
char *linkname; /* Symlink's contents */
|
||||
char *localname; /* Filename of local file, if we have one */
|
||||
struct timeval timestamp; /* Subclass specific */
|
||||
guint64 timestamp; /* Subclass specific */
|
||||
off_t data_offset; /* Subclass specific */
|
||||
};
|
||||
|
||||
|
@ -54,7 +54,6 @@
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <sys/time.h> /* gettimeofday() */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h> /* uintmax_t */
|
||||
@ -66,6 +65,7 @@
|
||||
#include "lib/fileloc.h"
|
||||
#include "lib/util.h" /* my_exit() */
|
||||
#include "lib/mcconfig.h"
|
||||
#include "lib/timer.h"
|
||||
|
||||
#include "src/execute.h" /* pre_exec, post_exec */
|
||||
|
||||
@ -766,8 +766,7 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
|
||||
vfs_print_message (_("fish: Reading directory %s..."), remote_path);
|
||||
|
||||
gettimeofday (&dir->timestamp, NULL);
|
||||
dir->timestamp.tv_sec += fish_directory_timeout;
|
||||
dir->timestamp = mc_timer_elapsed (mc_global.timer) + fish_directory_timeout * G_USEC_PER_SEC;
|
||||
|
||||
quoted_path = strutils_shell_escape (remote_path);
|
||||
(void) fish_command_v (me, super, NONE, FISH_SUPER (super)->scr_ls, "FISH_FILENAME=%s;\n",
|
||||
|
@ -91,13 +91,14 @@ What to do with this?
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/time.h> /* gettimeofday() */
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h> /* uintmax_t */
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/util.h"
|
||||
#include "lib/strutil.h" /* str_move() */
|
||||
#include "lib/mcconfig.h"
|
||||
#include "lib/timer.h"
|
||||
|
||||
#include "lib/tty/tty.h" /* enable/disable interrupt key */
|
||||
#include "lib/widget.h" /* message() */
|
||||
@ -181,7 +182,7 @@ gboolean ftpfs_ignore_chattr_errors = TRUE;
|
||||
second parameter to ftpfs_changetype. */
|
||||
#define TYPE_UNKNOWN -1
|
||||
|
||||
#define ABORT_TIMEOUT 5
|
||||
#define ABORT_TIMEOUT (5 * G_USEC_PER_SEC)
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
#ifndef HAVE_SOCKLEN_T
|
||||
@ -1490,17 +1491,19 @@ ftpfs_linear_abort (struct vfs_class *me, vfs_file_handler_t * fh)
|
||||
|
||||
if (select (dsock + 1, &mask, NULL, NULL, NULL) > 0)
|
||||
{
|
||||
struct timeval start_tim;
|
||||
guint64 start_tim;
|
||||
char buf[BUF_8K];
|
||||
|
||||
gettimeofday (&start_tim, NULL);
|
||||
start_tim = mc_timer_elapsed (mc_global.timer);
|
||||
|
||||
/* flush the remaining data */
|
||||
while (read (dsock, buf, sizeof (buf)) > 0)
|
||||
{
|
||||
struct timeval tim;
|
||||
guint64 tim;
|
||||
|
||||
gettimeofday (&tim, NULL);
|
||||
if (tim.tv_sec > start_tim.tv_sec + ABORT_TIMEOUT)
|
||||
tim = mc_timer_elapsed (mc_global.timer);
|
||||
|
||||
if (tim > start_tim + ABORT_TIMEOUT)
|
||||
{
|
||||
/* server keeps sending, drop the connection and ftpfs_reconnect */
|
||||
close (dsock);
|
||||
@ -1745,8 +1748,7 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path
|
||||
return (-1);
|
||||
}
|
||||
|
||||
gettimeofday (&dir->timestamp, NULL);
|
||||
dir->timestamp.tv_sec += ftpfs_directory_timeout;
|
||||
dir->timestamp = mc_timer_elapsed (mc_global.timer) + ftpfs_directory_timeout * G_USEC_PER_SEC;
|
||||
|
||||
if (ftp_super->strict == RFC_STRICT)
|
||||
sock = ftpfs_open_data_connection (me, super, "LIST", 0, TYPE_ASCII, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user