[svn:parrot] r39681 - in branches/io_cleanups/src: io pmc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sat Jun 20 21:16:43 UTC 2009


Author: whiteknight
Date: Sat Jun 20 21:16:42 2009
New Revision: 39681
URL: https://trac.parrot.org/parrot/changeset/39681

Log:
[io_cleanups] add socket to the list of types that can be handled by Parrot_io_close

Modified:
   branches/io_cleanups/src/io/api.c
   branches/io_cleanups/src/pmc/socket.pmc

Modified: branches/io_cleanups/src/io/api.c
==============================================================================
--- branches/io_cleanups/src/io/api.c	Sat Jun 20 20:58:30 2009	(r39680)
+++ branches/io_cleanups/src/io/api.c	Sat Jun 20 21:16:42 2009	(r39681)
@@ -32,6 +32,7 @@
 #include "api.str"
 #include "../pmc/pmc_filehandle.h"
 #include "../pmc/pmc_stringhandle.h"
+#include "../pmc/pmc_socket.h"
 
 #include <stdarg.h>
 
@@ -216,6 +217,14 @@
     }
     else if (pmc->vtable->base_type == enum_class_StringHandle)
         SETATTR_StringHandle_read_offset(interp, pmc, 0);
+    else if (pmc->vtable->base_type == enum_class_Socket)
+    {
+        PIOHANDLE os_handle;
+        GETATTR_Socket_os_handle(interp, pmc, os_handle);
+        if (os_handle != PIO_INVALID_HANDLE)
+            result = Parrot_io_close_piohandle(interp, os_handle);
+        SETATTR_Socket_os_handle(interp, pmc, PIO_INVALID_HANDLE);
+    }
     else
         Parrot_PCCINVOKE(interp, pmc, CONST_STRING(interp, "close"), "->I", &result);
 

Modified: branches/io_cleanups/src/pmc/socket.pmc
==============================================================================
--- branches/io_cleanups/src/pmc/socket.pmc	Sat Jun 20 20:58:30 2009	(r39680)
+++ branches/io_cleanups/src/pmc/socket.pmc	Sat Jun 20 21:16:42 2009	(r39681)
@@ -206,13 +206,8 @@
 
     METHOD close() {
         INTVAL result = -1;
-        if (PARROT_SOCKET(SELF)) {
-            Parrot_Socket_attributes *data_struct = PARROT_SOCKET(SELF);
-
-            if (data_struct->os_handle != PIO_INVALID_HANDLE)
-                result = Parrot_io_close_piohandle(interp, data_struct->os_handle);
-            data_struct->os_handle = PIO_INVALID_HANDLE;
-        }
+        if (PARROT_SOCKET(pmc))
+            result = Parrot_io_close(INTERP, SELF);
         RETURN(INTVAL result);
     }
 


More information about the parrot-commits mailing list