diff options
author | Boris Okunev <hait.08@mail.ru> | 2017-11-13 23:54:34 +0300 |
---|---|---|
committer | Bruce A. Mah <bmah@kitchenlab.org> | 2017-11-13 12:54:34 -0800 |
commit | 5b27ea39a72617734373ca1b42c251949f6b51fe (patch) | |
tree | 209f0e930578d2edb0e2f3a6414528c5a50c740c /src | |
parent | 480824e3c1c13d3ba9f918235491291b72fd25a1 (diff) | |
download | iperf3-5b27ea39a72617734373ca1b42c251949f6b51fe.tar.gz |
Implemented -A flag for Windows (#665)
TODO: Need to update some documentation that reflects `-A` is applicable to Windows. @bmah888 to do this.
Diffstat (limited to 'src')
-rwxr-xr-x | src/iperf_api.c | 24 | ||||
-rw-r--r-- | src/iperf_config.h.in | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/iperf_api.c b/src/iperf_api.c index 722af37..b3d8acd 100755 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -62,6 +62,10 @@ #include <sys/cpuset.h> #endif /* HAVE_CPUSET_SETAFFINITY */ +#if defined(HAVE_SETPROCESSAFFINITYMASK) +#include <Windows.h> +#endif /* HAVE_SETPROCESSAFFINITYMASK */ + #include "net.h" #include "iperf.h" #include "iperf_api.h" @@ -3576,6 +3580,15 @@ iperf_setaffinity(struct iperf_test *test, int affinity) return -1; } return 0; +#elif defined(HAVE_SETPROCESSAFFINITYMASK) + HANDLE process = GetCurrentProcess(); + DWORD_PTR processAffinityMask = 1 << affinity; + + if (SetProcessAffinityMask(process, processAffinityMask) == 0) { + i_errno = IEAFFINITY; + return -1; + } + return 0; #else /* neither HAVE_SCHED_SETAFFINITY nor HAVE_CPUSET_SETAFFINITY */ i_errno = IEAFFINITY; return -1; @@ -3604,6 +3617,17 @@ iperf_clearaffinity(struct iperf_test *test) return -1; } return 0; +#elif defined(HAVE_SETPROCESSAFFINITYMASK) + HANDLE process = GetCurrentProcess(); + DWORD_PTR processAffinityMask; + DWORD_PTR lpSystemAffinityMask; + + if (GetProcessAffinityMask(process, &processAffinityMask, &lpSystemAffinityMask) == 0 + || SetProcessAffinityMask(process, lpSystemAffinityMask) == 0) { + i_errno = IEAFFINITY; + return -1; + } + return 0; #else /* neither HAVE_SCHED_SETAFFINITY nor HAVE_CPUSET_SETAFFINITY */ i_errno = IEAFFINITY; return -1; diff --git a/src/iperf_config.h.in b/src/iperf_config.h.in index 438d672..2d13f98 100644 --- a/src/iperf_config.h.in +++ b/src/iperf_config.h.in @@ -42,6 +42,9 @@ /* Define to 1 if you have the `sendfile' function. */ #undef HAVE_SENDFILE +/* Define to 1 if you have the `SetProcessAffinityMask' function. */ +#undef HAVE_SETPROCESSAFFINITYMASK + /* Have SO_MAX_PACING_RATE sockopt. */ #undef HAVE_SO_MAX_PACING_RATE |