From 411cdf39fc2b961a970a0ae91b9059614251247e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 28 Aug 2012 17:42:54 +0000 Subject: 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(). --- src/unstable/itoserver.cpp | 13 ++++++------- src/unstable/itoserver.h | 18 ++++++++++++------ src/unstable/myriadfs.cpp | 5 +++-- 3 files changed, 21 insertions(+), 15 deletions(-) (limited to 'src/unstable') 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 @@ * terms of the license contained in the file LICENSE. */ +#include "bu/config.h" #include "bu/itoserver.h" #include #include "bu/tcpserversocket.h" #include "bu/client.h" #include "bu/tcpsocket.h" -#include "bu/config.h" - Bu::ItoServer::ItoServer() : nTimeoutSec( 1 ), nTimeoutUSec( 0 ) @@ -42,7 +41,7 @@ Bu::ItoServer::~ItoServer() void Bu::ItoServer::addPort( int nPort, int nPoolSize ) { TcpServerSocket *s = new TcpServerSocket( nPort, nPoolSize ); - int nSocket = s->getSocket(); + socket_t nSocket = s->getSocket(); FD_SET( nSocket, &fdActive ); hServers.insert( nSocket, s ); } @@ -50,7 +49,7 @@ void Bu::ItoServer::addPort( int nPort, int nPoolSize ) void Bu::ItoServer::addPort( const String &sAddr, int nPort, int nPoolSize ) { TcpServerSocket *s = new TcpServerSocket( sAddr, nPort, nPoolSize ); - int nSocket = s->getSocket(); + socket_t nSocket = s->getSocket(); FD_SET( nSocket, &fdActive ); hServers.insert( nSocket, s ); } @@ -61,7 +60,7 @@ void Bu::ItoServer::setTimeout( int nTimeoutSec, int nTimeoutUSec ) this->nTimeoutUSec = nTimeoutUSec; } -void Bu::ItoServer::addClient( int nSocket, int nPort ) +void Bu::ItoServer::addClient( socket_t nSocket, int nPort ) { ItoClient *pC = new ItoClient( *this, nSocket, nPort, nTimeoutSec, nTimeoutUSec ); @@ -106,7 +105,7 @@ void Bu::ItoServer::run() } } -void Bu::ItoServer::clientCleanup( int iSocket ) +void Bu::ItoServer::clientCleanup( socket_t iSocket ) { imClients.lock(); ItoClient *pCli = hClients.get( iSocket ); @@ -114,7 +113,7 @@ void Bu::ItoServer::clientCleanup( int iSocket ) qClientCleanup.enqueue( pCli ); } -Bu::ItoServer::ItoClient::ItoClient( ItoServer &rSrv, int iSocket, int iPort, +Bu::ItoServer::ItoClient::ItoClient( ItoServer &rSrv, Bu::ItoServer::socket_t iSocket, int iPort, int nTimeoutSec, int nTimeoutUSec ) : rSrv( rSrv ), 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 ItoServer(); virtual ~ItoServer(); +#ifdef WIN32 + typedef unsigned int socket_t; +#else + typedef int socket_t; +#endif + void addPort( int nPort, int nPoolSize=40 ); void addPort( const String &sAddr, int nPort, int nPoolSize=40 ); //void scan(); void setTimeout( int nTimeoutSec, int nTimeoutUSec=0 ); - void addClient( int nSocket, int nPort ); + void addClient( socket_t nSocket, int nPort ); virtual void onNewConnection( Client *pClient, int nPort )=0; virtual void onClosedConnection( Client *pClient )=0; @@ -78,7 +84,7 @@ namespace Bu { friend class Bu::ItoServer::SrvClientLink; public: - ItoClient( ItoServer &rSrv, int nSocket, int nPort, + ItoClient( ItoServer &rSrv, socket_t nSocket, int nPort, int nTimeoutSec, int nTimeoutUSec ); virtual ~ItoClient(); @@ -92,7 +98,7 @@ namespace Bu ItoServer &rSrv; Client *pClient; fd_set fdActive; - int iSocket; + socket_t iSocket; int iPort; int nTimeoutSec; int nTimeoutUSec; @@ -126,15 +132,15 @@ namespace Bu int nTimeoutSec; int nTimeoutUSec; fd_set fdActive; - typedef Hash ServerHash; + typedef Hash ServerHash; ServerHash hServers; - typedef Hash ClientHash; + typedef Hash ClientHash; typedef SynchroQueue ClientQueue; ClientHash hClients; ClientQueue qClientCleanup; Mutex imClients; - void clientCleanup( int iSocket ); + void clientCleanup( socket_t iSocket ); }; } 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 @@ * terms of the license contained in the file LICENSE. */ +#include "bu/config.h" #include "bu/myriadfs.h" #include "bu/myriadstream.h" @@ -434,7 +435,7 @@ int32_t Bu::MyriadFs::lookupInode( Bu::String::const_iterator iStart, void Bu::MyriadFs::readInode( int32_t iNode, RawStat &rs, MyriadStream &rIs ) { rIs.setPos( hNodeIndex.get( iNode )*sizeof(RawStat) ); - if( rIs.read( &rs, sizeof(RawStat) ) < sizeof(RawStat) ) + if( rIs.read( &rs, sizeof(RawStat) ) < (int)sizeof(RawStat) ) throw Bu::MyriadFsException("Filesystem corruption detected."); if( rs.iNode != iNode ) throw Bu::MyriadFsException("Filesystem corruption detected."); @@ -451,7 +452,7 @@ void Bu::MyriadFs::writeInode( const RawStat &rs, { rOs.setSize( hNodeIndex.getSize()*sizeof(RawStat) ); rOs.setPos( hNodeIndex.get( rs.iNode )*sizeof(RawStat) ); - if( rOs.write( &rs, sizeof(RawStat) ) < sizeof(RawStat) ) + if( rOs.write( &rs, sizeof(RawStat) ) < (int)sizeof(RawStat) ) throw Bu::MyriadFsException("Error writing inode to header stream."); } -- cgit v1.2.3