Beispiel #1
0
void watch_folder()
{
    while(1)
    {

        //printf("########## add_new_watch_item is %d ##########\n",add_new_watch_item);

        //if( pathlist.number > 0 && add_new_watch_item == 1)
        //if( pathlist.number > 0)
        if(allfolderlist->next != NULL)
        {
            //printf("#########restart inotifystart,keep_running is %d ###########\n");
#ifdef MYDEBUG
            printf("#########inotifystart watch_folder###########\n");
#endif
            //keep_running = 0;
            inotifyStart();
            /*if(!exit_loop)
            {
                pthread_mutex_lock(&mutex);
                keep_running = 1;
                pthread_mutex_unlock(&mutex);
            }*/
        }

        sleep(1);
        //if(keep_running == 0)
        //pthread_exit(0);

    }
}
Beispiel #2
0
void watch_folder()
{
    while(!exit_loop)
    {
        if(allfolderlist->next != NULL)
        {
#ifdef MYDEBUG
            printf("#########inotifystart watch_folder###########\n");
#endif
            inotifyStart();
        }
		sleep(1);
    }
}
Beispiel #3
0
void watch_folder()
{
    while(1)
    {

        if( pathlist.number > 0 && add_new_watch_item == 1)
        {
             //printf("restart inotifystart\n");
             keep_running = 0;
             inotifyStart();
        }

        sleep(1);
        //if(keep_running == 0)
            //pthread_exit(0);

    }
}
Beispiel #4
0
int inotifyStart()
{
    int inotify_fd;
    int i;
    //Folders allfolderlist;

    keep_running = 1;
    need_restart_inotify = 0;
    add_new_watch_item = 0;

    /* First we open the inotify dev entry */
    inotify_fd = open_inotify_fd ();
    if (inotify_fd > 0)
    {

        queue_t q;
        q = queue_create (128);

        int wd;

        wd = 0;

        memset(&allfolderlist,0,sizeof(Folders));

        //printf("list num is %d\n",pathlist.number);

        for( i = 0 ; i < pathlist.number; i++)
        {
            //printf("list is %s\n",pathlist.folderlist[i].name);
            get_all_folders(pathlist.folderlist[i].name,&allfolderlist,allfolderlist.number);
        }

       //for( i = 0 ; i < number; i++)uploadFile


        //strcpy(allfolderlist.folderlist[0].name,dirname);
        //allfolderlist.number = 1;



        printf("\n");
        for( i = 0; (i<allfolderlist.number) && (wd >= 0);i++)
        {
            wd = watch_dir (inotify_fd, allfolderlist.folderlist[i].name, IN_ALL_EVENTS);
            //printf("minitor path is %s\n",allfolderlist.folderlist[i].name);
        }

        if (wd > 0)
        {

            process_inotify_events (q, inotify_fd);
        }
        printf ("\nTerminating\n");
        close_inotify_fd (inotify_fd);
        queue_destroy (q);

        if(need_restart_inotify == 1)
            inotifyStart();
    }
    return 0;
}