static int throttlePipe_sendBuffers( void* opaque, const GoldfishPipeBuffer* buffers, int numBuffers ) { ThrottlePipe* pipe = opaque; int ret; if (pipe->sendExpiration > 0) { return PIPE_ERROR_AGAIN; } ret = pingPongPipe_sendBuffers(&pipe->pingpong, buffers, numBuffers); if (ret > 0) { pipe->sendExpiration = qemu_get_clock_ns(vm_clock) + ret*pipe->sendRate; throttlePipe_rearm(pipe); } return ret; }
static int throttlePipe_sendBuffers( void* opaque, const GoldfishPipeBuffer* buffers, int numBuffers ) { ThrottlePipe* pipe = opaque; int ret; if (pipe->sendExpiration > 0) { return PIPE_ERROR_AGAIN; } ret = pingPongPipe_sendBuffers(&pipe->pingpong, buffers, numBuffers); if (ret > 0) { /* Compute next send expiration time */ pipe->sendExpiration = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ret*pipe->sendRate; throttlePipe_rearm(pipe); } return ret; }