Skip to content

Commit

Permalink
Moving close() from Socket to Handle
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandobrito committed Nov 30, 2010
1 parent e844c4c commit 0428783
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
13 changes: 11 additions & 2 deletions src/io/api.c
Expand Up @@ -198,8 +198,7 @@ Parrot_io_fdopen(PARROT_INTERP, ARGIN_NULLOK(PMC *pmc), PIOHANDLE fd,
=item C<INTVAL Parrot_io_close(PARROT_INTERP, PMC *pmc)>
Closes the filehandle object. Calls the C<close> method on the filehandle
PMC object.
Closes the handle object.
=cut
Expand All @@ -219,6 +218,16 @@ Parrot_io_close(PARROT_INTERP, ARGMOD_NULLOK(PMC *pmc))
result = Parrot_io_close_filehandle(interp, pmc);
SETATTR_FileHandle_flags(interp, pmc, 0);
}
else if (pmc->vtable->base_type == enum_class_Socket) {
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;
}
}
else
Parrot_pcc_invoke_method_from_c_args(interp, pmc, CONST_STRING(interp, "close"), "->I", &result);

Expand Down
22 changes: 0 additions & 22 deletions src/pmc/socket.pmc
Expand Up @@ -198,28 +198,6 @@ connected socket object.]

/*

=item C<close()>

Close a socket.

=cut

*/

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;
}
RETURN(INTVAL result);
}

/*

=item C<recv()>

Receives a message from a connected socket object. It returns
Expand Down

0 comments on commit 0428783

Please sign in to comment.