180 lines
4.3 KiB
Diff
180 lines
4.3 KiB
Diff
--- trickle-1.07.orig/trickled.8
|
|
+++ trickle-1.07/trickled.8
|
|
@@ -101,6 +101,7 @@
|
|
is at eliminating bandwidth consumption peaks. Lower values will be
|
|
more aggressive, but may also result in over shaping. The default
|
|
value (512 KB) is usually sufficient.
|
|
+.El
|
|
.Sh EXAMPLES
|
|
.Cm trickled -u 10 -d 20
|
|
.Pp
|
|
@@ -137,4 +138,4 @@
|
|
.\" .Xr kqueue 2 .
|
|
.\" Please report any bugs to Marius Aamodt Eriksen
|
|
.\" .Aq marius@monkey.org .
|
|
-.\" .Sh CAVEATS
|
|
\ No newline at end of file
|
|
+.\" .Sh CAVEATS
|
|
--- trickle-1.07.orig/trickled.conf.5
|
|
+++ trickle-1.07/trickled.conf.5
|
|
@@ -38,6 +38,7 @@
|
|
Sets the length smoothing parameter of the application, see
|
|
.Xr trickled 8
|
|
for details.
|
|
+.El
|
|
.Sh EXAMPLES
|
|
.Pp
|
|
.nf
|
|
--- trickle-1.07.orig/trickle-overload.c
|
|
+++ trickle-1.07/trickle-overload.c
|
|
@@ -144,6 +144,9 @@
|
|
DECLARE(sendfile, ssize_t, (int, int, off_t *, size_t));
|
|
#endif
|
|
|
|
+DECLARE(fread, size_t, (void *, size_t, size_t, FILE *));
|
|
+DECLARE(fwrite, size_t, (const void *, size_t, size_t, FILE *));
|
|
+
|
|
static int delay(int, ssize_t *, short);
|
|
static struct timeval *getdelay(struct sockdesc *, ssize_t *, short);
|
|
static void update(int, ssize_t, short);
|
|
@@ -225,6 +228,9 @@
|
|
GETADDR(sendfile);
|
|
#endif
|
|
|
|
+ GETADDR(fread);
|
|
+ GETADDR(fwrite);
|
|
+
|
|
/* XXX pthread test */
|
|
/* if ((dh = dlopen("/usr/lib/libpthread.so.1.0", RTLD_LAZY)) == NULL) */
|
|
/* errx(1, "[trickle] Failed to open libpthread"); */
|
|
@@ -302,7 +308,9 @@
|
|
domain, type, protocol, sock);
|
|
#endif /* DEBUG */
|
|
|
|
- if (sock != -1 && domain == AF_INET && type == SOCK_STREAM) {
|
|
+ if (sock != -1
|
|
+ && (domain == AF_INET || domain == AF_INET6)
|
|
+ && type == SOCK_STREAM) {
|
|
if ((sd = calloc(1, sizeof(*sd))) == NULL)
|
|
return (-1);
|
|
if ((sd->stat = bwstat_new()) == NULL) {
|
|
@@ -1027,6 +1035,68 @@
|
|
}
|
|
#endif /* HAVE_SENDFILE */
|
|
|
|
+size_t
|
|
+fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
|
+{
|
|
+ size_t ret = -1;
|
|
+ size_t xnbytes = size * nmemb;
|
|
+ int eagain;
|
|
+
|
|
+ INIT;
|
|
+
|
|
+ if (!(eagain = delay(fileno(stream), &xnbytes, TRICKLE_RECV)
|
|
+ == TRICKLE_WOULDBLOCK)) {
|
|
+ ret = (*libc_fread)(ptr, size, nmemb, stream);
|
|
+#ifdef DEBUG
|
|
+ safe_printv(0, "[DEBUG] fread(%d, *, %d) = %d", fileno(stream),
|
|
+ xnbytes, ret);
|
|
+ } else {
|
|
+ safe_printv(0, "[DEBUG] delaying fread(%d, *, %d) = %d",
|
|
+ fileno(stream), xnbytes, ret);
|
|
+#endif /* DEBUG */
|
|
+ }
|
|
+
|
|
+ update(fileno(stream), ret, TRICKLE_RECV);
|
|
+
|
|
+ if (eagain) {
|
|
+ ret = -1;
|
|
+ errno = EAGAIN;
|
|
+ }
|
|
+
|
|
+ return (ret);
|
|
+}
|
|
+
|
|
+size_t
|
|
+fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
|
|
+{
|
|
+ size_t ret = -1;
|
|
+ size_t xlen = size * nmemb;
|
|
+ int eagain;
|
|
+
|
|
+ INIT;
|
|
+
|
|
+ if (!(eagain = delay(fileno(stream), &xlen, TRICKLE_SEND)
|
|
+ == TRICKLE_WOULDBLOCK)) {
|
|
+ ret = (*libc_fwrite)(ptr, size, nmemb, stream);
|
|
+#ifdef DEBUG
|
|
+ safe_printv(0, "[DEBUG] fwrite(%d, *, %d) = %d", fileno(stream),
|
|
+ xlen, ret);
|
|
+ } else {
|
|
+ safe_printv(0, "[DEBUG] delaying fwrite(%d, *, %d)",
|
|
+ fileno(stream), xlen);
|
|
+#endif /* DEBUG */
|
|
+ }
|
|
+
|
|
+ update(fileno(stream), ret, TRICKLE_SEND);
|
|
+
|
|
+ if (eagain) {
|
|
+ errno = EAGAIN;
|
|
+ ret = -1;
|
|
+ }
|
|
+
|
|
+ return (ret);
|
|
+}
|
|
+
|
|
static int
|
|
delay(int sock, ssize_t *len, short which)
|
|
{
|
|
--- trickle-1.07.orig/trickled.conf
|
|
+++ trickle-1.07/trickled.conf
|
|
@@ -0,0 +1,12 @@
|
|
+# this file is an example for a system-wide or personal settings file
|
|
+# for trickle (see manual pages for trickle, trickled and trickled.conf
|
|
+# below are two examples that should be self-explaining
|
|
+
|
|
+# [ssh]
|
|
+# Priority = 1
|
|
+# Time-Smoothing = 0.1
|
|
+# Length-Smoothing = 2
|
|
+# [ftp]
|
|
+# Priority = 8
|
|
+# Time-Smoothing = 5
|
|
+# Length-Smoothing = 20
|
|
--- trickle-1.07.orig/test.c
|
|
+++ trickle-1.07/test.c
|
|
@@ -0,0 +1,20 @@
|
|
+#include <sys/types.h>
|
|
+
|
|
+#ifdef HAVE_CONFIG_H
|
|
+#include "config.h"
|
|
+#endif /* HAVE_CONFIG_H */
|
|
+
|
|
+#include <sys/tree.h>
|
|
+#include <sys/queue.h>
|
|
+#include <sys/socket.h>
|
|
+#include <sys/un.h>
|
|
+#include <sys/uio.h>
|
|
+#include <sys/stat.h>
|
|
+#include <sys/param.h>
|
|
+#ifdef HAVE_SYS_TIME_H
|
|
+#include <sys/time.h>
|
|
+#endif /* HAVE_SYS_TIME_H */
|
|
+
|
|
+#include <netinet/in.h>
|
|
+#include <netinet/in_systm.h>
|
|
+
|
|
--- trickle-1.07.orig/config.h.in
|
|
+++ trickle-1.07/config.h.in
|
|
@@ -128,9 +128,6 @@
|
|
/* Define to empty if `const' does not conform to ANSI C. */
|
|
#undef const
|
|
|
|
-/* Define to `unsigned long' if <sys/types.h> does not define. */
|
|
-#undef in_addr_t
|
|
-
|
|
/* Define to `int' if <sys/types.h> does not define. */
|
|
#undef pid_t
|
|
|