Fixed bugs for debug session may 4 2012.

This commit is contained in:
Thulinma 2012-05-04 14:28:01 +02:00
parent ecbcf438de
commit 3ebfe1b693
9 changed files with 56 additions and 43 deletions

View file

@ -126,8 +126,10 @@ namespace Buffer{
lastPacketTime = now;
prevPacketTime = currPacketTime;
currPacketTime = thisStream->getStream()->getTime();
thisStream->dropWriteLock(true);
}else{
thisStream->dropWriteLock(false);
}
thisStream->dropWriteLock();
}else{
if (((currPacketTime - prevPacketTime) - (now - lastPacketTime)) > 999){
usleep(999000);
@ -151,8 +153,10 @@ namespace Buffer{
thisStream->getWriteLock();
if (thisStream->getStream()->parsePacket(inBuffer)){
thisStream->getStream()->outPacket(0);
thisStream->dropWriteLock(true);
}else{
thisStream->dropWriteLock(false);
}
thisStream->dropWriteLock();
}
}else{
usleep(1000000);
@ -177,27 +181,19 @@ namespace Buffer{
return 1;
}
std::string name = argv[1];
bool ip_waiting = false;
std::string waiting_ip;
if (argc >= 4){
waiting_ip += argv[2];
ip_waiting = true;
}
SS = Socket::makeStream(name);
thisStream = Stream::get();
thisStream->setName(name);
if (ip_waiting){
thisStream->setWaitingIP(waiting_ip);
}
Socket::Connection incoming;
Socket::Connection std_input(fileno(stdin));
tthread::thread StatsThread = tthread::thread(handleStats, 0);
tthread::thread * StdinThread = 0;
if (!ip_waiting){
if (argc < 3){
StdinThread = new tthread::thread(handleStdin, 0);
}else{
thisStream->setWaitingIP(argv[2]);
StdinThread = new tthread::thread(handlePushin, 0);
}

View file

@ -87,6 +87,7 @@ bool Buffer::Stream::checkWaitingIP(std::string ip){
if (ip == waiting_ip || ip == "::ffff:"+waiting_ip){
return true;
}else{
std::cout << ip << " != " << waiting_ip << std::endl;
return false;
}
}
@ -165,12 +166,12 @@ void Buffer::Stream::getWriteLock(){
}
/// Drops a previously gotten write lock.
void Buffer::Stream::dropWriteLock(){
void Buffer::Stream::dropWriteLock(bool newpackets_available){
rw_mutex.lock();
writers--;
rw_mutex.unlock();
rw_change.notify_all();
moreData.notify_all();
if (newpackets_available){moreData.notify_all();}
}
/// Blocks until reading is safe.

View file

@ -34,7 +34,7 @@ namespace Buffer{
/// Blocks until writing is safe.
void getWriteLock();
/// Drops a previously gotten write lock.
void dropWriteLock();
void dropWriteLock(bool newpackets_available);
/// Blocks until reading is safe.
void getReadLock();
/// Drops a previously gotten read lock.