Skip to content

Commit 5c2f156

Browse files
committed
Chore new version v3.16
1 parent 31674f7 commit 5c2f156

13 files changed

+704
-204
lines changed

Sources/IperfCLib/include/iperf.h

+33-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* iperf, Copyright (c) 2014-2020, The Regents of the University of
2+
* iperf, Copyright (c) 2014-2020, 2023, The Regents of the University of
33
* California, through Lawrence Berkeley National Laboratory (subject
44
* to receipt of any required approvals from the U.S. Dept. of
55
* Energy). All rights reserved.
@@ -67,21 +67,36 @@
6767
#include "queue.h"
6868
#include "cjson.h"
6969
#include "iperf_time.h"
70+
#include <File.h>
7071

7172
#if defined(HAVE_SSL)
7273
#include <openssl/bio.h>
7374
#include <openssl/evp.h>
7475
#endif // HAVE_SSL
7576

76-
#include <File.h>
77+
#ifdef HAVE_PTHREAD
78+
#include <pthread.h>
79+
#endif // HAVE_PTHREAD
80+
81+
/*
82+
* Atomic types highly desired, but if not, we approximate what we need
83+
* with normal integers and warn.
84+
*/
85+
#ifdef HAVE_STDATOMIC_H
86+
#include <stdatomic.h>
87+
#else
88+
#warning "No <stdatomic.h> available."
89+
typedef uint64_t atomic_uint_fast64_t;
90+
#endif // HAVE_STDATOMIC_H
7791

7892
#if !defined(__IPERF_API_H)
79-
typedef uint64_t iperf_size_t;
93+
typedef uint_fast64_t iperf_size_t;
94+
typedef atomic_uint_fast64_t atomic_iperf_size_t;
8095
#endif // __IPERF_API_H
8196

8297
struct iperf_interval_results
8398
{
84-
iperf_size_t bytes_transferred; /* bytes transferred in this interval */
99+
atomic_iperf_size_t bytes_transferred; /* bytes transferred in this interval */
85100
struct iperf_time interval_start_time;
86101
struct iperf_time interval_end_time;
87102
float interval_duration;
@@ -115,11 +130,11 @@ struct iperf_interval_results
115130

116131
struct iperf_stream_result
117132
{
118-
iperf_size_t bytes_received;
119-
iperf_size_t bytes_sent;
120-
iperf_size_t bytes_received_this_interval;
121-
iperf_size_t bytes_sent_this_interval;
122-
iperf_size_t bytes_sent_omit;
133+
atomic_iperf_size_t bytes_received;
134+
atomic_iperf_size_t bytes_sent;
135+
atomic_iperf_size_t bytes_received_this_interval;
136+
atomic_iperf_size_t bytes_sent_this_interval;
137+
atomic_iperf_size_t bytes_sent_omit;
123138
long stream_prev_total_retrans;
124139
long stream_retrans;
125140
long stream_max_rtt;
@@ -177,6 +192,9 @@ struct iperf_stream
177192
{
178193
struct iperf_test* test;
179194

195+
pthread_t thr;
196+
int done;
197+
180198
/* configurable members */
181199
int local_port;
182200
int remote_port;
@@ -269,6 +287,8 @@ enum debug_level {
269287

270288
struct iperf_test
271289
{
290+
pthread_mutex_t print_mutex;
291+
272292
char role; /* 'c' lient or 's' erver */
273293
enum iperf_mode mode;
274294
int sender_has_retransmits;
@@ -354,11 +374,11 @@ struct iperf_test
354374

355375
int num_streams; /* total streams in the test (-P) */
356376

357-
iperf_size_t bytes_sent;
358-
iperf_size_t blocks_sent;
377+
atomic_iperf_size_t bytes_sent;
378+
atomic_iperf_size_t blocks_sent;
359379

360-
iperf_size_t bytes_received;
361-
iperf_size_t blocks_received;
380+
atomic_iperf_size_t bytes_received;
381+
atomic_iperf_size_t blocks_received;
362382

363383
iperf_size_t bitrate_limit_stats_count; /* Number of stats periods accumulated for server's total bitrate average */
364384
iperf_size_t *bitrate_limit_intervals_traffic_bytes; /* Pointer to a cyclic array that includes the last interval's bytes transferred */

Sources/IperfCLib/include/iperf_api.h

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* iperf, Copyright (c) 2014-2022, The Regents of the University of
2+
* iperf, Copyright (c) 2014-2023, The Regents of the University of
33
* California, through Lawrence Berkeley National Laboratory (subject
44
* to receipt of any required approvals from the U.S. Dept. of
55
* Energy). All rights reserved.
@@ -38,6 +38,16 @@
3838
extern "C" { /* open extern "C" */
3939
#endif
4040

41+
/*
42+
* Atomic types highly desired, but if not, we approximate what we need
43+
* with normal integers and warn.
44+
*/
45+
#ifdef HAVE_STDATOMIC_H
46+
#include <stdatomic.h>
47+
#else
48+
#warning "No <stdatomic.h> available"
49+
typedef u_int64_t atomic_uint_fast64_t;
50+
#endif // HAVE_STDATOMIC_H
4151

4252
struct iperf_test;
4353
struct iperf_stream_result;
@@ -46,7 +56,8 @@ struct iperf_stream;
4656
struct iperf_time;
4757

4858
#if !defined(__IPERF_H)
49-
typedef uint64_t iperf_size_t;
59+
typedef uint_fast64_t iperf_size_t;
60+
typedef atomic_uint_fast64_t atomic_iperf_size_t;
5061
#endif // __IPERF_H
5162

5263
/* default settings */
@@ -200,6 +211,10 @@ void iperf_set_dont_fragment( struct iperf_test* ipt, int dont_fragment );
200211
void iperf_set_test_congestion_control(struct iperf_test* ipt, char* cc);
201212
void iperf_set_test_mss(struct iperf_test* ipt, int mss);
202213
void iperf_set_mapped_v4(struct iperf_test* ipt, const int val);
214+
void iperf_set_on_new_stream_callback(struct iperf_test* ipt, void (*callback)());
215+
void iperf_set_on_test_start_callback(struct iperf_test* ipt, void (*callback)());
216+
void iperf_set_on_test_connect_callback(struct iperf_test* ipt, void (*callback)());
217+
void iperf_set_on_test_finish_callback(struct iperf_test* ipt, void (*callback)());
203218

204219
#if defined(HAVE_SSL)
205220
void iperf_set_test_client_username(struct iperf_test *ipt, const char *client_username);
@@ -306,8 +321,8 @@ void build_tcpinfo_message(struct iperf_interval_results *r, char *message);
306321

307322
int iperf_set_send_state(struct iperf_test *test, signed char state);
308323
void iperf_check_throttle(struct iperf_stream *sp, struct iperf_time *nowP);
309-
int iperf_send(struct iperf_test *, fd_set *) /* __attribute__((hot)) */;
310-
int iperf_recv(struct iperf_test *, fd_set *);
324+
int iperf_send_mt(struct iperf_stream *) /* __attribute__((hot)) */;
325+
int iperf_recv_mt(struct iperf_stream *);
311326
void iperf_catch_sigend(void (*handler)(int));
312327
void iperf_got_sigend(struct iperf_test *test) __attribute__ ((noreturn));
313328
void usage(void);
@@ -402,6 +417,7 @@ enum {
402417
IERVRSONLYRCVTIMEOUT = 32, // Client receive timeout is valid only in reverse mode
403418
IESNDTIMEOUT = 33, // Illegal message send timeout
404419
IEUDPFILETRANSFER = 34, // Cannot transfer file using UDP
420+
IESERVERAUTHUSERS = 35, // Cannot access authorized users file
405421
/* Test errors */
406422
IENEWTEST = 100, // Unable to create a new test (check perror)
407423
IEINITTEST = 101, // Test initialization failed (check perror)
@@ -452,6 +468,11 @@ enum {
452468
IEBINDDEVNOSUPPORT = 146, // `ip%%dev` is not supported as system does not support bind to device
453469
IEHOSTDEV = 147, // host device name (ip%%<dev>) is supported (and required) only for IPv6 link-local address
454470
IESETUSERTIMEOUT = 148, // Unable to set TCP USER_TIMEOUT (check perror)
471+
IEPTHREADCREATE=150, // Unable to create thread (check perror)
472+
IEPTHREADCANCEL=151, // Unable to cancel thread (check perror)
473+
IEPTHREADJOIN=152, // Unable to join thread (check perror)
474+
IEPTHREADATTRINIT=153, // Unable to initialize thread attribute (check perror)
475+
IEPTHREADATTRDESTROY=154, // Unable to destroy thread attribute (check perror)
455476
/* Stream errors */
456477
IECREATESTREAM = 200, // Unable to create a new stream (check herror/perror)
457478
IEINITSTREAM = 201, // Unable to initialize stream (check herror/perror)

Sources/IperfCLib/include/iperf_config.h

+16-3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
/* Define to 1 if you have the <poll.h> header file. */
5050
#define HAVE_POLL_H 1
5151

52+
/* Define if you have POSIX threads libraries and header files. */
53+
#define HAVE_PTHREAD 1
54+
55+
/* Have PTHREAD_PRIO_INHERIT. */
56+
#define HAVE_PTHREAD_PRIO_INHERIT 1
57+
5258
/* Define to 1 if you have the `sched_setaffinity' function. */
5359
/* #undef HAVE_SCHED_SETAFFINITY */
5460

@@ -70,6 +76,9 @@
7076
/* OpenSSL Is Available */
7177
#define HAVE_SSL 1
7278

79+
/* Define to 1 if you have the <stdatomic.h> header file. */
80+
#define HAVE_STDATOMIC_H 1
81+
7382
/* Define to 1 if you have the <stdint.h> header file. */
7483
#define HAVE_STDINT_H 1
7584

@@ -125,7 +134,7 @@
125134
#define PACKAGE_NAME "iperf"
126135

127136
/* Define to the full name and version of this package. */
128-
#define PACKAGE_STRING "iperf 3.14"
137+
#define PACKAGE_STRING "iperf 3.16"
129138

130139
/* Define to the one symbol short name of this package. */
131140
#define PACKAGE_TARNAME "iperf"
@@ -134,15 +143,19 @@
134143
#define PACKAGE_URL "https://software.es.net/iperf/"
135144

136145
/* Define to the version of this package. */
137-
#define PACKAGE_VERSION "3.14"
146+
#define PACKAGE_VERSION "3.16"
147+
148+
/* Define to necessary symbol if this constant uses a non-standard name on
149+
your system. */
150+
/* #undef PTHREAD_CREATE_JOINABLE */
138151

139152
/* Define to 1 if all of the C90 standard headers exist (not just the ones
140153
required in a freestanding environment). This macro is provided for
141154
backward compatibility; new code need not use it. */
142155
#define STDC_HEADERS 1
143156

144157
/* Version number of package */
145-
#define VERSION "3.14"
158+
#define VERSION "3.16"
146159

147160
/* Define to empty if `const' does not conform to ANSI C. */
148161
/* #undef const */

Sources/IperfCLib/include/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
* This code is distributed under a BSD style license, see the LICENSE
2525
* file for complete information.
2626
*/
27-
#define IPERF_VERSION "3.14"
27+
#define IPERF_VERSION "3.16"

0 commit comments

Comments
 (0)