bug-commoncpp
[Top][All Lists]
Advanced

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

tcpstream lock


From: Borja Pacheco
Subject: tcpstream lock
Date: Mon, 15 Dec 2003 12:17:33 +0100

Dear all,

I've been using your classes to develop a server that interacts with different elements. Main objects are based on CommonC++ classes, and they uses Threads, tcpstream, Mutex to implement the funcionality.

This server runs severad threads to manage different resources that could be available or unavailabe, when one of these resources changes their state, I have to send a notification, through a TCP/IP message, to another console program. So, I had one thread that periodically query to these resources, and when somethig is changed, it used a tcpstream to send a the notification. The procedure for this is something like this...

// ---- Start C++ code ----

char * frame;

tcp = new tcpstream (<an string with ip + tcp port>); // TROUBLES HERE!!!!
tcp->setTimeout(200);
tcp->setCompletion(false);
tcp->sync();

<Init the frame...>

if (tcp&&tcp->isConnected()) {
tcp->write(frame,28);
tcp->flush();
tcp->close();
   delete tcp;
}

delete[] frame;

// ---- End C++ code ----

I've noticed that when this process is repeated for two hours (in my case, I suppose it really depends on the number of notifications, but I'm sorry because I don't know how many), the thread is locked (it stops and don't go away with its normal execution) when it tries to create a new tcpstream object. After this, another thread that don't have any point of coincidence with this other, catch an exception when tries to create another tcpstream, and then the programs dies.

I'm absolutely sure that the problem is inside the constructor of the tcpstream, because I've redisigned thes thread to avoid creating and destroying tcpstream objects, instead of it now I use open an close only, and it works perfectly.

Best Regards,

Borja Pacheco
-- 

reply via email to

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