diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-08-28 17:42:54 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-08-28 17:42:54 +0000 |
commit | 411cdf39fc2b961a970a0ae91b9059614251247e (patch) | |
tree | 935afa56c11aef0fb769e63659970e7d033a99e8 /src/unstable | |
parent | fc5132d68ae9e6afdbd0b5a687ba81c88fc84826 (diff) | |
download | libbu++-411cdf39fc2b961a970a0ae91b9059614251247e.tar.gz libbu++-411cdf39fc2b961a970a0ae91b9059614251247e.tar.bz2 libbu++-411cdf39fc2b961a970a0ae91b9059614251247e.tar.xz libbu++-411cdf39fc2b961a970a0ae91b9059614251247e.zip |
Loads of win32 compilation issues fixed. Most are fairly minor unsigned/signed
mismatches because of socket handles, but there were also some
order-of-definition issues that were fixed in the FD_SETSIZE definition code.
Fixed a few things that just never worked on windows, like Bu::Thread::yield().
Diffstat (limited to 'src/unstable')
-rw-r--r-- | src/unstable/itoserver.cpp | 13 | ||||
-rw-r--r-- | src/unstable/itoserver.h | 18 | ||||
-rw-r--r-- | src/unstable/myriadfs.cpp | 5 |
3 files changed, 21 insertions, 15 deletions
diff --git a/src/unstable/itoserver.cpp b/src/unstable/itoserver.cpp index 5b3b5a2..7dbce6c 100644 --- a/src/unstable/itoserver.cpp +++ b/src/unstable/itoserver.cpp | |||
@@ -5,14 +5,13 @@ | |||
5 | * terms of the license contained in the file LICENSE. | 5 | * terms of the license contained in the file LICENSE. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "bu/config.h" | ||
8 | #include "bu/itoserver.h" | 9 | #include "bu/itoserver.h" |
9 | #include <errno.h> | 10 | #include <errno.h> |
10 | #include "bu/tcpserversocket.h" | 11 | #include "bu/tcpserversocket.h" |
11 | #include "bu/client.h" | 12 | #include "bu/client.h" |
12 | #include "bu/tcpsocket.h" | 13 | #include "bu/tcpsocket.h" |
13 | 14 | ||
14 | #include "bu/config.h" | ||
15 | |||
16 | Bu::ItoServer::ItoServer() : | 15 | Bu::ItoServer::ItoServer() : |
17 | nTimeoutSec( 1 ), | 16 | nTimeoutSec( 1 ), |
18 | nTimeoutUSec( 0 ) | 17 | nTimeoutUSec( 0 ) |
@@ -42,7 +41,7 @@ Bu::ItoServer::~ItoServer() | |||
42 | void Bu::ItoServer::addPort( int nPort, int nPoolSize ) | 41 | void Bu::ItoServer::addPort( int nPort, int nPoolSize ) |
43 | { | 42 | { |
44 | TcpServerSocket *s = new TcpServerSocket( nPort, nPoolSize ); | 43 | TcpServerSocket *s = new TcpServerSocket( nPort, nPoolSize ); |
45 | int nSocket = s->getSocket(); | 44 | socket_t nSocket = s->getSocket(); |
46 | FD_SET( nSocket, &fdActive ); | 45 | FD_SET( nSocket, &fdActive ); |
47 | hServers.insert( nSocket, s ); | 46 | hServers.insert( nSocket, s ); |
48 | } | 47 | } |
@@ -50,7 +49,7 @@ void Bu::ItoServer::addPort( int nPort, int nPoolSize ) | |||
50 | void Bu::ItoServer::addPort( const String &sAddr, int nPort, int nPoolSize ) | 49 | void Bu::ItoServer::addPort( const String &sAddr, int nPort, int nPoolSize ) |
51 | { | 50 | { |
52 | TcpServerSocket *s = new TcpServerSocket( sAddr, nPort, nPoolSize ); | 51 | TcpServerSocket *s = new TcpServerSocket( sAddr, nPort, nPoolSize ); |
53 | int nSocket = s->getSocket(); | 52 | socket_t nSocket = s->getSocket(); |
54 | FD_SET( nSocket, &fdActive ); | 53 | FD_SET( nSocket, &fdActive ); |
55 | hServers.insert( nSocket, s ); | 54 | hServers.insert( nSocket, s ); |
56 | } | 55 | } |
@@ -61,7 +60,7 @@ void Bu::ItoServer::setTimeout( int nTimeoutSec, int nTimeoutUSec ) | |||
61 | this->nTimeoutUSec = nTimeoutUSec; | 60 | this->nTimeoutUSec = nTimeoutUSec; |
62 | } | 61 | } |
63 | 62 | ||
64 | void Bu::ItoServer::addClient( int nSocket, int nPort ) | 63 | void Bu::ItoServer::addClient( socket_t nSocket, int nPort ) |
65 | { | 64 | { |
66 | ItoClient *pC = new ItoClient( *this, nSocket, nPort, nTimeoutSec, | 65 | ItoClient *pC = new ItoClient( *this, nSocket, nPort, nTimeoutSec, |
67 | nTimeoutUSec ); | 66 | nTimeoutUSec ); |
@@ -106,7 +105,7 @@ void Bu::ItoServer::run() | |||
106 | } | 105 | } |
107 | } | 106 | } |
108 | 107 | ||
109 | void Bu::ItoServer::clientCleanup( int iSocket ) | 108 | void Bu::ItoServer::clientCleanup( socket_t iSocket ) |
110 | { | 109 | { |
111 | imClients.lock(); | 110 | imClients.lock(); |
112 | ItoClient *pCli = hClients.get( iSocket ); | 111 | ItoClient *pCli = hClients.get( iSocket ); |
@@ -114,7 +113,7 @@ void Bu::ItoServer::clientCleanup( int iSocket ) | |||
114 | qClientCleanup.enqueue( pCli ); | 113 | qClientCleanup.enqueue( pCli ); |
115 | } | 114 | } |
116 | 115 | ||
117 | Bu::ItoServer::ItoClient::ItoClient( ItoServer &rSrv, int iSocket, int iPort, | 116 | Bu::ItoServer::ItoClient::ItoClient( ItoServer &rSrv, Bu::ItoServer::socket_t iSocket, int iPort, |
118 | int nTimeoutSec, int nTimeoutUSec ) : | 117 | int nTimeoutSec, int nTimeoutUSec ) : |
119 | rSrv( rSrv ), | 118 | rSrv( rSrv ), |
120 | iSocket( iSocket ), | 119 | iSocket( iSocket ), |
diff --git a/src/unstable/itoserver.h b/src/unstable/itoserver.h index 57fece3..6a0df56 100644 --- a/src/unstable/itoserver.h +++ b/src/unstable/itoserver.h | |||
@@ -58,13 +58,19 @@ namespace Bu | |||
58 | ItoServer(); | 58 | ItoServer(); |
59 | virtual ~ItoServer(); | 59 | virtual ~ItoServer(); |
60 | 60 | ||
61 | #ifdef WIN32 | ||
62 | typedef unsigned int socket_t; | ||
63 | #else | ||
64 | typedef int socket_t; | ||
65 | #endif | ||
66 | |||
61 | void addPort( int nPort, int nPoolSize=40 ); | 67 | void addPort( int nPort, int nPoolSize=40 ); |
62 | void addPort( const String &sAddr, int nPort, int nPoolSize=40 ); | 68 | void addPort( const String &sAddr, int nPort, int nPoolSize=40 ); |
63 | 69 | ||
64 | //void scan(); | 70 | //void scan(); |
65 | void setTimeout( int nTimeoutSec, int nTimeoutUSec=0 ); | 71 | void setTimeout( int nTimeoutSec, int nTimeoutUSec=0 ); |
66 | 72 | ||
67 | void addClient( int nSocket, int nPort ); | 73 | void addClient( socket_t nSocket, int nPort ); |
68 | 74 | ||
69 | virtual void onNewConnection( Client *pClient, int nPort )=0; | 75 | virtual void onNewConnection( Client *pClient, int nPort )=0; |
70 | virtual void onClosedConnection( Client *pClient )=0; | 76 | virtual void onClosedConnection( Client *pClient )=0; |
@@ -78,7 +84,7 @@ namespace Bu | |||
78 | { | 84 | { |
79 | friend class Bu::ItoServer::SrvClientLink; | 85 | friend class Bu::ItoServer::SrvClientLink; |
80 | public: | 86 | public: |
81 | ItoClient( ItoServer &rSrv, int nSocket, int nPort, | 87 | ItoClient( ItoServer &rSrv, socket_t nSocket, int nPort, |
82 | int nTimeoutSec, int nTimeoutUSec ); | 88 | int nTimeoutSec, int nTimeoutUSec ); |
83 | virtual ~ItoClient(); | 89 | virtual ~ItoClient(); |
84 | 90 | ||
@@ -92,7 +98,7 @@ namespace Bu | |||
92 | ItoServer &rSrv; | 98 | ItoServer &rSrv; |
93 | Client *pClient; | 99 | Client *pClient; |
94 | fd_set fdActive; | 100 | fd_set fdActive; |
95 | int iSocket; | 101 | socket_t iSocket; |
96 | int iPort; | 102 | int iPort; |
97 | int nTimeoutSec; | 103 | int nTimeoutSec; |
98 | int nTimeoutUSec; | 104 | int nTimeoutUSec; |
@@ -126,15 +132,15 @@ namespace Bu | |||
126 | int nTimeoutSec; | 132 | int nTimeoutSec; |
127 | int nTimeoutUSec; | 133 | int nTimeoutUSec; |
128 | fd_set fdActive; | 134 | fd_set fdActive; |
129 | typedef Hash<int,TcpServerSocket *> ServerHash; | 135 | typedef Hash<socket_t,TcpServerSocket *> ServerHash; |
130 | ServerHash hServers; | 136 | ServerHash hServers; |
131 | typedef Hash<int,ItoClient *> ClientHash; | 137 | typedef Hash<socket_t,ItoClient *> ClientHash; |
132 | typedef SynchroQueue<ItoClient *> ClientQueue; | 138 | typedef SynchroQueue<ItoClient *> ClientQueue; |
133 | ClientHash hClients; | 139 | ClientHash hClients; |
134 | ClientQueue qClientCleanup; | 140 | ClientQueue qClientCleanup; |
135 | Mutex imClients; | 141 | Mutex imClients; |
136 | 142 | ||
137 | void clientCleanup( int iSocket ); | 143 | void clientCleanup( socket_t iSocket ); |
138 | }; | 144 | }; |
139 | } | 145 | } |
140 | 146 | ||
diff --git a/src/unstable/myriadfs.cpp b/src/unstable/myriadfs.cpp index 32e1ad6..6ed176d 100644 --- a/src/unstable/myriadfs.cpp +++ b/src/unstable/myriadfs.cpp | |||
@@ -5,6 +5,7 @@ | |||
5 | * terms of the license contained in the file LICENSE. | 5 | * terms of the license contained in the file LICENSE. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "bu/config.h" | ||
8 | #include "bu/myriadfs.h" | 9 | #include "bu/myriadfs.h" |
9 | #include "bu/myriadstream.h" | 10 | #include "bu/myriadstream.h" |
10 | 11 | ||
@@ -434,7 +435,7 @@ int32_t Bu::MyriadFs::lookupInode( Bu::String::const_iterator iStart, | |||
434 | void Bu::MyriadFs::readInode( int32_t iNode, RawStat &rs, MyriadStream &rIs ) | 435 | void Bu::MyriadFs::readInode( int32_t iNode, RawStat &rs, MyriadStream &rIs ) |
435 | { | 436 | { |
436 | rIs.setPos( hNodeIndex.get( iNode )*sizeof(RawStat) ); | 437 | rIs.setPos( hNodeIndex.get( iNode )*sizeof(RawStat) ); |
437 | if( rIs.read( &rs, sizeof(RawStat) ) < sizeof(RawStat) ) | 438 | if( rIs.read( &rs, sizeof(RawStat) ) < (int)sizeof(RawStat) ) |
438 | throw Bu::MyriadFsException("Filesystem corruption detected."); | 439 | throw Bu::MyriadFsException("Filesystem corruption detected."); |
439 | if( rs.iNode != iNode ) | 440 | if( rs.iNode != iNode ) |
440 | throw Bu::MyriadFsException("Filesystem corruption detected."); | 441 | throw Bu::MyriadFsException("Filesystem corruption detected."); |
@@ -451,7 +452,7 @@ void Bu::MyriadFs::writeInode( const RawStat &rs, | |||
451 | { | 452 | { |
452 | rOs.setSize( hNodeIndex.getSize()*sizeof(RawStat) ); | 453 | rOs.setSize( hNodeIndex.getSize()*sizeof(RawStat) ); |
453 | rOs.setPos( hNodeIndex.get( rs.iNode )*sizeof(RawStat) ); | 454 | rOs.setPos( hNodeIndex.get( rs.iNode )*sizeof(RawStat) ); |
454 | if( rOs.write( &rs, sizeof(RawStat) ) < sizeof(RawStat) ) | 455 | if( rOs.write( &rs, sizeof(RawStat) ) < (int)sizeof(RawStat) ) |
455 | throw Bu::MyriadFsException("Error writing inode to header stream."); | 456 | throw Bu::MyriadFsException("Error writing inode to header stream."); |
456 | } | 457 | } |
457 | 458 | ||