Enlightenment CVS committal

Author  : lordchaos
Project : e17
Module  : apps/evfs

Dir     : e17/apps/evfs/src/plugins


Modified Files:
        evfs_fs_posix.c 


Log Message:
Posix file plugin: don't allow multiple monitors of the same object per client

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/plugins/evfs_fs_posix.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- evfs_fs_posix.c     19 Aug 2005 12:15:12 -0000      1.5
+++ evfs_fs_posix.c     19 Aug 2005 22:41:59 -0000      1.6
@@ -119,6 +119,21 @@
        
 }
 
+/*This is potentially inefficient with a lot of clients monitoring the same 
dir/file*/
+int client_already_monitoring(evfs_client* client, Ecore_List* mon_list) {
+       evfs_file_monitor* mon;
+       ecore_list_goto_first(mon_list);
+
+       while ( (mon = ecore_list_next(mon_list))) {
+               if (mon->client == client) {
+                       return 1;
+               }
+       }
+
+       return 0;
+       
+}
+
 int posix_monitor_add(evfs_client* client, evfs_command* command) {
        Ecore_List* mon_list = ecore_hash_get(posix_monitor_hash, 
command->file_command.files[0]->path);
        evfs_file_monitor* mon;
@@ -138,14 +153,19 @@
 
                ecore_list_append(mon_list,mon);
        } else {
-               /*We assume there is something already in the list.  This is 
probably bad*/
-               ecore_list_goto_first(mon_list);
-               old = ecore_list_current(mon_list);
-
-               /*Make sure we have the ecore ref, so the last monitor can nuke 
it*/
-               mon->em = old->em;
+               if (!client_already_monitoring(client, mon_list)) {
+                       /*We assume there is something already in the list.  
This is probably bad a bad assumption*/
+                       ecore_list_goto_first(mon_list);
+                       old = ecore_list_current(mon_list);
+
+                       /*Make sure we have the ecore ref, so the last monitor 
can nuke it*/
+                       mon->em = old->em;
+                       ecore_list_append(mon_list, mon);
+               } else {
+                       printf ("Oi, dufus, you're already monitoring this 
object\n");
+               }
+               
                
-               ecore_list_append(mon_list, mon);
        }
 
        return 0;




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to