X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fpazpar2_play.c;h=622885a873b19f34a62cd024e950c28175942cb5;hb=e1e528d4e6e3a4311d8b8f0dec6664e798be31c0;hp=298a3d38d865849f8839a7c329994469c0fe7a6f;hpb=9b8a842cb328ac45bff04dae8f7e564ba1fc3b3e;p=pazpar2-moved-to-github.git 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;