[PATCH 5/9] ftpd: Fairplay with libbsd
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Apr 30 09:48:13 UTC 2018
Update #3419.
---
cpukit/ftpd/ftpd.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/cpukit/ftpd/ftpd.c b/cpukit/ftpd/ftpd.c
index 0d4256bc23..3e0ff5d30a 100644
--- a/cpukit/ftpd/ftpd.c
+++ b/cpukit/ftpd/ftpd.c
@@ -199,6 +199,7 @@
#include <errno.h>
#include <ctype.h>
#include <inttypes.h>
+#include <sched.h>
#include <rtems.h>
#include <rtems/rtems_bsdnet.h>
@@ -305,6 +306,19 @@ static int ftpd_timeout = 0;
*/
static int ftpd_access = 0;
+static void
+yield(void)
+{
+/*
+ * If we build not for the legacy network stack, then we use the libbsd. In
+ * the libbsd there is no global network stack semaphore which provides round
+ * robin fairness for threads of equal priority.
+ */
+#ifndef RTEMS_NETWORKING
+ yield();
+#endif
+}
+
/*
* serr
*
@@ -786,6 +800,7 @@ command_retrieve(FTPD_SessionInfo_t *info, char const *filename)
{
if(send(s, buf, n, 0) != n)
break;
+ yield();
}
}
else if (info->xfer_mode == TYPE_A)
@@ -821,6 +836,7 @@ command_retrieve(FTPD_SessionInfo_t *info, char const *filename)
}
}
while((rest -= i) > 0);
+ yield();
}
}
@@ -1014,6 +1030,7 @@ command_store(FTPD_SessionInfo_t *info, char const *filename)
res = 0;
break;
}
+ yield();
}
}
else if(info->xfer_mode == TYPE_A)
@@ -1075,6 +1092,7 @@ command_store(FTPD_SessionInfo_t *info, char const *filename)
res = 0;
}
while((rest -= i) > 0);
+ yield();
}
}
--
2.12.3
More information about the devel
mailing list