iperf: add patch from [http://lkml.org/lkml/2007/9/26/132 LKML] to fix locking bugs...
authorGabor Juhos <juhosg@openwrt.org>
Tue, 2 Oct 2007 14:02:38 +0000 (14:02 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Tue, 2 Oct 2007 14:02:38 +0000 (14:02 +0000)
SVN-Revision: 9093

net/iperf/Makefile
net/iperf/patches/001-locking_fixes.patch [new file with mode: 0755]
net/iperf/patches/001-thread_library_fix.patch [deleted file]

index 7dc40cf59dc4bcb42d96735f537545cc2c5aad25..bdb8994da082970b2c121ce39bc4d0cf8c92f59f 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=iperf
 PKG_VERSION:=2.0.2
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://dast.nlanr.net/Projects/Iperf2.0
diff --git a/net/iperf/patches/001-locking_fixes.patch b/net/iperf/patches/001-locking_fixes.patch
new file mode 100755 (executable)
index 0000000..a297130
--- /dev/null
@@ -0,0 +1,92 @@
+===================================================================
+--- iperf-2.0.2.orig/compat/Thread.c
++++ iperf-2.0.2/compat/Thread.c
+@@ -405,9 +405,6 @@ int thread_numuserthreads( void ) {
+ void thread_rest ( void ) {
+ #if defined( HAVE_THREAD )
+ #if defined( HAVE_POSIX_THREAD )
+-    // TODO add checks for sched_yield or pthread_yield and call that
+-    // if available
+-    usleep( 0 );
+ #else // Win32
+     SwitchToThread( );
+ #endif
+Index: iperf-2.0.2/src/Reporter.c
+===================================================================
+--- iperf-2.0.2.orig/src/Reporter.c
++++ iperf-2.0.2/src/Reporter.c
+@@ -111,6 +111,7 @@ report_statistics multiple_reports[kRepo
+ char buffer[64]; // Buffer for printing
+ ReportHeader *ReportRoot = NULL;
+ extern Condition ReportCond;
++extern Condition ReportDoneCond;
+ int reporter_process_report ( ReportHeader *report );
+ void process_report ( ReportHeader *report );
+ int reporter_handle_packet( ReportHeader *report );
+@@ -338,7 +339,7 @@ void ReportPacket( ReportHeader* agent, 
+             // item
+             while ( index == 0 ) {
+                 Condition_Signal( &ReportCond );
+-                thread_rest();
++                Condition_Wait( &ReportDoneCond );
+                 index = agent->reporterindex;
+             }
+             agent->agentindex = 0;
+@@ -346,7 +347,7 @@ void ReportPacket( ReportHeader* agent, 
+         // Need to make sure that reporter is not about to be "lapped"
+         while ( index - 1 == agent->agentindex ) {
+             Condition_Signal( &ReportCond );
+-            thread_rest();
++            Condition_Wait( &ReportDoneCond );
+             index = agent->reporterindex;
+         }
+         
+@@ -553,6 +554,7 @@ void reporter_spawn( thread_Settings *th
+         }
+         Condition_Unlock ( ReportCond );
++again:
+         if ( ReportRoot != NULL ) {
+             ReportHeader *temp = ReportRoot;
+             //Condition_Unlock ( ReportCond );
+@@ -575,9 +577,12 @@ void reporter_spawn( thread_Settings *th
+                 // finished with report so free it
+                 free( temp );
+                 Condition_Unlock ( ReportCond );
++              Condition_Signal( &ReportDoneCond );
++              if (ReportRoot)
++                      goto again;
+             }
+-            // yield control of CPU is another thread is waiting
+-            thread_rest();
++            Condition_Signal( &ReportDoneCond );
++            usleep(10000);
+         } else {
+             //Condition_Unlock ( ReportCond );
+         }
+Index: iperf-2.0.2/src/main.cpp
+===================================================================
+--- iperf-2.0.2.orig/src/main.cpp
++++ iperf-2.0.2/src/main.cpp
+@@ -96,6 +96,7 @@ extern "C" {
+     // records being accessed in a report and also to
+     // serialize modification of the report list
+     Condition ReportCond;
++    Condition ReportDoneCond;
+ }
+ // global variables only accessed within this file
+@@ -141,6 +142,7 @@ int main( int argc, char **argv ) {
+     // Initialize global mutexes and conditions
+     Condition_Initialize ( &ReportCond );
++    Condition_Initialize ( &ReportDoneCond );
+     Mutex_Initialize( &groupCond );
+     Mutex_Initialize( &clients_mutex );
+-
+To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
+the body of a message to majordomo@vger.kernel.org
+More majordomo info at  http://vger.kernel.org/majordomo-info.html
+Please read the FAQ at  http://www.tux.org/lkml/
+
diff --git a/net/iperf/patches/001-thread_library_fix.patch b/net/iperf/patches/001-thread_library_fix.patch
deleted file mode 100644 (file)
index 7cd9a3f..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-Index: iperf-2.0.2/compat/Thread.c
-===================================================================
---- iperf-2.0.2.orig/compat/Thread.c   2007-09-26 15:01:48.000000000 +0200
-+++ iperf-2.0.2/compat/Thread.c        2007-09-26 15:01:49.000000000 +0200
-@@ -405,9 +405,13 @@
- void thread_rest ( void ) {
- #if defined( HAVE_THREAD )
- #if defined( HAVE_POSIX_THREAD )
--    // TODO add checks for sched_yield or pthread_yield and call that
--    // if available
-+
-+#if defined( _POSIX_PRIORITY_SCHEDULING )
-+    sched_yield();
-+#else
-     usleep( 0 );
-+#endif
-+
- #else // Win32
-     SwitchToThread( );
- #endif