[svn:parrot] r39261 - in branches/io_rewiring: include/parrot src/io src/pmc
Infinoid at svn.parrot.org
Infinoid at svn.parrot.org
Sat May 30 12:58:53 UTC 2009
Author: Infinoid
Date: Sat May 30 12:58:52 2009
New Revision: 39261
URL: https://trac.parrot.org/parrot/changeset/39261
Log:
[io] Create an abstract close_piohandle() function in the main I/O API, so the various PMCs' destroy() vtables can call that directly.
(This needs an implementation on win32; I've only handled unix so far.)
Modified:
branches/io_rewiring/include/parrot/io.h
branches/io_rewiring/include/parrot/io_unix.h
branches/io_rewiring/include/parrot/io_win32.h
branches/io_rewiring/src/io/api.c
branches/io_rewiring/src/io/unix.c
branches/io_rewiring/src/pmc/socket.pmc
Modified: branches/io_rewiring/include/parrot/io.h
==============================================================================
--- branches/io_rewiring/include/parrot/io.h Sat May 30 10:32:06 2009 (r39260)
+++ branches/io_rewiring/include/parrot/io.h Sat May 30 12:58:52 2009 (r39261)
@@ -150,6 +150,10 @@
FUNC_MODIFIES(*pmc);
PARROT_EXPORT
+INTVAL Parrot_io_close_piohandle(PARROT_INTERP, PIOHANDLE handle)
+ __attribute__nonnull__(1);
+
+PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
INTVAL Parrot_io_eof(PARROT_INTERP, ARGMOD(PMC *pmc))
__attribute__nonnull__(1)
@@ -352,6 +356,8 @@
#define ASSERT_ARGS_Parrot_io_close __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc)
+#define ASSERT_ARGS_Parrot_io_close_piohandle __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_io_eof __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc)
Modified: branches/io_rewiring/include/parrot/io_unix.h
==============================================================================
--- branches/io_rewiring/include/parrot/io_unix.h Sat May 30 10:32:06 2009 (r39260)
+++ branches/io_rewiring/include/parrot/io_unix.h Sat May 30 12:58:52 2009 (r39261)
@@ -28,6 +28,7 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*filehandle);
+INTVAL Parrot_io_close_piohandle_unix(SHIM_INTERP, PIOHANDLE handle);
INTVAL Parrot_io_close_unix(PARROT_INTERP, ARGMOD(PMC *filehandle))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
@@ -114,6 +115,8 @@
#define ASSERT_ARGS_Parrot_io_async_unix __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(filehandle)
+#define ASSERT_ARGS_Parrot_io_close_piohandle_unix \
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
#define ASSERT_ARGS_Parrot_io_close_unix __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(filehandle)
@@ -269,6 +272,7 @@
#define PIO_OPEN_PIPE(interp, pmc, file, flags) \
Parrot_io_open_pipe_unix((interp), (pmc), (file), (flags))
#define PIO_CLOSE(interp, pmc) Parrot_io_close_unix((interp), (pmc))
+#define PIO_CLOSE_PIOHANDLE(interp, handle) Parrot_io_close_piohandle_unix((interp), (handle))
#define PIO_IS_CLOSED(interp, pmc) Parrot_io_is_closed_unix((interp), (pmc))
#define PIO_READ(interp, pmc, buf) Parrot_io_read_unix((interp), (pmc), (buf))
#define PIO_WRITE(interp, pmc, str) Parrot_io_write_unix((interp), (pmc), (str))
Modified: branches/io_rewiring/include/parrot/io_win32.h
==============================================================================
--- branches/io_rewiring/include/parrot/io_win32.h Sat May 30 10:32:06 2009 (r39260)
+++ branches/io_rewiring/include/parrot/io_win32.h Sat May 30 12:58:52 2009 (r39261)
@@ -251,6 +251,7 @@
#define PIO_OPEN_PIPE(interp, pmc, file, flags) \
Parrot_io_open_pipe_win32((interp), (pmc), (file), (flags))
#define PIO_CLOSE(interp, pmc) Parrot_io_close_win32((interp), (pmc))
+#define PIO_CLOSE_PIOHANDLE(interp, handle) Parrot_io_close_piohandle_win32((interp), (handle))
#define PIO_IS_CLOSED(interp, pmc) Parrot_io_is_closed_win32((interp), (pmc))
#define PIO_READ(interp, pmc, buf) Parrot_io_read_win32((interp), (pmc), (buf))
#define PIO_WRITE(interp, pmc, str) Parrot_io_write_win32((interp), (pmc), (str))
Modified: branches/io_rewiring/src/io/api.c
==============================================================================
--- branches/io_rewiring/src/io/api.c Sat May 30 10:32:06 2009 (r39260)
+++ branches/io_rewiring/src/io/api.c Sat May 30 12:58:52 2009 (r39261)
@@ -221,6 +221,27 @@
return result;
}
+
+/*
+
+=item C<INTVAL Parrot_io_close_piohandle(PARROT_INTERP, PIOHANDLE handle)>
+
+Calls close() on the given PIOHANDLE. This is the low level OS-specific close()
+function, intended to be called directly by PMC destroy() vtables.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+INTVAL
+Parrot_io_close_piohandle(PARROT_INTERP, PIOHANDLE handle)
+{
+ ASSERT_ARGS(Parrot_io_close_piohandle)
+ return PIO_CLOSE_PIOHANDLE(interp, handle);
+}
+
+
/*
=item C<INTVAL Parrot_io_is_closed(PARROT_INTERP, PMC *pmc)>
Modified: branches/io_rewiring/src/io/unix.c
==============================================================================
--- branches/io_rewiring/src/io/unix.c Sat May 30 10:32:06 2009 (r39260)
+++ branches/io_rewiring/src/io/unix.c Sat May 30 12:58:52 2009 (r39261)
@@ -357,6 +357,24 @@
return result;
}
+
+/*
+
+=item C<INTVAL Parrot_io_close_piohandle_unix(PARROT_INTERP, PIOHANDLE handle)>
+
+Closes the given file descriptor. Returns 0 on success, -1 on error.
+
+=cut
+
+*/
+
+INTVAL
+Parrot_io_close_piohandle_unix(SHIM_INTERP, PIOHANDLE handle)
+{
+ ASSERT_ARGS(Parrot_io_close_piohandle_unix)
+ return close(handle);
+}
+
/*
=item C<INTVAL Parrot_io_is_closed_unix(PARROT_INTERP, PMC *filehandle)>
Modified: branches/io_rewiring/src/pmc/socket.pmc
==============================================================================
--- branches/io_rewiring/src/pmc/socket.pmc Sat May 30 10:32:06 2009 (r39260)
+++ branches/io_rewiring/src/pmc/socket.pmc Sat May 30 12:58:52 2009 (r39261)
@@ -115,7 +115,9 @@
if (PARROT_SOCKET(SELF)) {
Parrot_Socket_attributes *data_struct = PARROT_SOCKET(SELF);
- /* TODO Shutdown socket */
+ if(data_struct->os_handle != PIO_INVALID_HANDLE)
+ Parrot_io_close_piohandle(interp, data_struct->os_handle);
+ data_struct->os_handle = PIO_INVALID_HANDLE;
}
}
More information about the parrot-commits
mailing list