ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.192 by root, Wed Sep 3 10:36:25 2008 UTC vs.
Revision 1.200 by root, Sun Jan 4 10:22:19 2009 UTC

10 10
11=over 4 11=over 4
12 12
13=cut 13=cut
14 14
15package Deliantra::Client; # work around CPAN breakage
16package App::Deliantra; # try to reserve namespace
17package DC; 15package DC;
18 16
19use Carp (); 17use Carp ();
20 18
21our $VERSION; 19our $VERSION;
22 20
23BEGIN { 21BEGIN {
24 $VERSION = '0.9975'; 22 $VERSION = '2.02';
25 23
26 use XSLoader; 24 use XSLoader;
27 XSLoader::load "Deliantra::Client", $VERSION; 25 XSLoader::load "Deliantra::Client", $VERSION;
28} 26}
29 27
30use utf8; 28use utf8;
31use strict qw(vars subs); 29use strict qw(vars subs);
32 30
31use Socket ();
33use AnyEvent (); 32use AnyEvent ();
33use AnyEvent::Util ();
34use Pod::POM (); 34use Pod::POM ();
35use File::Path (); 35use File::Path ();
36use Storable (); # finally 36use Storable (); # finally
37use Fcntl (); 37use Fcntl ();
38use JSON::XS qw(encode_json decode_json); 38use JSON::XS qw(encode_json decode_json);
69 s/</&lt;/g; 69 s/</&lt;/g;
70 70
71 $_ 71 $_
72} 72}
73 73
74sub socketpipe() {
75 socketpair my $fh1, my $fh2, Socket::AF_UNIX, Socket::SOCK_STREAM, Socket::PF_UNSPEC
76 or die "cannot establish bidirectional pipe: $!\n";
77
78 ($fh1, $fh2)
79}
80
81sub background(&;&) { 74sub background(&;&) {
82 my ($bg, $cb) = @_; 75 my ($bg, $cb) = @_;
83 76
84 my ($fh_r, $fh_w) = DC::socketpipe; 77 my ($fh_r, $fh_w) = AnyEvent::Util::portable_socketpair
78 or die "unable to create background socketpair: $!";
85 79
86 my $pid = fork; 80 my $pid = fork;
87 81
88 if (defined $pid && !$pid) { 82 if (defined $pid && !$pid) {
89 local $SIG{__DIE__}; 83 local $SIG{__DIE__};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines