Noticed in apache error logs (see below). If the length of the message is longer...
authorSam Reed <reedy@users.mediawiki.org>
Fri, 16 Sep 2011 20:08:33 +0000 (20:08 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Fri, 16 Sep 2011 20:08:33 +0000 (20:08 +0000)
Sep 16 20:07:28 10.0.2.193 apache2[28441]: PHP Warning:  socket_sendto() [<a href='function.socket-sendto'>function.socket-sendto</a>]: unable to write to socket [90]: Message too long in /home/wikipedia/common/php-1.17-test/includes/GlobalFunctions.php on line 464
Sep 16 20:07:29 10.0.2.193 apache2[26511]: PHP Warning:  socket_sendto() [<a href='function.socket-sendto'>function.socket-sendto</a>]: unable to write to socket [90]: Message too long in /home/wikipedia/common/php-1.17-test/includes/GlobalFunctions.php on line 464

includes/GlobalFunctions.php

index 33cff2c..13fe67f 100644 (file)
@@ -867,7 +867,14 @@ function wfErrorLog( $text, $file ) {
                if ( !$sock ) {
                        return;
                }
-               socket_sendto( $sock, $text, strlen( $text ), 0, $host, $port );
+
+               $len = strlen( $text );
+               $maxLen = socket_get_option( $sock, SOL_UDP, SO_SNDBUF );
+
+               if ( $len > $maxLen ) {
+                       $len = $maxLen - 1;
+               }
+               socket_sendto( $sock, $text, $len, 0, $host, $port );
                socket_close( $sock );
        } else {
                wfSuppressWarnings();