diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-06-27 19:54:43 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-06-27 19:54:43 +0200 |
commit | c0bd49f419b0850085d651a4ceeca45cf9d09832 (patch) | |
tree | ec845a5805a6fb82ad7f6d9ed13a106b3109cdc8 /src/Net/Connection.h | |
parent | d1306a1710cda4acb9a0138347cdb43943271b9c (diff) | |
download | mad-c0bd49f419b0850085d651a4ceeca45cf9d09832.tar mad-c0bd49f419b0850085d651a4ceeca45cf9d09832.zip |
Behandle GnuTLS-Bye korrekt
Diffstat (limited to 'src/Net/Connection.h')
-rw-r--r-- | src/Net/Connection.h | 32 |
1 files changed, 12 insertions, 20 deletions
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<const unsigned char*>(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();} |