From c0bd49f419b0850085d651a4ceeca45cf9d09832 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 27 Jun 2008 19:54:43 +0200 Subject: Behandle GnuTLS-Bye korrekt --- src/Net/Connection.h | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'src/Net/Connection.h') diff --git a/src/Net/Connection.h b/src/Net/Connection.h index a3670b0..01926e1 100644 --- a/src/Net/Connection.h +++ b/src/Net/Connection.h @@ -62,12 +62,23 @@ class Connection { void doReceive(); void doSend(); + void doBye(); + void doDisconnect(); bool receiveComplete() const { return (transR.length == transR.transmitted); } + void bye() { + if(state != DISCONNECT) + return; + + state = BYE; + + doBye(); + } + // Prevent shallow copy Connection(const Connection &o); Connection& operator=(const Connection &o); @@ -162,26 +173,7 @@ class Connection { return rawSend(reinterpret_cast(packet.getRawData()), packet.getRawDataLength()); } - void sendReceive(short events = POLLIN|POLLOUT) { - if(events & POLLHUP || events & POLLERR) { - doDisconnect(); - return; - } - - if(state == HANDSHAKE) { - doHandshake(); - return; - } - - if(events & POLLIN) - doReceive(); - - if(events & POLLOUT) - doSend(); - - if(state == DISCONNECT && sendQueueEmpty()) - doDisconnect(); - } + void sendReceive(short events = POLLIN|POLLOUT); bool sendQueueEmpty() const {return transS.empty();} -- cgit v1.2.3