mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-22 03:02:06 +03:00
Revert "VFS GC: use mc_timer."
This reverts commit f21f27c5ae
to fix an unexpected segfaults.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
3b997974ec
commit
28cdea55cd
29
lib/vfs/gc.c
29
lib/vfs/gc.c
@ -39,11 +39,12 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h> /* For atol() */
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h> /* gettimeofday() */
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/event.h"
|
||||
#include "lib/timer.h"
|
||||
|
||||
#include "vfs.h"
|
||||
#include "utilvfs.h"
|
||||
@ -97,7 +98,7 @@ struct vfs_stamping
|
||||
{
|
||||
struct vfs_class *v;
|
||||
vfsid id;
|
||||
guint64 time;
|
||||
struct timeval time;
|
||||
};
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
@ -108,6 +109,16 @@ static GSList *stamps = NULL;
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/** Compare two timeval structures. Return 0 is t1 is less than t2. */
|
||||
static inline int
|
||||
timeoutcmp (const struct timeval *t1, const struct timeval *t2)
|
||||
{
|
||||
return ((t1->tv_sec < t2->tv_sec)
|
||||
|| ((t1->tv_sec == t2->tv_sec) && (t1->tv_usec <= t2->tv_usec)));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static gint
|
||||
vfs_stamp_compare (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
@ -137,7 +148,7 @@ vfs_stamp_expire (gpointer data, gpointer user_data)
|
||||
{
|
||||
struct vfs_stamping *stamp = VFS_STAMPING (data);
|
||||
|
||||
if (user_data == NULL || stamp->time <= *(guint64 *) user_data)
|
||||
if (user_data == NULL || timeoutcmp (&(stamp->time), (struct timeval *) user_data) != 0)
|
||||
{
|
||||
vfs_stamp_free (data, NULL);
|
||||
vfs_rmstamp (stamp->v, stamp->id);
|
||||
@ -156,7 +167,7 @@ vfs_addstamp (struct vfs_class *v, vfsid id)
|
||||
stamp = g_new (struct vfs_stamping, 1);
|
||||
stamp->v = v;
|
||||
stamp->id = id;
|
||||
stamp->time = mc_timer_elapsed (mc_global.timer);
|
||||
gettimeofday (&(stamp->time), NULL);
|
||||
|
||||
stamps = g_slist_append (stamps, stamp);
|
||||
}
|
||||
@ -179,7 +190,7 @@ vfs_stamp (struct vfs_class *v, vfsid id)
|
||||
stamp = g_slist_find_custom (stamps, &what, vfs_stamp_compare);
|
||||
if (stamp != NULL)
|
||||
{
|
||||
VFS_STAMPING (stamp->data)->time = mc_timer_elapsed (mc_global.timer);
|
||||
gettimeofday (&(VFS_STAMPING (stamp->data)->time), NULL);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
@ -277,9 +288,11 @@ vfs_expire (gboolean now)
|
||||
g_slist_foreach (stamps, vfs_stamp_expire, NULL);
|
||||
else
|
||||
{
|
||||
guint64 lc_time;
|
||||
struct timeval lc_time;
|
||||
|
||||
gettimeofday (&lc_time, NULL);
|
||||
lc_time.tv_sec -= vfs_timeout;
|
||||
|
||||
lc_time = mc_timer_elapsed (mc_global.timer) - vfs_timeout * G_USEC_PER_SEC;
|
||||
g_slist_foreach (stamps, vfs_stamp_expire, &lc_time);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user