Subject: | [PATCH] Use open() to obtain a filehandle for a socket |
Despite being a cleaner solution, PerlIO_fdopen did not write a writable
filehandle on Perl 5.14 for some reason.
Subject: | 0001-Use-open-to-obtain-a-filehandle-for-a-socket.patch |
From b0e37d8e3fe89221805cce5a07f26a945c476c46 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Sun, 20 Nov 2011 18:16:23 +0100
Subject: [PATCH 1/2] Use open() to obtain a filehandle for a socket
Despite being a cleaner solution, PerlIO_fdopen did not write a writable
filehandle on Perl 5.14 for some reason.
---
BlueZ.xs | 11 -----------
Bluetooth.pm | 5 ++---
MSWin.xs | 11 -----------
3 files changed, 2 insertions(+), 25 deletions(-)
diff --git a/BlueZ.xs b/BlueZ.xs
index f4ed554..3eee2db 100644
--- a/BlueZ.xs
+++ b/BlueZ.xs
@@ -132,17 +132,6 @@ _close(sock)
PPCODE:
close(sock);
-InOutStream
-_perlfh(fd)
- int fd
- CODE:
- InOutStream fh = PerlIO_fdopen(fd, "r+");
- RETVAL = fh;
-
- OUTPUT:
- RETVAL
-
-
unsigned int
_use_service_handle()
CODE:
diff --git a/Bluetooth.pm b/Bluetooth.pm
index f0bbf61..9945eda 100644
--- a/Bluetooth.pm
+++ b/Bluetooth.pm
@@ -118,9 +118,8 @@ my $self = shift;
sub perlfh {
my $self = shift;
-
- *SOCK = _perlfh($self->{SOCK_FD});
- return *SOCK;
+ open (my $fh, '+<&=', $self->{SOCK_FD});
+ return $fh;
}
diff --git a/MSWin.xs b/MSWin.xs
index 7d7f7e1..5d4c897 100644
--- a/MSWin.xs
+++ b/MSWin.xs
@@ -141,17 +141,6 @@ _deinit()
WSACleanup();
-InOutStream
-_perlfh(fd)
- int fd
- CODE:
- InOutStream fh = PerlIO_fdopen(fd, "r+");
- RETVAL = fh;
-
- OUTPUT:
- RETVAL
-
-
void
_close(sock)
int sock
--
1.7.1