summaryrefslogtreecommitdiffstats
path: root/client/red_peer.h
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2009-10-16 00:21:43 +0200
committerYaniv Kamay <ykamay@redhat.com>2009-10-18 17:42:37 +0200
commitef213c66c19d265140e9a55519b174d34ff1f16b (patch)
tree0a8e58217f5757881d4d4798d1316dbb3809f37a /client/red_peer.h
parent308e4545cbf8d26d5d47ad6ab9f2c6e6e6648003 (diff)
downloadspice-ef213c66c19d265140e9a55519b174d34ff1f16b.tar.gz
spice-ef213c66c19d265140e9a55519b174d34ff1f16b.tar.xz
spice-ef213c66c19d265140e9a55519b174d34ff1f16b.zip
tunnel
Diffstat (limited to 'client/red_peer.h')
-rw-r--r--client/red_peer.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/client/red_peer.h b/client/red_peer.h
index f1db1814..eb0597d8 100644
--- a/client/red_peer.h
+++ b/client/red_peer.h
@@ -18,12 +18,6 @@
#ifndef _H_REDPEER
#define _H_REDPEER
-#ifdef _WIN32
-#include <winsock.h>
-#else
-typedef int SOCKET;
-#endif
-
#include <openssl/ssl.h>
#include <openssl/err.h>
@@ -31,6 +25,7 @@ typedef int SOCKET;
#include "red.h"
#include "events_loop.h"
#include "threads.h"
+#include "platform_utils.h"
class RedPeer: protected EventsLoop::Socket {
public:
@@ -116,7 +111,7 @@ private:
class RedPeer::InMessage {
public:
- InMessage(uint16_t type, uint32_t size, uint8_t* data)
+ InMessage(uint16_t type, uint32_t size, uint8_t * data)
: _type (type)
, _size (size)
, _data (data)
@@ -139,12 +134,14 @@ class RedPeer::CompundInMessage: public RedPeer::InMessage {
public:
CompundInMessage(uint64_t _serial, uint16_t type, uint32_t size, uint32_t sub_list)
: InMessage(type, size, new uint8_t[size])
+ , _refs (1)
, _serial (_serial)
, _sub_list (sub_list)
{
}
- virtual ~CompundInMessage() { delete[] _data;}
+ RedPeer::InMessage* ref() { _refs++; return this;}
+ void unref() {if (!--_refs) delete this;}
uint64_t serial() { return _serial;}
uint32_t sub_list() { return _sub_list;}
@@ -152,7 +149,11 @@ public:
virtual uint32_t size() { return _sub_list ? _sub_list : _size;}
uint32_t compund_size() {return _size;}
+protected:
+ virtual ~CompundInMessage() { delete[] _data;}
+
private:
+ int _refs;
uint64_t _serial;
uint32_t _sub_list;
};