1. put some extra checks and balances in to message send routine in Msg.pm to
authordjk <djk>
Wed, 3 May 2000 13:34:18 +0000 (13:34 +0000)
committerdjk <djk>
Wed, 3 May 2000 13:34:18 +0000 (13:34 +0000)
see if I can prevent the error seen by Arnold (which I think is only likely to
appear in heavily loaded sites).

Changes
perl/Msg.pm

diff --git a/Changes b/Changes
index 5b9060d0197a4016248e8a334b10ff72e6b9ac4e..c56dfd4c454f2d1dd735803a2f7ec8e2ad96fcb1 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,7 @@
+30Apr00=======================================================================
+1. put some extra checks and balances in to message send routine in Msg.pm to
+see if I can prevent the error seen by Arnold (which I think is only likely to
+appear in heavily loaded sites).
 25Apr00=======================================================================
 1. Changed reply so that you can reply to more than one address privately
 31Mar00=======================================================================
index 9df7640ecbbfbfecd5a80493469a5abacb1700f5..33a0af80786bab83e44bf12b1bbc26324a1d1f97 100644 (file)
@@ -110,9 +110,11 @@ sub _send {
 
     while (@$rq) {
         my $msg            = $rq->[0];
-        my $bytes_to_write = length($msg) - $offset;
+               my $mlth           = length($msg);
+        my $bytes_to_write = $mlth - $offset;
         my $bytes_written  = 0;
-        while ($bytes_to_write) {
+               confess("Negative Length! msg: '$msg' lth: $mlth offset: $offset") if $bytes_to_write < 0;
+        while ($bytes_to_write > 0) {
             $bytes_written = syswrite ($sock, $msg,
                                        $bytes_to_write, $offset);
             if (!defined($bytes_written)) {
@@ -124,6 +126,7 @@ sub _send {
                     # be called back eventually, and will resume sending
                     return 1;
                 } else {    # Uh, oh
+                                       delete $conn->{send_offset};
                     $conn->handle_send_err($!);
                     return 0; # fail. Message remains in queue ..
                 }