faubackup2/src/network network_sender.cpp,1.5,1.6
Erik Merkel <[email protected]> Thu, 23 Jun 2005 14:55:41 +0000
| Newsgroups | gmane.comp.sysutils.backup.faubackup.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/faubackup/faubackup2/src/network
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10337/src/network
Modified Files:
network_sender.cpp
Log Message:
small speed improvments
Index: network_sender.cpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/network/network_sender.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** network_sender.cpp 14 Jun 2005 22:10:31 -0000 1.5
--- network_sender.cpp 23 Jun 2005 14:55:38 -0000 1.6
***************
*** 32,40 ****
void NetworkSender::work()
{
! while(1) {
// output.information("before lock" + int2string(queue_client1.empty()) + " " + int2string(queue_client2.empty()), EXCESSIV_DEBUG_OUTPUT);
pthread_mutex_lock( &sender_network_mutex);
! while(queue_client2.empty() && queue_client1.empty() && !die_on_end) {
// output.information("inside lock" + int2string(queue_client1.size()) + " " + int2string(queue_client2.size()), EXCESSIV_DEBUG_OUTPUT);
pthread_cond_wait( &sender_network_cond, &sender_network_mutex);
--- 32,40 ----
void NetworkSender::work()
{
! while (1) {
// output.information("before lock" + int2string(queue_client1.empty()) + " " + int2string(queue_client2.empty()), EXCESSIV_DEBUG_OUTPUT);
pthread_mutex_lock( &sender_network_mutex);
! while (queue_client2.empty() && queue_client1.empty() && !die_on_end) {
// output.information("inside lock" + int2string(queue_client1.size()) + " " + int2string(queue_client2.size()), EXCESSIV_DEBUG_OUTPUT);
pthread_cond_wait( &sender_network_cond, &sender_network_mutex);
***************
*** 44,71 ****
! while(!queue_client2.empty()) {
! sendPackage(queue_client2.front());
! queue_client2.pop();
! /* wake up sleeping clients */
! pthread_mutex_lock( &sender_client2_mutex);
! pthread_cond_signal( &sender_client2_cond);
! pthread_mutex_unlock( &sender_client2_mutex);
! }
! while(!queue_client1.empty()) {
! sendPackage(queue_client1.front());
! queue_client1.pop();
! /* wake up sleeping clients */
! pthread_mutex_lock( &sender_client1_mutex);
! pthread_cond_signal( &sender_client1_cond);
! pthread_mutex_unlock( &sender_client1_mutex);
}
! if(die_on_end && queue_client1.empty() && queue_client2.empty()) {
uint8_t dummy = 0xff; //special sign
sendData(&dummy, 1);
close(fd);
thread.setDead();
! return;
}
--- 44,73 ----
! while ((!queue_client2.empty()) || (!queue_client1.empty())) {
! if ((!queue_client2.empty())) {
! sendPackage(queue_client2.front());
! queue_client2.pop();
! /* wake up sleeping clients */
! pthread_mutex_lock( &sender_client2_mutex);
! pthread_cond_signal( &sender_client2_cond);
! pthread_mutex_unlock( &sender_client2_mutex);
! }
! if (!queue_client1.empty()) {
! sendPackage(queue_client1.front());
! queue_client1.pop();
! /* wake up sleeping clients */
! pthread_mutex_lock( &sender_client1_mutex);
! pthread_cond_signal( &sender_client1_cond);
! pthread_mutex_unlock( &sender_client1_mutex);
! }
}
! if (die_on_end && queue_client1.empty() && queue_client2.empty()) {
uint8_t dummy = 0xff; //special sign
sendData(&dummy, 1);
close(fd);
thread.setDead();
! return ;
}
***************
*** 77,84 ****
item->setDestination(clientNo);
! if(clientNo == 1) {
pthread_mutex_lock( &sender_client1_mutex);
! if(queue_client1.size() > 2000)
! while(queue_client1.size() > 1500)
pthread_cond_wait( &sender_client1_cond, &sender_client1_mutex);
pthread_mutex_unlock( &sender_client1_mutex);
--- 79,86 ----
item->setDestination(clientNo);
! if (clientNo == 1) {
pthread_mutex_lock( &sender_client1_mutex);
! if (queue_client1.size() > 2000)
! while (queue_client1.size() > 1500)
pthread_cond_wait( &sender_client1_cond, &sender_client1_mutex);
pthread_mutex_unlock( &sender_client1_mutex);
***************
*** 90,97 ****
} else
! if(clientNo == 2) {
pthread_mutex_lock( &sender_client2_mutex);
! if(queue_client2.size() > 2000)
! while(queue_client2.size() > 1500)
pthread_cond_wait( &sender_client2_cond, &sender_client2_mutex);
pthread_mutex_unlock( &sender_client2_mutex);
--- 92,99 ----
} else
! if (clientNo == 2) {
pthread_mutex_lock( &sender_client2_mutex);
! if (queue_client2.size() > 2000)
! while (queue_client2.size() > 1500)
pthread_cond_wait( &sender_client2_cond, &sender_client2_mutex);
pthread_mutex_unlock( &sender_client2_mutex);
***************
*** 110,114 ****
uint64_t NetworkSender::finished_Client()
{
! die_on_end= true;
pthread_mutex_lock( &sender_network_mutex);
pthread_cond_signal( &sender_network_cond);
--- 112,116 ----
uint64_t NetworkSender::finished_Client()
{
! die_on_end = true;
pthread_mutex_lock( &sender_network_mutex);
pthread_cond_signal( &sender_network_cond);
***************
*** 129,133 ****
sendData(&header, 1);
uint16_t net_size = htons(item->getDataSize());
! if(item->hasVarSize()) {
// output.information("Package has var size", EXCESSIV_DEBUG_OUTPUT);
sendData(&net_size, 2);
--- 131,135 ----
sendData(&header, 1);
uint16_t net_size = htons(item->getDataSize());
! if (item->hasVarSize()) {
// output.information("Package has var size", EXCESSIV_DEBUG_OUTPUT);
sendData(&net_size, 2);
***************
*** 148,159 ****
{
// output.information("senddata begin", EXCESSIV_DEBUG_OUTPUT);
! if(length == 0)
! return;
! if(data == NULL)
output.critical("trying to send NULL Pointer Data", 0);
//output.information("senddata begin", EXCESSIV_DEBUG_OUTPUT);
! if( write (fd, data , length ) != length )
output.critical("sendData: error sending Data", errno);
! total+=length;
// output.information("senddata end", EXCESSIV_DEBUG_OUTPUT);
}
--- 150,161 ----
{
// output.information("senddata begin", EXCESSIV_DEBUG_OUTPUT);
! if (length == 0)
! return ;
! if (data == NULL)
output.critical("trying to send NULL Pointer Data", 0);
//output.information("senddata begin", EXCESSIV_DEBUG_OUTPUT);
! if ( write (fd, data , length ) != length )
output.critical("sendData: error sending Data", errno);
! total += length;
// output.information("senddata end", EXCESSIV_DEBUG_OUTPUT);
}
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click