ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro-Mysql/Mysql.pm
(Generate patch)

Comparing Coro-Mysql/Mysql.pm (file contents):
Revision 1.2 by root, Sat May 30 06:58:22 2009 UTC vs.
Revision 1.3 by root, Mon Jun 1 12:03:21 2009 UTC

75 75
76sub readable { &Coro::Handle::FH::readable } 76sub readable { &Coro::Handle::FH::readable }
77sub writable { &Coro::Handle::FH::writable } 77sub writable { &Coro::Handle::FH::writable }
78 78
79BEGIN { 79BEGIN {
80 our $VERSION = '0.1'; 80 our $VERSION = '0.2';
81 81
82 require XSLoader; 82 require XSLoader;
83 XSLoader::load Coro::Mysql::, $VERSION; 83 XSLoader::load Coro::Mysql::, $VERSION;
84} 84}
85 85
89so it becomes compatible to Coro threads. 89so it becomes compatible to Coro threads.
90 90
91After that, it returns the patched handle - you should always use the 91After that, it returns the patched handle - you should always use the
92newly returned database handle. 92newly returned database handle.
93 93
94It is safe to call this function on any database handle, but it will only
95do anything to L<DBD::mysql> handles, others are returned unchanged.
96
94=cut 97=cut
95 98
96sub unblock { 99sub unblock {
97 my ($DBH) = @_; 100 my ($DBH) = @_;
98 my $sock = $DBH->{sock};
99 101
100 open my $fh, "+>&" . $DBH->{sockfd} 102 if ($DBH->{Driver}{Name} eq "mysql") {
101 or croak "Coro::Mysql unable to clone mysql fd"; 103 my $sock = $DBH->{sock};
102 104
103 $fh = Coro::Handle::unblock $fh; 105 open my $fh, "+>&" . $DBH->{sockfd}
106 or croak "Coro::Mysql unable to clone mysql fd";
104 107
108 $fh = Coro::Handle::unblock $fh;
109
105 _patch $sock, $DBH->{sockfd}, tied ${$fh}; 110 _patch $sock, $DBH->{sockfd}, tied ${$fh};
106 $DBH->{private_Coro_Mysql} = guard { 111 $DBH->{private_Coro_Mysql} = guard {
107 _unpatch $sock; 112 _unpatch $sock;
108 undef $fh; 113 undef $fh;
114 };
109 }; 115 }
110 116
111 $DBH 117 $DBH
112} 118}
113 119
1141; 1201;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines