Author: dick
Date: 2005-04-29 09:17:48 -0400 (Fri, 29 Apr 2005)
New Revision: 43787

Modified:
   trunk/mono/mono/handles/hps.c
   trunk/mono/mono/io-layer/ChangeLog
   trunk/mono/mono/io-layer/processes.c
   trunk/mono/mono/io-layer/sockets.c
Log:

2005-04-29  Dick Porter  <[EMAIL PROTECTED]>

        * processes.c (EnumProcesses): Use a GArray instead of a GPtrArray
        now it's storing pids not handles, also fixes memory leak caused
        by unclear glib documentation.

        * sockets.c (WSACleanup): Remove unused variable




Modified: trunk/mono/mono/handles/hps.c
===================================================================
--- trunk/mono/mono/handles/hps.c       2005-04-29 12:39:43 UTC (rev 43786)
+++ trunk/mono/mono/handles/hps.c       2005-04-29 13:17:48 UTC (rev 43787)
@@ -103,7 +103,7 @@
                
                file_share = &_wapi_fileshare_layout->share_info[i];
                if (file_share->handle_refs > 0) {
-                       g_print ("dev: 0x%llx ino: %lld share: 0x%x access: 
0x%x refs: %d\n", file_share->device, file_share->inode, file_share->sharemode, 
file_share->access, file_share->handle_refs);
+                       g_print ("dev: 0x%llx ino: %lld open pid: %d share: 
0x%x access: 0x%x refs: %d\n", file_share->device, file_share->inode, 
file_share->opened_by_pid, file_share->sharemode, file_share->access, 
file_share->handle_refs);
                }
        }
        

Modified: trunk/mono/mono/io-layer/ChangeLog
===================================================================
--- trunk/mono/mono/io-layer/ChangeLog  2005-04-29 12:39:43 UTC (rev 43786)
+++ trunk/mono/mono/io-layer/ChangeLog  2005-04-29 13:17:48 UTC (rev 43787)
@@ -1,5 +1,13 @@
 2005-04-29  Dick Porter  <[EMAIL PROTECTED]>
 
+       * processes.c (EnumProcesses): Use a GArray instead of a GPtrArray
+       now it's storing pids not handles, also fixes memory leak caused
+       by unclear glib documentation.
+
+       * sockets.c (WSACleanup): Remove unused variable
+
+2005-04-29  Dick Porter  <[EMAIL PROTECTED]>
+
        * handles.c (_wapi_handle_check_share_by_pid): For systems that
        don't have file descriptor info in /proc check that the original
        opener of a file is still there, if a share violation would

Modified: trunk/mono/mono/io-layer/processes.c
===================================================================
--- trunk/mono/mono/io-layer/processes.c        2005-04-29 12:39:43 UTC (rev 
43786)
+++ trunk/mono/mono/io-layer/processes.c        2005-04-29 13:17:48 UTC (rev 
43787)
@@ -803,8 +803,9 @@
 
 static gboolean process_enum (gpointer handle, gpointer user_data)
 {
-       GPtrArray *processes=user_data;
+       GArray *processes=user_data;
        pid_t pid = signal_process_if_gone (handle);
+       int i;
        
        if (pid == 0) {
                return (FALSE);
@@ -820,9 +821,16 @@
                 * the comment above _wapi_search_handle () for why
                 * it's needed
                 */
-               g_ptr_array_remove (processes, GUINT_TO_POINTER(pid));
+               for (i = 0; i < processes->len; i++) {
+                       if (g_array_index (processes, pid_t, i) == pid) {
+                               /* We've already got this one, return
+                                * FALSE to keep searching
+                                */
+                               return (FALSE);
+                       }
+               }
                
-               g_ptr_array_add (processes, GUINT_TO_POINTER(pid));
+               g_array_append_val (processes, pid);
        }
        
        /* Return false to keep searching */
@@ -831,7 +839,7 @@
 
 gboolean EnumProcesses (guint32 *pids, guint32 len, guint32 *needed)
 {
-       GPtrArray *processes=g_ptr_array_new ();
+       GArray *processes = g_array_new (FALSE, FALSE, sizeof(pid_t));
        guint32 fit, i, j;
        
        mono_once (&process_current_once, process_set_current);
@@ -841,10 +849,10 @@
        
        fit=len/sizeof(guint32);
        for (i = 0, j = 0; j < fit && i < processes->len; i++) {
-               pids[j++] = GPOINTER_TO_UINT(g_ptr_array_index (processes, i));
+               pids[j++] = g_array_index (processes, pid_t, i);
        }
 
-       g_ptr_array_free (processes, FALSE);
+       g_array_free (processes, TRUE);
        
        *needed = j * sizeof(guint32);
        

Modified: trunk/mono/mono/io-layer/sockets.c
===================================================================
--- trunk/mono/mono/io-layer/sockets.c  2005-04-29 12:39:43 UTC (rev 43786)
+++ trunk/mono/mono/io-layer/sockets.c  2005-04-29 13:17:48 UTC (rev 43787)
@@ -122,8 +122,6 @@
 
 int WSACleanup(void)
 {
-       guint32 i;
-       
 #ifdef DEBUG
        g_message ("%s: cleaning up", __func__);
 #endif

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to