/*
* Copyright (c) 2020 YuQing <384681@qq.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the Lesser GNU General Public License, version 3
* or later ("LGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see .
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "fastcommon/logger.h"
#include "fastcommon/shared_func.h"
#include "fastcommon/sched_thread.h"
#include "fastcommon/ini_file_reader.h"
#include "fastcommon/fast_mblock.h"
#include "fastcommon/sockopt.h"
#include "fastcommon/system_info.h"
#include "fastcommon/local_ip_func.h"
struct my_struct {
struct fast_mblock_man *mblock;
void *obj;
};
static int test_delay(void *args)
{
struct my_struct *my;
my = (struct my_struct *)args;
fast_mblock_free_object(my->mblock, my->obj);
return 0;
}
int main(int argc, char *argv[])
{
int64_t start_time;
int64_t end_time;
int64_t mem_size;
struct fast_mblock_man mblock1;
struct fast_mblock_man mblock2;
struct my_struct *objs;
void *obj1;
void *obj2;
int reclaim_target;
int reclaim_count;
int i;
int count;
pthread_t schedule_tid;
ScheduleArray scheduleArray;
ScheduleEntry scheduleEntries[1];
volatile bool continue_flag = true;
FastIFConfig if_configs[32];
struct fast_statfs stats[32];
char *path;
FastStatFS statfs;
start_time = get_current_time_ms();
srand(time(NULL));
log_init();
g_log_context.log_level = LOG_DEBUG;
load_local_host_ip_addrs();
print_local_host_ip_addrs();
printf("first_local_ip: %s\n", get_first_local_ip());
getifconfigs(if_configs, sizeof(if_configs) / sizeof(if_configs[0]), &count);
printf("ifconfig count: %d\n", count);
for (i=0; i %s %s %ld %ld %ld %ld %ld %ld %ld\n",
stats[i].f_mntfromname, stats[i].f_mntonname,
stats[i].f_fstypename, stats[i].f_type, stats[i].f_bsize,
stats[i].f_blocks, stats[i].f_bfree, stats[i].f_bavail,
stats[i].f_files, stats[i].f_ffree);
}
path = "/";
if (get_statfs_by_path(path, &statfs) == 0) {
printf("\ninput path: %s, %s => %s, type: %s, category: %s, "
"rotational: %d\n\n", path, statfs.f_mntfromname,
statfs.f_mntonname, statfs.f_fstypename,
get_device_type_caption(statfs.device_type),
is_rotational_device_by_path(path));
}
#if defined(OS_LINUX) || defined(OS_FREEBSD)
{
FastProcessInfo *processes;
struct fast_sysinfo info;
struct stat st;
get_processes(&processes, &count);
printf("process count: %d\n", count);
for (i=0; i