Author: dylan
Date: 2005-11-22 11:50:24 -0500 (Tue, 22 Nov 2005)
New Revision: 932
Modified:
trunk/
trunk/perl/server/lib/Haver/Server/Talker.pm
Log:
[EMAIL PROTECTED]: dylan | 2005-11-22 11:50:22 -0500
Added support for as-yet-not-specified S: WARN.
Syntax:
S: WARN $type $count @extra
Where $type is the type of warning, and $count is the number of that $type of
warning this client has received.
Currently Haver::Server only has one warning: "empty"
After some threshold (typically 3, but this is configurable by the server
admin)
the server will disconnect the client with 'S: BYE warned $type'.
A properly behaving client should never receive WARN.
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/havercurs-objc:43089
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk:11166
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk-merge-10131:11178
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/winch/trunk:43192
27e50396-46e3-0310-8b22-ae223a1f35ce:/local:212
e9404bb1-7af0-0310-a7ff-e22194cd388b:/haver/local:1569
edfcd8bd-4ce7-0310-a97e-bb1efd40edf3:/local:238
+ 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/havercurs-objc:43089
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk:11166
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk-merge-10131:11178
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/winch/trunk:43192
27e50396-46e3-0310-8b22-ae223a1f35ce:/local:212
e9404bb1-7af0-0310-a7ff-e22194cd388b:/haver/local:1597
edfcd8bd-4ce7-0310-a97e-bb1efd40edf3:/local:238
Modified: trunk/perl/server/lib/Haver/Server/Talker.pm
===================================================================
--- trunk/perl/server/lib/Haver/Server/Talker.pm 2005-11-20 04:30:01 UTC
(rev 931)
+++ trunk/perl/server/lib/Haver/Server/Talker.pm 2005-11-22 16:50:24 UTC
(rev 932)
@@ -78,10 +78,13 @@
sub input {
my ($kernel, $heap, $args, $session) = @_[KERNEL, HEAP, ARG0, SESSION];
- my @copy = @$args;
return if $heap->{plonk};
return if $heap->{shutdown};
-
+
+ unless (@$args) {
+ call('warn', 'empty');
+ return;
+ }
my $cmd = shift @$args;
my $event = 'msg_' . $cmd;
@@ -97,7 +100,17 @@
$heap->{client}->put(['FAIL', $heap->{cmd}, $err, @args]);
}
+sub warn {
+ my ($kernel, $heap, $type) = @_[KERNEL, HEAP, ARG0];
+ if ($heap->{warnings}{$type} >= 3) {
+ call('shutdown', 'warned', $type, $heap->{warnings}{$type});
+ } else {
+ $heap->{client}->put(['WARN', $type]);
+ }
+ $heap->{warnings}{$type}++;
+}
+
sub error {
my ($kernel, $heap, $operation, $errnum, $errstr) = @_[KERNEL, HEAP,
ARG0..ARG3];
my @why;
@@ -128,6 +141,9 @@
Log('info', "Shutting down talker for $heap->{address}:$heap->{port}");
$heap->{shutdown} = 1;
+ # XXX dylan remrks XXX
+ # I wish I remembered why I decided that if @why is populated, we wait
for a flush event,
+ # and if it isn't, we immediantly close the connection...
if (@why) {
if ($heap->{user}) {
my $user = delete $heap->{user};