line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Component::Client::TCP; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
608
|
use strict; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
416
|
|
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
47
|
use vars qw($VERSION); |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
516
|
|
6
|
|
|
|
|
|
|
$VERSION = '1.366'; # NOTE - Should be #.### (three decimal places) |
7
|
|
|
|
|
|
|
|
8
|
11
|
|
|
11
|
|
48
|
use Carp qw(carp croak); |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
576
|
|
9
|
11
|
|
|
11
|
|
45
|
use Errno qw(ETIMEDOUT ECONNRESET); |
|
11
|
|
|
|
|
11
|
|
|
11
|
|
|
|
|
433
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Explicit use to import the parameter constants; |
12
|
11
|
|
|
11
|
|
49
|
use POE::Session; |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
56
|
|
13
|
11
|
|
|
11
|
|
696
|
use POE::Driver::SysRW; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
190
|
|
14
|
11
|
|
|
11
|
|
758
|
use POE::Filter::Line; |
|
11
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
202
|
|
15
|
11
|
|
|
11
|
|
869
|
use POE::Wheel::ReadWrite; |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
185
|
|
16
|
11
|
|
|
11
|
|
1944
|
use POE::Wheel::SocketFactory; |
|
11
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
16527
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Create the client. This is just a handy way to encapsulate |
19
|
|
|
|
|
|
|
# POE::Session->create(). Because the states are so small, it uses |
20
|
|
|
|
|
|
|
# real inline coderefs. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
84
|
|
|
84
|
1
|
8802
|
my $type = shift; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Helper so we don't have to type it all day. $mi is a name I call |
26
|
|
|
|
|
|
|
# myself. |
27
|
84
|
|
|
|
|
140
|
my $mi = $type . '->new()'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# If they give us lemons, tell them to make their own damn |
30
|
|
|
|
|
|
|
# lemonade. |
31
|
84
|
100
|
|
|
|
384
|
croak "$mi requires an even number of parameters" if (@_ & 1); |
32
|
82
|
|
|
|
|
372
|
my %param = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Validate what we're given. |
35
|
82
|
100
|
|
|
|
393
|
croak "$mi needs a RemoteAddress parameter" |
36
|
|
|
|
|
|
|
unless exists $param{RemoteAddress}; |
37
|
80
|
100
|
|
|
|
339
|
croak "$mi needs a RemotePort parameter" |
38
|
|
|
|
|
|
|
unless exists $param{RemotePort}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Extract parameters. |
41
|
78
|
|
|
|
|
144
|
my $alias = delete $param{Alias}; |
42
|
78
|
|
|
|
|
104
|
my $address = delete $param{RemoteAddress}; |
43
|
78
|
|
|
|
|
93
|
my $port = delete $param{RemotePort}; |
44
|
78
|
|
|
|
|
75
|
my $domain = delete $param{Domain}; |
45
|
78
|
|
|
|
|
76
|
my $bind_address = delete $param{BindAddress}; |
46
|
78
|
|
|
|
|
80
|
my $bind_port = delete $param{BindPort}; |
47
|
78
|
|
|
|
|
88
|
my $ctimeout = delete $param{ConnectTimeout}; |
48
|
78
|
|
|
|
|
70
|
my $args = delete $param{Args}; |
49
|
78
|
|
|
|
|
77
|
my $session_type = delete $param{SessionType}; |
50
|
78
|
|
|
|
|
74
|
my $session_params = delete $param{SessionParams}; |
51
|
|
|
|
|
|
|
|
52
|
78
|
50
|
|
|
|
165
|
$args = [] unless defined $args; |
53
|
78
|
50
|
|
|
|
185
|
croak "Args must be an array reference" unless ref($args) eq "ARRAY"; |
54
|
|
|
|
|
|
|
|
55
|
78
|
|
|
|
|
130
|
foreach ( |
56
|
|
|
|
|
|
|
qw( |
57
|
|
|
|
|
|
|
PreConnect Connected ConnectError Disconnected ServerInput |
58
|
|
|
|
|
|
|
ServerError ServerFlushed Started |
59
|
|
|
|
|
|
|
ServerHigh ServerLow |
60
|
|
|
|
|
|
|
) |
61
|
|
|
|
|
|
|
) { |
62
|
780
|
50
|
66
|
|
|
2148
|
croak "$_ must be a coderef" if( |
63
|
|
|
|
|
|
|
defined($param{$_}) and ref($param{$_}) ne 'CODE' |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
78
|
|
|
|
|
107
|
my $high_mark_level = delete $param{HighMark}; |
68
|
78
|
|
|
|
|
77
|
my $low_mark_level = delete $param{LowMark}; |
69
|
78
|
|
|
|
|
82
|
my $high_event = delete $param{ServerHigh}; |
70
|
78
|
|
|
|
|
83
|
my $low_event = delete $param{ServerLow}; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# this is ugly, but now its elegant :) grep++ |
73
|
78
|
|
|
|
|
109
|
my $using_watermarks = grep { defined $_ } |
|
312
|
|
|
|
|
372
|
|
74
|
|
|
|
|
|
|
($high_mark_level, $low_mark_level, $high_event, $low_event); |
75
|
78
|
100
|
66
|
|
|
206
|
if ($using_watermarks > 0 and $using_watermarks != 4) { |
76
|
8
|
|
|
|
|
753
|
croak "If you use the Mark settings, you must define all four"; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
70
|
50
|
|
0
|
|
293
|
$high_event = sub { } unless defined $high_event; |
|
0
|
|
|
|
|
0
|
|
80
|
70
|
50
|
|
0
|
|
251
|
$low_event = sub { } unless defined $low_event; |
|
0
|
|
|
|
|
0
|
|
81
|
|
|
|
|
|
|
|
82
|
70
|
|
|
|
|
83
|
my $pre_conn_callback = delete $param{PreConnect}; |
83
|
70
|
|
|
|
|
98
|
my $conn_callback = delete $param{Connected}; |
84
|
70
|
|
|
|
|
88
|
my $conn_error_callback = delete $param{ConnectError}; |
85
|
70
|
|
|
|
|
86
|
my $disc_callback = delete $param{Disconnected}; |
86
|
70
|
|
|
|
|
87
|
my $input_callback = delete $param{ServerInput}; |
87
|
70
|
|
|
|
|
75
|
my $error_callback = delete $param{ServerError}; |
88
|
70
|
|
|
|
|
74
|
my $flush_callback = delete $param{ServerFlushed}; |
89
|
70
|
|
|
|
|
67
|
my $start_callback = delete $param{Started}; |
90
|
70
|
|
|
|
|
66
|
my $filter = delete $param{Filter}; |
91
|
|
|
|
|
|
|
# TODO should we have ServerInputFilter/ServerOutputFilter like Server-TCP does? |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Extra states. |
94
|
|
|
|
|
|
|
|
95
|
70
|
|
|
|
|
71
|
my $inline_states = delete $param{InlineStates}; |
96
|
70
|
100
|
|
|
|
138
|
$inline_states = {} unless defined $inline_states; |
97
|
|
|
|
|
|
|
|
98
|
70
|
|
|
|
|
70
|
my $package_states = delete $param{PackageStates}; |
99
|
70
|
100
|
|
|
|
118
|
$package_states = [] unless defined $package_states; |
100
|
|
|
|
|
|
|
|
101
|
70
|
|
|
|
|
68
|
my $object_states = delete $param{ObjectStates}; |
102
|
70
|
100
|
|
|
|
120
|
$object_states = [] unless defined $object_states; |
103
|
|
|
|
|
|
|
|
104
|
70
|
100
|
|
|
|
324
|
croak "InlineStates must be a hash reference" |
105
|
|
|
|
|
|
|
unless ref($inline_states) eq 'HASH'; |
106
|
|
|
|
|
|
|
|
107
|
68
|
100
|
|
|
|
321
|
croak "PackageStates must be a list or array reference" |
108
|
|
|
|
|
|
|
unless ref($package_states) eq 'ARRAY'; |
109
|
|
|
|
|
|
|
|
110
|
66
|
100
|
|
|
|
361
|
croak "ObjectStates must be a list or array reference" |
111
|
|
|
|
|
|
|
unless ref($object_states) eq 'ARRAY'; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# Errors. |
114
|
|
|
|
|
|
|
|
115
|
64
|
100
|
|
|
|
371
|
croak "$mi requires a ServerInput parameter" unless defined $input_callback; |
116
|
|
|
|
|
|
|
|
117
|
62
|
|
|
|
|
187
|
foreach (sort keys %param) { |
118
|
0
|
|
|
|
|
0
|
carp "$mi doesn't recognize \"$_\" as a parameter"; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# Defaults. |
122
|
|
|
|
|
|
|
|
123
|
62
|
50
|
|
|
|
136
|
$session_type = 'POE::Session' unless defined $session_type; |
124
|
62
|
100
|
66
|
|
|
157
|
if (defined($session_params) && ref($session_params)) { |
125
|
2
|
50
|
|
|
|
12
|
if (ref($session_params) ne 'ARRAY') { |
126
|
2
|
|
|
|
|
194
|
croak "SessionParams must be an array reference"; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
} else { |
129
|
60
|
|
|
|
|
74
|
$session_params = [ ]; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
60
|
50
|
|
|
|
99
|
$address = '127.0.0.1' unless defined $address; |
133
|
|
|
|
|
|
|
|
134
|
60
|
100
|
|
|
|
116
|
$conn_error_callback = \&_default_error unless defined $conn_error_callback; |
135
|
60
|
100
|
|
|
|
94
|
$error_callback = \&_default_io_error unless defined $error_callback; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# Spawn the session that makes the connection and then interacts |
138
|
|
|
|
|
|
|
# with what was connected to. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
return $session_type->create |
141
|
|
|
|
|
|
|
( @$session_params, |
142
|
|
|
|
|
|
|
inline_states => |
143
|
|
|
|
|
|
|
{ _start => sub { |
144
|
60
|
|
|
60
|
|
115
|
my ($kernel, $heap) = @_[KERNEL, HEAP]; |
145
|
60
|
|
|
|
|
132
|
$heap->{shutdown_on_error} = 1; |
146
|
60
|
100
|
|
|
|
169
|
$kernel->alias_set( $alias ) if defined $alias; |
147
|
60
|
|
|
|
|
154
|
$kernel->yield( 'reconnect' ); |
148
|
60
|
100
|
|
|
|
968
|
$start_callback and $start_callback->(@_); |
149
|
|
|
|
|
|
|
}, |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# To quiet ASSERT_STATES. |
152
|
60
|
|
|
60
|
|
162
|
_stop => sub { }, |
153
|
0
|
|
|
0
|
|
0
|
_child => sub { }, |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
reconnect => sub { |
156
|
60
|
|
|
60
|
|
111
|
my ($kernel, $heap) = @_[KERNEL, HEAP]; |
157
|
|
|
|
|
|
|
|
158
|
60
|
|
|
|
|
113
|
$heap->{shutdown} = 0; |
159
|
60
|
|
|
|
|
95
|
$heap->{connected} = 0; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Tentative patch to re-establish the alias upon reconnect. |
162
|
|
|
|
|
|
|
# Necessary because otherwise the alias goes away for good. |
163
|
|
|
|
|
|
|
# Unfortunately, there is a gap where the alias may not be |
164
|
|
|
|
|
|
|
# set, and any events dispatched then will be dropped. |
165
|
60
|
100
|
|
|
|
169
|
$kernel->alias_set( $alias ) if defined $alias; |
166
|
|
|
|
|
|
|
|
167
|
60
|
|
|
|
|
354
|
$heap->{server} = POE::Wheel::SocketFactory->new |
168
|
|
|
|
|
|
|
( RemoteAddress => $address, |
169
|
|
|
|
|
|
|
RemotePort => $port, |
170
|
|
|
|
|
|
|
SocketDomain => $domain, |
171
|
|
|
|
|
|
|
BindAddress => $bind_address, |
172
|
|
|
|
|
|
|
BindPort => $bind_port, |
173
|
|
|
|
|
|
|
SuccessEvent => 'got_connect_success', |
174
|
|
|
|
|
|
|
FailureEvent => 'got_connect_error', |
175
|
|
|
|
|
|
|
); |
176
|
60
|
50
|
|
|
|
132
|
$_[KERNEL]->alarm_remove( delete $heap->{ctimeout_id} ) |
177
|
|
|
|
|
|
|
if exists $heap->{ctimeout_id}; |
178
|
60
|
100
|
|
|
|
233
|
$heap->{ctimeout_id} = $_[KERNEL]->alarm_set |
179
|
|
|
|
|
|
|
( got_connect_timeout => time + $ctimeout |
180
|
|
|
|
|
|
|
) if defined $ctimeout; |
181
|
|
|
|
|
|
|
}, |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
connect => sub { |
184
|
0
|
|
|
0
|
|
0
|
my ($new_address, $new_port) = @_[ARG0, ARG1]; |
185
|
0
|
0
|
|
|
|
0
|
$address = $new_address if defined $new_address; |
186
|
0
|
0
|
|
|
|
0
|
$port = $new_port if defined $new_port; |
187
|
0
|
|
|
|
|
0
|
$_[KERNEL]->yield("reconnect"); |
188
|
|
|
|
|
|
|
}, |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
got_connect_success => sub { |
191
|
58
|
|
|
58
|
|
112
|
my ($kernel, $heap, $socket) = @_[KERNEL, HEAP, ARG0]; |
192
|
|
|
|
|
|
|
|
193
|
58
|
100
|
|
|
|
175
|
$kernel->alarm_remove( delete $heap->{ctimeout_id} ) |
194
|
|
|
|
|
|
|
if exists $heap->{ctimeout_id}; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# Pre-connected callback. |
197
|
58
|
100
|
|
|
|
100
|
if ($pre_conn_callback) { |
198
|
2
|
50
|
|
|
|
9
|
unless ($socket = $pre_conn_callback->(@_)) { |
199
|
0
|
|
|
|
|
0
|
$heap->{connected} = 0; |
200
|
|
|
|
|
|
|
# TODO - Error callback? Disconnected callback? |
201
|
0
|
|
|
|
|
0
|
return; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# Ok to overwrite like this as of 0.13. |
206
|
58
|
50
|
|
|
|
1456
|
$_[HEAP]->{server} = POE::Wheel::ReadWrite->new |
207
|
|
|
|
|
|
|
( Handle => $socket, |
208
|
|
|
|
|
|
|
Driver => POE::Driver::SysRW->new(), |
209
|
|
|
|
|
|
|
Filter => _get_filter($filter), |
210
|
|
|
|
|
|
|
InputEvent => 'got_server_input', |
211
|
|
|
|
|
|
|
ErrorEvent => 'got_server_error', |
212
|
|
|
|
|
|
|
FlushedEvent => 'got_server_flush', |
213
|
|
|
|
|
|
|
( |
214
|
|
|
|
|
|
|
$using_watermarks |
215
|
|
|
|
|
|
|
? ( |
216
|
|
|
|
|
|
|
HighMark => $high_mark_level, |
217
|
|
|
|
|
|
|
HighEvent => 'got_high', |
218
|
|
|
|
|
|
|
LowMark => $low_mark_level, |
219
|
|
|
|
|
|
|
LowEvent => 'got_low', |
220
|
|
|
|
|
|
|
) |
221
|
|
|
|
|
|
|
: () |
222
|
|
|
|
|
|
|
) |
223
|
|
|
|
|
|
|
); |
224
|
|
|
|
|
|
|
|
225
|
58
|
|
|
|
|
240
|
$heap->{connected} = 1; |
226
|
58
|
100
|
|
|
|
295
|
$conn_callback and $conn_callback->(@_); |
227
|
|
|
|
|
|
|
}, |
228
|
|
|
|
|
|
|
got_high => $high_event, |
229
|
|
|
|
|
|
|
got_low => $low_event, |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
got_connect_error => sub { |
232
|
2
|
|
|
2
|
|
5
|
my $heap = $_[HEAP]; |
233
|
2
|
50
|
|
|
|
7
|
$_[KERNEL]->alarm_remove( delete $heap->{ctimeout_id} ) |
234
|
|
|
|
|
|
|
if exists $heap->{ctimeout_id}; |
235
|
2
|
|
|
|
|
4
|
$heap->{connected} = 0; |
236
|
2
|
|
|
|
|
9
|
$conn_error_callback->(@_); |
237
|
2
|
|
|
|
|
1434
|
delete $heap->{server}; |
238
|
|
|
|
|
|
|
}, |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
got_connect_timeout => sub { |
241
|
0
|
|
|
0
|
|
0
|
my $heap = $_[HEAP]; |
242
|
0
|
|
|
|
|
0
|
$heap->{connected} = 0; |
243
|
0
|
0
|
|
|
|
0
|
$_[KERNEL]->alarm_remove( delete $heap->{ctimeout_id} ) |
244
|
|
|
|
|
|
|
if exists $heap->{ctimeout_id}; |
245
|
0
|
|
|
|
|
0
|
$! = ETIMEDOUT; |
246
|
0
|
|
|
|
|
0
|
@_[ARG0,ARG1,ARG2] = ('connect', $!+0, $!); |
247
|
0
|
|
|
|
|
0
|
$conn_error_callback->(@_); |
248
|
0
|
|
|
|
|
0
|
delete $heap->{server}; |
249
|
|
|
|
|
|
|
}, |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
got_server_error => sub { |
252
|
18
|
|
|
18
|
|
74
|
$error_callback->(@_); |
253
|
18
|
50
|
|
|
|
1269
|
if ($_[HEAP]->{shutdown_on_error}) { |
254
|
18
|
|
|
|
|
64
|
$_[KERNEL]->yield("shutdown"); |
255
|
18
|
|
|
|
|
69
|
$_[HEAP]->{got_an_error} = 1; |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
}, |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
got_server_input => sub { |
260
|
58
|
|
|
58
|
|
90
|
my $heap = $_[HEAP]; |
261
|
58
|
50
|
|
|
|
158
|
return if $heap->{shutdown}; |
262
|
58
|
|
|
|
|
205
|
$input_callback->(@_); |
263
|
|
|
|
|
|
|
}, |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
got_server_flush => sub { |
266
|
60
|
|
|
60
|
|
72
|
my $heap = $_[HEAP]; |
267
|
60
|
100
|
|
|
|
235
|
$flush_callback and $flush_callback->(@_); |
268
|
60
|
100
|
|
|
|
1720
|
if ($heap->{shutdown}) { |
269
|
4
|
|
|
|
|
14
|
delete $heap->{server}; |
270
|
4
|
50
|
|
|
|
20
|
$disc_callback and $disc_callback->(@_); |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
}, |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
shutdown => sub { |
275
|
69
|
|
|
69
|
|
179
|
my ($kernel, $heap) = @_[KERNEL, HEAP]; |
276
|
69
|
|
|
|
|
132
|
$heap->{shutdown} = 1; |
277
|
|
|
|
|
|
|
|
278
|
69
|
50
|
|
|
|
192
|
$kernel->alarm_remove( delete $heap->{ctimeout_id} ) |
279
|
|
|
|
|
|
|
if exists $heap->{ctimeout_id}; |
280
|
|
|
|
|
|
|
|
281
|
69
|
100
|
|
|
|
156
|
if ($heap->{connected}) { |
282
|
58
|
|
|
|
|
71
|
$heap->{connected} = 0; |
283
|
58
|
50
|
|
|
|
133
|
if (defined $heap->{server}) { |
284
|
58
|
100
|
100
|
|
|
246
|
if ( |
285
|
|
|
|
|
|
|
$heap->{got_an_error} or |
286
|
|
|
|
|
|
|
not $heap->{server}->get_driver_out_octets() |
287
|
|
|
|
|
|
|
) { |
288
|
54
|
|
|
|
|
219
|
delete $heap->{server}; |
289
|
54
|
100
|
|
|
|
272
|
$disc_callback and $disc_callback->(@_); |
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
else { |
294
|
11
|
|
|
|
|
21
|
delete $heap->{server}; |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
69
|
100
|
|
|
|
362
|
$kernel->alias_remove($alias) if defined $alias; |
298
|
|
|
|
|
|
|
}, |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
# User supplied states. |
301
|
60
|
|
|
|
|
1834
|
%$inline_states, |
302
|
|
|
|
|
|
|
}, |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
# User arguments. |
305
|
|
|
|
|
|
|
args => $args, |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
# User supplied states. |
308
|
|
|
|
|
|
|
package_states => $package_states, |
309
|
|
|
|
|
|
|
object_states => $object_states, |
310
|
|
|
|
|
|
|
)->ID; |
311
|
|
|
|
|
|
|
} |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
sub _get_filter { |
314
|
58
|
|
|
58
|
|
98
|
my $filter = shift; |
315
|
58
|
100
|
|
|
|
213
|
if (ref $filter eq 'ARRAY') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
316
|
2
|
|
|
|
|
11
|
my @filter_args = @$filter; |
317
|
2
|
|
|
|
|
4
|
$filter = shift @filter_args; |
318
|
2
|
|
|
|
|
11
|
return $filter->new(@filter_args); |
319
|
|
|
|
|
|
|
} elsif (ref $filter) { |
320
|
0
|
|
|
|
|
0
|
return $filter->clone(); |
321
|
|
|
|
|
|
|
} elsif (!defined($filter)) { |
322
|
56
|
|
|
|
|
183
|
return POE::Filter::Line->new(); |
323
|
|
|
|
|
|
|
} else { |
324
|
0
|
|
|
|
|
|
return $filter->new(); |
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
# The default error handler logs to STDERR and shuts down the socket. |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
sub _default_error { |
331
|
0
|
0
|
0
|
0
|
|
|
unless ($_[ARG0] eq "read" and ($_[ARG1] == 0 or $_[ARG1] == ECONNRESET)) { |
|
|
|
0
|
|
|
|
|
332
|
0
|
|
|
|
|
|
warn( |
333
|
|
|
|
|
|
|
'Client ', $_[SESSION]->ID, " got $_[ARG0] error $_[ARG1] ($_[ARG2])\n" |
334
|
|
|
|
|
|
|
); |
335
|
|
|
|
|
|
|
} |
336
|
0
|
|
|
|
|
|
delete $_[HEAP]->{server}; |
337
|
|
|
|
|
|
|
} |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
sub _default_io_error { |
340
|
0
|
|
|
0
|
|
|
my ($syscall, $errno, $error) = @_[ARG0..ARG2]; |
341
|
0
|
0
|
|
|
|
|
$error = "Normal disconnection" unless $errno; |
342
|
0
|
|
|
|
|
|
warn('Client ', $_[SESSION]->ID, " got $syscall error $errno ($error)\n"); |
343
|
0
|
|
|
|
|
|
$_[KERNEL]->yield("shutdown"); |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
1; |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
__END__ |