Post details: A bug with slow reading from a socket: Linux + CommonC++

03/04/06

Permalink 01:47:14 pm, Categories: Misc, Linux kernel, Programming, Bug reports, 294 words   English (US)

A bug with slow reading from a socket: Linux + CommonC++


I have reported the following bug to the bug-commoncpp mailing list. But probably it was a bug not in CommonC++ but in Linux 2.6.7.

[More:]

Here is my original bug report:

CommonC++ "2" 1.3.22 (at least on Linux 2.6.7 with glibc 2.3.5) in a reason which I was not able to understand (without very thorough research) reads TCP sockets through std::ifstream VERY slowly. It is a serious bug in CommonC++.

A program to reproduce the bug is attached. Note that it reads from the standard "chargen" service (port 19) which can be configured using inetd and /etc/inetd.conf.

Note that the program does not use much CPU resources despite of it runs slowly.

I also did strace on this program. It outputs only recv() syscall and nothing other. So I suspect that it may be a bug in Linux kernel 2.6.7 itself. Anyway, even if this is a bug in Linux, not in CommonC++, you should work around.

The bug is that the program runs very much too long time and does not use all CPU resources as it should.

#include <cc++/socket.h>

using namespace ost;

int main() {
TCPStream stream(IPV4Host("127.0.0.1"), (tpport_t)19, 536u, false,
(timeout_t)0/*10000*/);
const int buf_size = 1024, repeat_count = 1024;
for(int i=0; i<repeat_count; ++i) {
char buf[buf_size];
stream.read(buf, buf_size);
}
return 0;
}

After upgrade from Linux 2.6.7 to Linux 2.6.15.4, the bug disappeared.

I deem the most probably that the bug was in Linux kernel (version 2.6.7).

So I have notified bug-commoncpp mailing list:

Regarding the below bug report which I've sent you earlier.

After upgrading Linux 2.6.7 -> 2.6.15.4 the bug is fixed. So I deem it was a bug in Linux kernel. Indeed it would be probably good if you will include a workaround of this kernel (?) bug in CommonC++.

Comments, Trackbacks, Pingbacks:

No Comments/Trackbacks/Pingbacks for this post yet...

Software Blog

See also my free software. This weblog will contain information about:
  • software developed by me;
  • my software patches (for others' software);
  • my software related reviews, comments, suggestions, ideas
and other misc software related things.

Recently ||

Last comments

Search

Syndicate this blog XML

Add to MyYahoo

What is RSS?

powered by
b2evolution