User "Reedy" posted a comment on MediaWiki.r97328.
Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97328#c22999
Commit summary:
Noticed in apache error logs (see below). If the length of the message is
longer than the maximum length, only send what will fit
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
Comment:
Looking at the PHP documentation for this [1]
SO_SNDBUF is "Reports the size of the send buffer.", which seemingly is what we
want.
Reading it and the documentation would lead you to believe SOL_UDP is valid,
but does a poor job of listing other correct values
The constants [2] show SOL_DUP along with a huge host of other values.
SOCK_DGRAM would be correct for UDP, but pushing that as the middle parameter
to socket_get_option() gives "unable to retrieve socket option [95]"
It could be hardcoded at 64KB (65,536) using the length in bytes per Krinkle
above (rather thant he string length)... It just seems like there should be a
better way to do it
Having said that, I've just noticed above
<pre>
// Clean it up for the multiplexer
if ( strval( $prefix ) !== '' ) {
$text = preg_replace( '/^/m', $prefix . ' ', $text );
// Limit to 64KB
if ( strlen( $text ) > 65534 ) {
$text = substr( $text, 0, 65534 );
}
if ( substr( $text, -1 ) != "\n" ) {
$text .= "\n";
}
} elseif ( strlen( $text ) > 65535 ) {
$text = substr( $text, 0, 65535 );
}
</pre>
In theory, the larger packet condition shouldn't occur, bar, that is using
strlen also, not string byte length..
Removing the code I added, and then just changing both to do the length by the
byte length..
[1] http://php.net/manual/en/function.socket-get-option.php
[2] http://www.php.net/manual/en/sockets.constants.php
_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview