Exemplo n.º 1
0
void poststat(int mytype)
{
	get_top(mytype);
	writestat(mytype);
	if(mytype==0)
		backup_top();
	gen_hot_subjects_xml(mytype);
	if(mytype==0)
		gen_secs_hot_subjects_xml(mytype);

	if(mytype==0)
		log_top();
}
Exemplo n.º 2
0
void poststat(int mytype)
{
#ifdef REDIS     //KBS 统计十大失败时,不更新十大数据
    if (get_top(mytype) == 0)
		return;
#else
    get_top(mytype);
#endif /* REDIS */
    writestat(mytype);
    if (mytype==0)
        backup_top();
    gen_hot_subjects_xml(mytype);
    if (mytype==0)
        gen_secs_hot_subjects_xml(mytype);

    if (mytype==0)
        log_top();
}
Exemplo n.º 3
0
static void *
thr_main (void *arg)
{
    int self_index = (int) arg;

    while (process_flag)
    {
        if (work_msg[self_index].filename == NULL)
        {
            SLEEP_MILISEC (0, 100);
        }
        else
        {
            log_top (work_msg[self_index].fp, work_msg[self_index].filename);
            fclose (work_msg[self_index].fp);
            work_msg[self_index].fp = NULL;
            work_msg[self_index].filename = NULL;
        }
    }
    return NULL;
}
Exemplo n.º 4
0
static int
log_top_query (int argc, char *argv[], int arg_start)
{
    FILE *fp;
    char *filename;
    int i;
#ifdef MT_MODE
    T_THREAD thrid;
    int j;
#endif

#ifdef MT_MODE
    query_info_mutex_init ();
#endif

#ifdef MT_MODE
    work_msg = MALLOC (sizeof (T_WORK_MSG) * num_thread);
    if (work_msg == NULL)
    {
        fprintf (stderr, "malloc error\n");
        return -1;
    }
    memset (work_msg, 0, sizeof (T_WORK_MSG *) * num_thread);

    for (i = 0; i < num_thread; i++)
        THREAD_BEGIN (thrid, thr_main, (void *) i);
#endif

    for (i = arg_start; i < argc; i++)
    {
        filename = argv[i];
        fprintf (stdout, "%s\n", filename);

        fp = fopen (filename, "r");
        if (fp == NULL)
        {
            fprintf (stderr, "%s[%s]\n", strerror (errno), filename);
#ifdef MT_MODE
            process_flag = 0;
#endif
            return -1;
        }

#ifdef MT_MODE
        while (1)
        {
            for (j = 0; j < num_thread; j++)
            {
                if (work_msg[j].filename == NULL)
                {
                    work_msg[j].fp = fp;
                    work_msg[j].filename = filename;
                    break;
                }
            }
            if (j == num_thread)
                SLEEP_MILISEC (1, 0);
            else
                break;
        }
#else
        log_top (fp, filename);
        fclose (fp);
#endif
    }

#ifdef MT_MODE
    process_flag = 0;
#endif

    if (sql_info_file != NULL)
    {
        fprintf (stdout, "read sql info file...\n");
        if (sql_list_make (sql_info_file) < 0)
        {
            return -1;
        }
    }

    fprintf (stdout, "print results...\n");
    query_info_print ();

    return 0;
}