From: Gerrit Renker Date: Tue, 24 Feb 2009 19:30:18 +0000 (+0100) Subject: Remove Win32 Support X-Git-Url: http://sjero.net/git/?p=iperf;a=commitdiff_plain;h=0b373e070771aa2bc368ec82dbd4f48e69f5faf9 Remove Win32 Support This removes support for Win32 since all subsequent patches introduce functionality specific to Linux: * use of nanosleep (POSIX, using hrtimers), * UDP-Lite support (RFC 3828), * DCCP support (RFC 4340-2). Don't know whether this was a good idea, but it helped to make the code more readable. --- diff --git a/compat/error.c b/compat/error.c index 829ecc9..1d3647e 100644 --- a/compat/error.c +++ b/compat/error.c @@ -57,105 +57,6 @@ extern "C" { #endif -#ifdef WIN32 - -/* ------------------------------------------------------------------- - * Implement a simple Win32 strerror function for our purposes. - * These error values weren't handled by FormatMessage; - * any particular reason why not?? - * ------------------------------------------------------------------- */ - -struct mesg { - DWORD err; - const char* str; -}; - -const struct mesg error_mesgs[] = -{ - { WSAEACCES, "Permission denied"}, - { WSAEADDRINUSE, "Address already in use"}, - { WSAEADDRNOTAVAIL, "Cannot assign requested address"}, - { WSAEAFNOSUPPORT, "Address family not supported by protocol family"}, - { WSAEALREADY, "Operation already in progress"}, - { WSAECONNABORTED, "Software caused connection abort"}, - { WSAECONNREFUSED, "Connection refused"}, - { WSAECONNRESET, "Connection reset by peer"}, - { WSAEDESTADDRREQ, "Destination address required"}, - { WSAEFAULT, "Bad address"}, - { WSAEHOSTDOWN, "Host is down"}, - { WSAEHOSTUNREACH, "No route to host"}, - { WSAEINPROGRESS, "Operation now in progress"}, - { WSAEINTR, "Interrupted function call."}, - { WSAEINVAL, "Invalid argument."}, - { WSAEISCONN, "Socket is already connected."}, - { WSAEMFILE, "Too many open files."}, - { WSAEMSGSIZE, "Message too long"}, - { WSAENETDOWN, "Network is down"}, - { WSAENETRESET, "Network dropped connection on reset"}, - { WSAENETUNREACH, "Network is unreachable"}, - { WSAENOBUFS, "No buffer space available."}, - { WSAENOPROTOOPT, "Bad protocol option."}, - { WSAENOTCONN, "Socket is not connected"}, - { WSAENOTSOCK, "Socket operation on non-socket."}, - { WSAEOPNOTSUPP, "Operation not supported"}, - { WSAEPFNOSUPPORT, "Protocol family not supported"}, - { WSAEPROCLIM, "Too many processes."}, - { WSAEPROTONOSUPPORT, "Protocol not supported"}, - { WSAEPROTOTYPE, "Protocol wrong type for socket"}, - { WSAESHUTDOWN, "Cannot send after socket shutdown"}, - { WSAESOCKTNOSUPPORT, "Socket type not supported."}, - { WSAETIMEDOUT, "Connection timed out."}, - { WSATYPE_NOT_FOUND, "Class type not found."}, - { WSAEWOULDBLOCK, "Resource temporarily unavailable"}, - { WSAHOST_NOT_FOUND, "Host not found."}, - { WSA_INVALID_HANDLE, "Specified event object handle is invalid."}, - { WSA_INVALID_PARAMETER, "One or more parameters are invalid."}, - { WSA_IO_INCOMPLETE, "Overlapped I/O event object not in signaled state."}, - { WSA_IO_PENDING, "Overlapped operations will complete later."}, - { WSA_NOT_ENOUGH_MEMORY, "Insufficient memory available."}, - { WSANOTINITIALISED, "Successful WSAStartup not yet performed."}, - { WSANO_DATA, "Valid name, no data record of requested type."}, - { WSANO_RECOVERY, "This is a non-recoverable error."}, - { WSASYSCALLFAILURE, "System call failure."}, - { WSASYSNOTREADY, "Network subsystem is unavailable."}, - { WSATRY_AGAIN, "Non-authoritative host not found."}, - { WSAVERNOTSUPPORTED, "WINSOCK.DLL version out of range."}, - { WSAEDISCON, "Graceful shutdown in progress."}, - { WSA_OPERATION_ABORTED, "Overlapped operation aborted."}, - { 0, "No error."} - - /* These appeared in the documentation, but didn't compile. - * { WSAINVALIDPROCTABLE, "Invalid procedure table from service provider." }, - * { WSAINVALIDPROVIDER, "Invalid service provider version number." }, - * { WSAPROVIDERFAILEDINIT, "Unable to initialize a service provider." }, - */ - -}; /* end error_mesgs[] */ - -const char* winsock_strerror( DWORD inErrno ); - -/* ------------------------------------------------------------------- - * winsock_strerror - * - * returns a string representing the error code. The error messages - * were taken from Microsoft's online developer library. - * ------------------------------------------------------------------- */ - -const char* winsock_strerror( DWORD inErrno ) { - const char* str = "Unknown error"; - int i; - for ( i = 0; i < sizeof(error_mesgs); i++ ) { - if ( error_mesgs[i].err == inErrno ) { - str = error_mesgs[i].str; - break; - } - } - - return str; -} /* end winsock_strerror */ - -#endif /* WIN32 */ - /* ------------------------------------------------------------------- * warn * @@ -185,13 +86,8 @@ void warn_errno( const char *inMessage, const char *inFile, int inLine ) { const char* my_str; /* get platform's errno and error message */ -#ifdef WIN32 - my_err = WSAGetLastError(); - my_str = winsock_strerror( my_err ); -#else my_err = errno; my_str = strerror( my_err ); -#endif fflush( 0 ); diff --git a/include/Condition.h b/include/Condition.h index 692de35..cb232c5 100644 --- a/include/Condition.h +++ b/include/Condition.h @@ -63,11 +63,6 @@ typedef struct Condition { pthread_cond_t mCondition; pthread_mutex_t mMutex; } Condition; -#elif defined( HAVE_WIN32_THREAD ) -typedef struct Condition { - HANDLE mCondition; - HANDLE mMutex; -} Condition; #else typedef struct Condition { int mCondition; @@ -85,14 +80,6 @@ typedef struct Condition { Mutex_Initialize( &(Cond)->mMutex ); \ pthread_cond_init( &(Cond)->mCondition, NULL ); \ } while ( 0 ) -#elif defined( HAVE_WIN32_THREAD ) - // set all conditions to be broadcast - // unfortunately in Win32 you have to know at creation - // whether the signal is broadcast or not. - #define Condition_Initialize( Cond ) do { \ - Mutex_Initialize( &(Cond)->mMutex ); \ - (Cond)->mCondition = CreateEvent( NULL, true, false, NULL ); \ - } while ( 0 ) #else #define Condition_Initialize( Cond ) #endif @@ -103,11 +90,6 @@ typedef struct Condition { pthread_cond_destroy( &(Cond)->mCondition ); \ Mutex_Destroy( &(Cond)->mMutex ); \ } while ( 0 ) -#elif defined( HAVE_WIN32_THREAD ) - #define Condition_Destroy( Cond ) do { \ - CloseHandle( (Cond)->mCondition ); \ - Mutex_Destroy( &(Cond)->mMutex ); \ - } while ( 0 ) #else #define Condition_Destroy( Cond ) #endif @@ -115,13 +97,6 @@ typedef struct Condition { // sleep this thread, waiting for condition signal #if defined( HAVE_POSIX_THREAD ) #define Condition_Wait( Cond ) pthread_cond_wait( &(Cond)->mCondition, &(Cond)->mMutex ) -#elif defined( HAVE_WIN32_THREAD ) - // atomically release mutex and wait on condition, - // then re-acquire the mutex - #define Condition_Wait( Cond ) do { \ - SignalObjectAndWait( (Cond)->mMutex, (Cond)->mCondition, INFINITE, false ); \ - Mutex_Lock( &(Cond)->mMutex ); \ - } while ( 0 ) #else #define Condition_Wait( Cond ) #endif @@ -135,13 +110,6 @@ typedef struct Condition { absTimeout.tv_nsec = 0; \ pthread_cond_timedwait( &(Cond)->mCondition, &(Cond)->mMutex, &absTimeout ); \ } while ( 0 ) -#elif defined( HAVE_WIN32_THREAD ) - // atomically release mutex and wait on condition, - // then re-acquire the mutex - #define Condition_TimedWait( Cond, inSeconds ) do { \ - SignalObjectAndWait( (Cond)->mMutex, (Cond)->mCondition, inSeconds*1000, false ); \ - Mutex_Lock( &(Cond)->mMutex ); \ - } while ( 0 ) #else #define Condition_TimedWait( Cond, inSeconds ) #endif @@ -151,8 +119,6 @@ typedef struct Condition { // use PulseEvent to auto-reset the signal after waking all threads #if defined( HAVE_POSIX_THREAD ) #define Condition_Signal( Cond ) pthread_cond_signal( &(Cond)->mCondition ) -#elif defined( HAVE_WIN32_THREAD ) - #define Condition_Signal( Cond ) PulseEvent( (Cond)->mCondition ) #else #define Condition_Signal( Cond ) #endif @@ -160,8 +126,6 @@ typedef struct Condition { // send a condition signal to wake all threads waiting on condition #if defined( HAVE_POSIX_THREAD ) #define Condition_Broadcast( Cond ) pthread_cond_broadcast( &(Cond)->mCondition ) -#elif defined( HAVE_WIN32_THREAD ) - #define Condition_Broadcast( Cond ) PulseEvent( (Cond)->mCondition ) #else #define Condition_Broadcast( Cond ) #endif diff --git a/include/Locale.h b/include/Locale.h index 926b47a..01f55b5 100644 --- a/include/Locale.h +++ b/include/Locale.h @@ -62,14 +62,7 @@ extern "C" { * ------------------------------------------------------------------- */ extern const char usage_short[]; - -#ifdef WIN32 -extern const char usage_long1[]; -extern const char usage_long2[]; -#else extern const char usage_long[]; -#endif - extern const char version[]; /* ------------------------------------------------------------------- diff --git a/include/Mutex.h b/include/Mutex.h index 17e0a12..88c436f 100644 --- a/include/Mutex.h +++ b/include/Mutex.h @@ -57,8 +57,6 @@ #if defined( HAVE_POSIX_THREAD ) typedef pthread_mutex_t Mutex; -#elif defined( HAVE_WIN32_THREAD ) - typedef HANDLE Mutex; #else typedef int Mutex; #endif @@ -70,8 +68,6 @@ public:*/ // initialize mutex #if defined( HAVE_POSIX_THREAD ) #define Mutex_Initialize( MutexPtr ) pthread_mutex_init( MutexPtr, NULL ) -#elif defined( HAVE_WIN32_THREAD ) - #define Mutex_Initialize( MutexPtr ) *MutexPtr = CreateMutex( NULL, false, NULL ) #else #define Mutex_Initialize( MutexPtr ) #endif @@ -79,8 +75,6 @@ public:*/ // lock the mutex variable #if defined( HAVE_POSIX_THREAD ) #define Mutex_Lock( MutexPtr ) pthread_mutex_lock( MutexPtr ) -#elif defined( HAVE_WIN32_THREAD ) - #define Mutex_Lock( MutexPtr ) WaitForSingleObject( *MutexPtr, INFINITE ) #else #define Mutex_Lock( MutexPtr ) #endif @@ -88,8 +82,6 @@ public:*/ // unlock the mutex variable #if defined( HAVE_POSIX_THREAD ) #define Mutex_Unlock( MutexPtr ) pthread_mutex_unlock( MutexPtr ) -#elif defined( HAVE_WIN32_THREAD ) - #define Mutex_Unlock( MutexPtr ) ReleaseMutex( *MutexPtr ) #else #define Mutex_Unlock( MutexPtr ) #endif @@ -103,8 +95,6 @@ public:*/ pthread_mutex_destroy( MutexPtr ); \ } \ } while ( 0 ) -#elif defined( HAVE_WIN32_THREAD ) - #define Mutex_Destroy( MutexPtr ) CloseHandle( *MutexPtr ) #else #define Mutex_Destroy( MutexPtr ) #endif diff --git a/include/Settings.hpp b/include/Settings.hpp index ec81dc9..4c3aede 100644 --- a/include/Settings.hpp +++ b/include/Settings.hpp @@ -170,9 +170,6 @@ typedef struct thread_Settings { iperf_sockaddr local; Socklen_t size_local; nthread_t mTID; -#if defined( HAVE_WIN32_THREAD ) - HANDLE mHandle; -#endif } thread_Settings; /* diff --git a/include/Thread.h b/include/Thread.h index fd24187..2524a09 100644 --- a/include/Thread.h +++ b/include/Thread.h @@ -77,13 +77,6 @@ typedef pthread_t nthread_t; #define HAVE_THREAD 1 -#elif defined( HAVE_WIN32_THREAD ) - -/* Definitions for Win32 NT Threads */ -typedef DWORD nthread_t; - - #define HAVE_THREAD 1 - #else /* Definitions for no threads */ @@ -126,8 +119,6 @@ typedef int nthread_t; * ------------------------------------------------------------------- */ #if defined( HAVE_POSIX_THREAD ) #define thread_getid() pthread_self() - #elif defined( HAVE_WIN32_THREAD ) - #define thread_getid() GetCurrentThreadId() #else #define thread_getid() 0 #endif @@ -136,11 +127,7 @@ typedef int nthread_t; nthread_t thread_zeroid( void ); -#if defined( HAVE_WIN32_THREAD ) - DWORD WINAPI thread_run_wrapper( void* paramPtr ); -#else - void* thread_run_wrapper( void* paramPtr ); -#endif + void* thread_run_wrapper( void* paramPtr ); void thread_rest ( void ); diff --git a/include/headers.h b/include/headers.h index 657674f..6bf6da8 100644 --- a/include/headers.h +++ b/include/headers.h @@ -84,44 +84,6 @@ #include #include -#ifdef WIN32 - -/* Windows config file */ - #include "config.win32.h" - -/* Windows headers */ - #define _WIN32_WINNT 0x0400 /* use (at least) WinNT 4.0 API */ - #define WIN32_LEAN_AND_MEAN /* exclude unnecesary headers */ - #include - #include - #include - -/* define EINTR, just to help compile; it isn't useful */ - #ifndef EINTR - #define EINTR WSAEINTR - #endif // EINTR - -/* Visual C++ has INT64, but not 'long long'. - * Metrowerks has 'long long', but INT64 doesn't work. */ - #ifdef __MWERKS__ - #define int64_t long long - #else - #define int64_t INT64 - #endif // __MWERKS__ - -/* Visual C++ has _snprintf instead of snprintf */ - #ifndef __MWERKS__ - #define snprintf _snprintf - #endif // __MWERKS__ - -/* close, read, and write only work on files in Windows. - * I get away with #defining them because I don't read files. */ - #define close( s ) closesocket( s ) - #define read( s, b, l ) recv( s, (char*) b, l, 0 ) - #define write( s, b, l ) send( s, (char*) b, l, 0 ) - -#else /* not defined WIN32 */ - /* required on AIX for FD_SET (requires bzero). * often this is the same as */ #ifdef HAVE_STRINGS_H @@ -157,8 +119,6 @@ SPECIAL_OSF1_EXTERN_C_STOP #define SOCKET_ERROR -1 #define INVALID_SOCKET -1 -#endif /* not defined WIN32 */ - #ifndef INET6_ADDRSTRLEN #define INET6_ADDRSTRLEN 40 #endif diff --git a/include/util.h b/include/util.h index dab0a3f..d23618c 100644 --- a/include/util.h +++ b/include/util.h @@ -82,20 +82,6 @@ typedef Sigfunc *SigfuncPtr; SigfuncPtr my_signal( int inSigno, SigfuncPtr inFunc ); -#ifdef WIN32 - -/* under windows, emulate unix signals */ -enum { - SIGINT, - SIGTERM, - SIGPIPE, - _NSIG -}; - -BOOL WINAPI sig_dispatcher( DWORD type ); - -#endif - /* ------------------------------------------------------------------- * error handlers * error.c diff --git a/src/Listener.cpp b/src/Listener.cpp index 94e32de..cf3c159 100644 --- a/src/Listener.cpp +++ b/src/Listener.cpp @@ -118,11 +118,6 @@ Listener::~Listener() { * spawn a new Server thread. * ------------------------------------------------------------------- */ void Listener::Run( void ) { -#ifdef WIN32 - if ( isUDP( mSettings ) && !isSingleUDP( mSettings ) ) { - UDPSingleServer(); - } else -#else #ifdef sun if ( ( isUDP( mSettings ) && isMulticast( mSettings ) && @@ -134,7 +129,6 @@ void Listener::Run( void ) { if ( isSingleUDP( mSettings ) ) { UDPSingleServer(); } else -#endif #endif { bool client = false, UDP = isUDP( mSettings ), mCount = (mSettings->mThreads != 0); @@ -248,18 +242,6 @@ void Listener::Run( void ) { } // Start the server -#if defined(WIN32) && defined(HAVE_THREAD) - if ( UDP ) { - // WIN32 does bad UDP handling so run single threaded - if ( server->runNow != NULL ) { - thread_start( server->runNow ); - } - server_spawn( server ); - if ( server->runNext != NULL ) { - thread_start( server->runNext ); - } - } else -#endif thread_start( server ); // create a new socket @@ -303,18 +285,8 @@ void Listener::Listen( ) { #endif : AF_INET); -#ifdef WIN32 - if ( SockAddr_isMulticast( &mSettings->local ) ) { - // Multicast on Win32 requires special handling - mSettings->mSock = WSASocket( domain, type, 0, 0, 0, WSA_FLAG_MULTIPOINT_C_LEAF | WSA_FLAG_MULTIPOINT_D_LEAF ); - WARN_errno( mSettings->mSock == INVALID_SOCKET, "socket" ); - - } else -#endif - { - mSettings->mSock = socket( domain, type, 0 ); - WARN_errno( mSettings->mSock == INVALID_SOCKET, "socket" ); - } + mSettings->mSock = socket( domain, type, 0 ); + WARN_errno( mSettings->mSock == INVALID_SOCKET, "socket" ); SetSocketOptions( mSettings ); @@ -324,17 +296,9 @@ void Listener::Listen( ) { setsockopt( mSettings->mSock, SOL_SOCKET, SO_REUSEADDR, (char*) &boolean, len ); // bind socket to server address -#ifdef WIN32 - if ( SockAddr_isMulticast( &mSettings->local ) ) { - // Multicast on Win32 requires special handling - rc = WSAJoinLeaf( mSettings->mSock, (sockaddr*) &mSettings->local, mSettings->size_local,0,0,0,0,JL_BOTH); - WARN_errno( rc == SOCKET_ERROR, "WSAJoinLeaf (aka bind)" ); - } else -#endif - { - rc = bind( mSettings->mSock, (sockaddr*) &mSettings->local, mSettings->size_local ); - WARN_errno( rc == SOCKET_ERROR, "bind" ); - } + rc = bind( mSettings->mSock, (sockaddr*) &mSettings->local, mSettings->size_local ); + WARN_errno( rc == SOCKET_ERROR, "bind" ); + // listen for connections (TCP only). // default backlog traditionally 5 if ( !isUDP( mSettings ) ) { @@ -342,12 +306,10 @@ void Listener::Listen( ) { WARN_errno( rc == SOCKET_ERROR, "listen" ); } -#ifndef WIN32 // if multicast, join the group if ( SockAddr_isMulticast( &mSettings->local ) ) { McastJoin( ); } -#endif } // end Listen /* ------------------------------------------------------------------- @@ -675,7 +637,6 @@ void Listener::UDPSingleServer( ) { * --------------------------------------------------------------------*/ void Listener::runAsDaemon(const char *pname, int facility) { -#ifndef WIN32 pid_t pid; /* Create a child process & if successful, exit from the parent process */ @@ -708,9 +669,5 @@ void Listener::runAsDaemon(const char *pname, int facility) { fflush(stderr); fclose(stdin); -#else - fprintf( stderr, "Use the precompiled windows version for service (daemon) option\n"); -#endif - } diff --git a/src/Locale.c b/src/Locale.c index d6fb1f8..d7e71f8 100644 --- a/src/Locale.c +++ b/src/Locale.c @@ -55,9 +55,6 @@ #ifdef HAVE_CONFIG_H #include "config.h" #else -#ifdef WIN32 -#include "config.win32.h" -#endif #endif #ifdef __cplusplus @@ -71,61 +68,6 @@ const char usage_short[] = "\ Usage: %s [-s|-c host] [options]\n\ Try `%s --help' for more information.\n"; -#ifdef WIN32 -const char usage_long1[] = "\ -Usage: iperf [-s|-c host] [options]\n\ - iperf [-h|--help] [-v|--version]\n\ -\n\ -Client/Server:\n\ - -f, --format [kmKM] format to report: Kbits, Mbits, KBytes, MBytes\n\ - -i, --interval # seconds between periodic bandwidth reports\n\ - -l, --len #[KM] length of buffer to read or write (default 8 KB)\n\ - -m, --print_mss print TCP maximum segment size (MTU - TCP/IP header)\n\ - -o, --output output the report or error message to this specified file\n\ - -p, --port # server port to listen on/connect to\n\ - -u, --udp use UDP rather than TCP\n\ - -w, --window #[KM] TCP window size (socket buffer size)\n\ - -B, --bind bind to , an interface or multicast address\n\ - -C, --compatibility for use with older versions does not sent extra msgs\n\ - -M, --mss # set TCP maximum segment size (MTU - 40 bytes)\n\ - -N, --nodelay set TCP no delay, disabling Nagle's Algorithm\n\ - -V, --IPv6Version Set the domain to IPv6\n\ -\n\ -Server specific:\n\ - -s, --server run in server mode\n\ - -U, --single_udp run in single threaded UDP mode\n\ - -D, --daemon run the server as a daemon\n\ - -R, --remove remove service in win32\n"; - -const char usage_long2[] = "\ -\n\ -Client specific:\n\ - -b, --bandwidth #[KM] for UDP, bandwidth to send at in bits/sec\n\ - (default 1 Mbit/sec, implies -u)\n\ - -c, --client run in client mode, connecting to \n\ - -d, --dualtest Do a bidirectional test simultaneously\n\ - -n, --num #[KM] number of bytes to transmit (instead of -t)\n\ - -r, --tradeoff Do a bidirectional test individually\n\ - -t, --time # time in seconds to transmit for (default 10 secs)\n\ - -F, --fileinput input the data to be transmitted from a file\n\ - -I, --stdin input the data to be transmitted from stdin\n\ - -L, --listenport # port to recieve bidirectional tests back on\n\ - -P, --parallel # number of parallel client threads to run\n\ - -T, --ttl # time-to-live, for multicast (default 1)\n\ -\n\ -Miscellaneous:\n\ - -h, --help print this message and quit\n\ - -v, --version print version information and quit\n\ -\n\ -[KM] Indicates options that support a K or M suffix for kilo- or mega-\n\ -\n\ -The TCP window size option can be set by the environment variable\n\ -TCP_WINDOW_SIZE. Most other options can be set by an environment variable\n\ -IPERF_, such as IPERF_BANDWIDTH.\n\ -\n\ -Report bugs to \n"; - -#else const char usage_long[] = "\ Usage: iperf [-s|-c host] [options]\n\ iperf [-h|--help] [-v|--version]\n\ @@ -174,13 +116,10 @@ TCP_WINDOW_SIZE. Most other options can be set by an environment variable\n\ IPERF_, such as IPERF_BANDWIDTH.\n\ \n\ Report bugs to \n"; -#endif // include a description of the threading in the version #if defined( HAVE_POSIX_THREAD ) #define IPERF_THREADS "pthreads" -#elif defined( HAVE_WIN32_THREAD ) - #define IPERF_THREADS "win32 threads" #else #define IPERF_THREADS "single threaded" #endif @@ -299,19 +238,11 @@ const char reportCSV_bw_jitter_loss_format[] = "%s,%s,%d,%.1f-%.1f,%lld,%lld,%.3f,%d,%d,%.3f,%d\n"; #endif // HAVE_PRINTF_QD #else // HAVE_QUAD_SUPPORT -#ifdef WIN32 -const char reportCSV_bw_format[] = -"%s,%s,%d,%.1f-%.1f,%I64d,%I64d\n"; - -const char reportCSV_bw_jitter_loss_format[] = -"%s,%s,%d,%.1f-%.1f,%I64d,%I64d,%.3f,%d,%d,%.3f,%d\n"; -#else const char reportCSV_bw_format[] = "%s,%s,%d,%.1f-%.1f,%d,%d\n"; const char reportCSV_bw_jitter_loss_format[] = "%s,%s,%d,%.1f-%.1f,%d,%d,%.3f,%d,%d,%.3f,%d\n"; -#endif //WIN32 #endif //HAVE_QUAD_SUPPORT /* ------------------------------------------------------------------- * warnings diff --git a/src/Settings.cpp b/src/Settings.cpp index 244b2a5..2b71693 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -373,12 +373,7 @@ void Settings_Interpret( char option, const char *optarg, thread_Settings *mExtS break; case 'h': // print help and exit -#ifndef WIN32 fprintf( stderr, usage_long ); -#else - fprintf(stderr, usage_long1); - fprintf(stderr, usage_long2); -#endif exit(1); break; @@ -761,11 +756,7 @@ void Settings_GenerateClientSettings( thread_Settings *server, (*client)->mAmount = ntohl(hdr->mAmount); if ( ((*client)->mAmount & 0x80000000) > 0 ) { setModeTime( (*client) ); -#ifndef WIN32 (*client)->mAmount |= 0xFFFFFFFF00000000LL; -#else - (*client)->mAmount |= 0xFFFFFFFF00000000; -#endif (*client)->mAmount = -(*client)->mAmount; } (*client)->mFileName = NULL; diff --git a/src/main.cpp b/src/main.cpp index f0bb7b2..167aed5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -71,10 +71,6 @@ #include "List.h" #include "util.h" -#ifdef WIN32 -#include "service.h" -#endif - /* ------------------------------------------------------------------- * prototypes * ------------------------------------------------------------------- */ @@ -125,20 +121,6 @@ int main( int argc, char **argv ) { my_signal( SIGTERM, Sig_Interupt ); my_signal( SIGINT, Sig_Interupt ); -#ifndef WIN32 - // Ignore broken pipes - signal(SIGPIPE,SIG_IGN); -#else - // Start winsock - WSADATA wsaData; - int rc = WSAStartup( 0x202, &wsaData ); - WARN_errno( rc == SOCKET_ERROR, "WSAStartup" ); - if (rc == SOCKET_ERROR) - return 0; - - // Tell windows we want to handle our own signals - SetConsoleCtrlHandler( sig_dispatcher, true ); -#endif // Initialize global mutexes and conditions Condition_Initialize ( &ReportCond ); @@ -168,25 +150,6 @@ int main( int argc, char **argv ) { // Check for either having specified client or server if ( ext_gSettings->mThreadMode == kMode_Client || ext_gSettings->mThreadMode == kMode_Listener ) { -#ifdef WIN32 - // Start the server as a daemon - // Daemon mode for non-windows in handled - // in the listener_spawn function - if ( isDaemon( ext_gSettings ) ) { - CmdInstallService(argc, argv); - return 0; - } - - // Remove the Windows service if requested - if ( isRemoveService( ext_gSettings ) ) { - // remove the service - if ( CmdRemoveService() ) { - fprintf(stderr, "IPerf Service is removed.\n"); - - return 0; - } - } -#endif // initialize client(s) if ( ext_gSettings->mThreadMode == kMode_Client ) { client_init( ext_gSettings ); @@ -214,23 +177,6 @@ int main( int argc, char **argv ) { // neither server nor client mode was specified // print usage and exit -#ifdef WIN32 - // In Win32 we also attempt to start a previously defined service - // Starting in 2.0 to restart a previously defined service - // you must call iperf with "iperf -D" or using the environment variable - SERVICE_TABLE_ENTRY dispatchTable[] = - { - { TEXT(SZSERVICENAME), (LPSERVICE_MAIN_FUNCTION)service_main}, - { NULL, NULL} - }; - - // Only attempt to start the service if "-D" was specified - if ( !isDaemon(ext_gSettings) || - // starting the service by SCM, there is no arguments will be passed in. - // the arguments will pass into Service_Main entry. - !StartServiceCtrlDispatcher(dispatchTable) ) - // If the service failed to start then print usage -#endif fprintf( stderr, usage_short, argv[0], argv[0] ); return 0; @@ -278,10 +224,6 @@ void Sig_Interupt( int inSigno ) { * ------------------------------------------------------------------- */ void cleanup( void ) { -#ifdef WIN32 - // Shutdown Winsock - WSACleanup(); -#endif // clean up the list of clients Iperf_destroy ( &clients ); @@ -289,116 +231,3 @@ void cleanup( void ) { thread_destroy( ); } // end cleanup -#ifdef WIN32 -/*-------------------------------------------------------------------- - * ServiceStart - * - * each time starting the service, this is the entry point of the service. - * Start the service, certainly it is on server-mode - * - *-------------------------------------------------------------------- */ -VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv) { - - // report the status to the service control manager. - // - if ( !ReportStatusToSCMgr( - SERVICE_START_PENDING, // service state - NO_ERROR, // exit code - 3000) ) // wait hint - goto clean; - - thread_Settings* ext_gSettings = new thread_Settings; - - // Initialize settings to defaults - Settings_Initialize( ext_gSettings ); - // read settings from environment variables - Settings_ParseEnvironment( ext_gSettings ); - // read settings from command-line parameters - Settings_ParseCommandLine( dwArgc, lpszArgv, ext_gSettings ); - - // report the status to the service control manager. - // - if ( !ReportStatusToSCMgr( - SERVICE_START_PENDING, // service state - NO_ERROR, // exit code - 3000) ) // wait hint - goto clean; - - // if needed, redirect the output into a specified file - if ( !isSTDOUT( ext_gSettings ) ) { - redirect( ext_gSettings->mOutputFileName ); - } - - // report the status to the service control manager. - // - if ( !ReportStatusToSCMgr( - SERVICE_START_PENDING, // service state - NO_ERROR, // exit code - 3000) ) // wait hint - goto clean; - - // initialize client(s) - if ( ext_gSettings->mThreadMode == kMode_Client ) { - client_init( ext_gSettings ); - } - - // start up the reporter and client(s) or listener - { - thread_Settings *into = NULL; -#ifdef HAVE_THREAD - Settings_Copy( ext_gSettings, &into ); - into->mThreadMode = kMode_Reporter; - into->runNow = ext_gSettings; -#else - into = ext_gSettings; -#endif - thread_start( into ); - } - - // report the status to the service control manager. - // - if ( !ReportStatusToSCMgr( - SERVICE_RUNNING, // service state - NO_ERROR, // exit code - 0) ) // wait hint - goto clean; - - clean: - // wait for other (client, server) threads to complete - thread_joinall(); -} - - -// -// FUNCTION: ServiceStop -// -// PURPOSE: Stops the service -// -// PARAMETERS: -// none -// -// RETURN VALUE: -// none -// -// COMMENTS: -// If a ServiceStop procedure is going to -// take longer than 3 seconds to execute, -// it should spawn a thread to execute the -// stop code, and return. Otherwise, the -// ServiceControlManager will believe that -// the service has stopped responding. -// -VOID ServiceStop() { -#ifdef HAVE_THREAD - Sig_Interupt( 1 ); -#else - sig_exit(1); -#endif -} - -#endif - - - - - diff --git a/src/stdio.c b/src/stdio.c index 9d69e96..96782f7 100644 --- a/src/stdio.c +++ b/src/stdio.c @@ -254,24 +254,8 @@ void byte_snprintf( char* outString, int inLen, * return: none * ------------------------------------------------------------------- */ -void redirect(const char *inOutputFileName) { -#ifdef WIN32 - - FILE *fp; - - if ( inOutputFileName == NULL ) { - fprintf(stderr, "should specify the output file name.\n"); - return; - } - - fp = freopen(inOutputFileName, "a+", stdout); - if ( fp == NULL ) { - fprintf(stderr, "redirect stdout failed!\n"); - return; - } - -#endif - +void redirect(const char *inOutputFileName) +{ return; }