From: Adam Dickmeiss Date: Sat, 26 Mar 2011 22:54:11 +0000 (+0100) Subject: pazpar2_play takes timings into account X-Git-Tag: v1.5.5~4^2 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=63771e0c2740834e4496fb6793d058b9b369ad07;p=pazpar2-moved-to-github.git pazpar2_play takes timings into account It only takes diffs into account not overhead for read/write calls. --- diff --git a/src/pazpar2_play.c b/src/pazpar2_play.c index 298a3d3..622885a 100644 --- a/src/pazpar2_play.c +++ b/src/pazpar2_play.c @@ -21,7 +21,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #endif +#include #include +#include #include #include #include @@ -41,9 +43,10 @@ struct con { static int run(FILE *inf, struct addrinfo *res) { - long long tv_sec0; - long long tv_usec0; + long long tv_sec0 = 0; + long long tv_usec0 = 0; struct con *cons = 0; + while (1) { long long tv_sec1; @@ -69,6 +72,23 @@ static int run(FILE *inf, struct addrinfo *res) fprintf(stderr, "bad line %s\n", req); return -1; } + if (tv_sec0) + { + struct timeval spec; + + spec.tv_sec = tv_sec1 - tv_sec0; + if (tv_usec0 > tv_usec1) + { + spec.tv_usec = 1000000 + tv_usec1 - tv_usec0; + spec.tv_sec--; + } + else + spec.tv_usec = tv_usec1 - tv_usec0; + + select(0, 0, 0, 0, &spec); + } + tv_sec0 = tv_sec1; + tv_usec0 = tv_usec1; for (conp = &cons; *conp; conp = &(*conp)->next) if ((*conp)->id == id) break;