bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TCPSession segfaults / hangs


From: David Sugar
Subject: Re: TCPSession segfaults / hangs
Date: Tue, 23 Nov 2004 13:37:19 -0500
User-agent: Mozilla Thunderbird 0.9 (Macintosh/20041103)

The most obvious possibility that comes to my mind is that a name resolution request is being made somewhere in this process (such as for a reverse lookup) that is timing out. When soc, which I gather is a TCPSocket object, is being assigned to the new session thread, I believe that processes the onAccept handling, and if so, somewhere in there it may be stalled on a name lookup. A very immediate way to test this theory on a GNU/Linux system is to set a very low timeout in /etc/resolv.conf and see if it then stalls for a much shorter period of time.

Rami Saarinen wrote:
Thanks David. That solves one problem and clears a lot of confusion.
Does anyone have any ideas why the TCPListener seems to stall for minutes
after the first connection? I have made quite a lot of changes (not to the
TCPListener or TCPSessionThread classes) to the code so it just may work
better now, but I don't currently have a change to try it out. However,
none of the changes affect the TCP classes. So if any of you think of
anything that may give me a proper direction, I'd appreciate it.

And, while we're at it... What is the simplest and best way to get the IP
of the computer? Now it seems to make a hostname query to the DNS and
resolve the IP from it. That's not a problem as such, but has caused some
confusion earlier when one of the computers had a bit of DNS troubles. I promise I'll stop using you as my help-line for now on. :)
--- David Sugar <address@hidden> wrote:


In 1.2.x, you must use detach rather than start if you intend for your thread to be a self deleting object, and you must exit the thread, and NOT put a delete this in it's final; a detached thread, that is, started

by "detach" rather than "start", is automatically deleted when it exits
now.


Rami Saarinen wrote:

[...]

TCPListener looks like this (mostly copied from the examples): ... void run() { try { TCPSessionThread<T> *tcp; while(enabled) { while(soc->isPendingConnection()) { tcp = new TCPSessionThread<T>(*soc,this->master); tcp->detach(); //tcp->start(); } } } catch(Socket *socket) { ...
And TCPSessionThread is just as simple.. could do some work on the

buffer

& data handling :) : ... void run() { ssize_t val=1; char buf[512]; string *ret=new string(); while(val>0) { val=readData((void *)buf,512); string s(buf,val); ret->append(s); if(ret->size()>MAX_IN_BYTECOUNT) throw OwnException("Buffer overrun in TCPSessionThread"); } ((T)this->master)->handleMessage(ret); } void final() { delete this; } ...

[...]


But on another laptop, where I need to get it to work, it does not

work at

all. The setup is Fedora core 3 (gcc 3.4.2) and any version on ccpp2

(from

1.0.13 to 1.2.6).
The problem seems to be TCPSession and especially the final() method

of

it.
1. If I use older version of ccpp2, I get free() invalid pointer error
from glibc and the program aborts. If I comment out the delete this

line

from final method. The program seg-faults (IIRC)
2. If I use ccpp2 1.2.6 I get the same free() invalid pointer error,

but

if I comment out the "delete this" from the final method the

TCPListener

seems to hang for minutes after the first TCPSession is created. After
several minutes the program continues and finally handles the pending
connections.
I do use mutexes quite a lot, but they should not be the cause of the
lock-up/stall as the program works fine on other systems.




                
__________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]