Public bug reported: Binary package hint: apt-cacher
I'm using apt-cacher on 8.04 Hardy beta 2.6.24-16-generic. The bug probably existed in old versions as well. apt-cacher occasionally returns error to a client doing apt-get. The error is: 400 No Request Recieved. I'd get about 8 to 10 such errors, very consistently, when setting up clients with apt-get installing about 460 packages. The bug is in the getRequestLine routine in /usr/share/apt-cacher/apt- cacher. The problematic lines are: # after every read at least one line MUST have been found. Read length # is large enough. my $n=sysread($source, $buf, 1024); Apparently from the comments, it's assumed that sysread will read enough bytes to have at least one complete line. Unfortunately this is not true. Given the unblocking nature of sysread, it can read anything from 0 bytes to the buffer length of 1024. My investigation shows that sysread indeed only reads half lines (such as "GET http://") when the error happens. The fix should be easy enough - just keep reading until at least one "\r\n" is encountered, as shown in the following code ($read_error is just for my own investigation, this code needs to be cleaned up): my $n; my $tmp; my $read_error; $read_error=""; $buf=$reqTail.$buf if(defined($reqTail)); RETRY_READ_SOCKET: $n=sysread($source, $tmp, 1024); if( defined($n) ) { if( $n == 0 ) { # EOF $read_error .= "EOF encountered"; # return shift(@reqLineBuf); } else { # we read something: keep reading until \r\n $read_error .=" Read $n bytes: $tmp "; $buf .= $tmp; if( $buf !~ /\r\n/s ) # cannot be $tmp here { $tmp = ""; goto RETRY_READ_SOCKET; } } } elsif($! == EWOULDBLOCK) { # we read nothing: no data from the other end of socket yet sleep(1); $read_error=" retry "; goto RETRY_READ_SOCKET; } else { # we read nothing: error $read_error=" error: $! "; return undef; } ** Affects: apt-cacher (Ubuntu) Importance: Undecided Status: New -- apt-cacher: keep getting 400 No Request Recieved https://bugs.launchpad.net/bugs/219095 You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs