[svn:parrot] r39742 - branches/io_cleanups/src/pmc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Tue Jun 23 15:07:45 UTC 2009


Author: whiteknight
Date: Tue Jun 23 15:07:43 2009
New Revision: 39742
URL: https://trac.parrot.org/parrot/changeset/39742

Log:
[io_cleanups] fix socket so it doesn't attempt to access it's Handle during destroy. This creates an order-of-destruction bug. Also, plug a leak where socket isn't freeing it's Parrot_Socket_attributes structure

Modified:
   branches/io_cleanups/src/pmc/filehandle.pmc
   branches/io_cleanups/src/pmc/handle.pmc
   branches/io_cleanups/src/pmc/socket.pmc

Modified: branches/io_cleanups/src/pmc/filehandle.pmc
==============================================================================
--- branches/io_cleanups/src/pmc/filehandle.pmc	Tue Jun 23 14:19:35 2009	(r39741)
+++ branches/io_cleanups/src/pmc/filehandle.pmc	Tue Jun 23 15:07:43 2009	(r39742)
@@ -119,8 +119,7 @@
     VTABLE void destroy() {
         if (PARROT_FILEHANDLE(SELF)) {
             Parrot_FileHandle_attributes *data_struct = PARROT_FILEHANDLE(SELF);
-
-            mem_sys_free(PARROT_FILEHANDLE(SELF));
+            mem_sys_free(data_struct);
             PMC_data(SELF) = NULL;
         }
     }

Modified: branches/io_cleanups/src/pmc/handle.pmc
==============================================================================
--- branches/io_cleanups/src/pmc/handle.pmc	Tue Jun 23 14:19:35 2009	(r39741)
+++ branches/io_cleanups/src/pmc/handle.pmc	Tue Jun 23 15:07:43 2009	(r39742)
@@ -62,9 +62,12 @@
                     Parrot_io_close_piohandle(INTERP, data_struct->os_handle);
             }
 
-            if (data_struct->buffer_start)
+            if (data_struct->buffer_start) {
                 mem_sys_free(data_struct->buffer_start);
+                data_struct->buffer_start = NULL;
+            }
             mem_sys_free(data_struct);
+            PMC_data(SELF) = NULL;
         }
     }
 }

Modified: branches/io_cleanups/src/pmc/socket.pmc
==============================================================================
--- branches/io_cleanups/src/pmc/socket.pmc	Tue Jun 23 14:19:35 2009	(r39741)
+++ branches/io_cleanups/src/pmc/socket.pmc	Tue Jun 23 15:07:43 2009	(r39742)
@@ -102,10 +102,8 @@
 
 */
     VTABLE void destroy() {
-        const PIOHANDLE os_handle = Parrot_io_get_os_handle(INTERP, SELF);
-        if (os_handle != PIO_INVALID_HANDLE)
-            Parrot_io_close_piohandle(interp, os_handle);
-        Parrot_io_set_os_handle(INTERP, SELF, PIO_INVALID_HANDLE);
+        if (PARROT_SOCKET(SELF))
+            mem_sys_free(PARROT_SOCKET(SELF));
     }
 
 /*


More information about the parrot-commits mailing list