Re: [PATCH spice-gtk V3 1/3] file-xfer: handling various transfer messages in main channel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

----- Mensaje original -----
> >> +static gboolean send_data(gpointer opaque)
> >> +{
> >> +#define FILE_XFER_CHUNK_SIZE (VD_AGENT_MAX_DATA_SIZE -
> >> sizeof(VDAgentMessage))
> >> +    SpiceFileXferTask *task = (SpiceFileXferTask *)opaque;
> >> +
> >> +    SpiceMainChannel *channel =
> >> SPICE_MAIN_CHANNEL(task->channel);
> >> +    SpiceMainChannelPrivate *c = channel->priv;
> >> +    gssize len;
> >> +    GError *error = NULL;
> >> +    VDAgentFileXferDataMessage *msg;
> >> +    uint32_t msg_size;
> >> +
> >> +    if (!g_queue_is_empty(c->agent_msg_queue)) {
> >> +        spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE);
> >> +        return TRUE;
> >
> >
> > You can't use Idle functions this way, you are going to busy-loop.
> > You need
> > to handle filling the queue differently.
> >
> I  knew this way is not good, but I cant find a better way to handle
> it. What about using g_io_scheduler_push_job() to fill data into msg
> queue.
> e.g.:
> 
> // gio thread context
> static gboolean send_data()
> {
>     // code
> 
>     for (;;) {
>         if (agent msg queue is not empty) {
>             // wait for 1ms until msg queue become empty, so that
>             other messages
>             // can still get through.
>             usleep(1000);
>             continue;
>         }

Why not call spice_channel_flush_async() and wait for the channel data to be sent? I think that could do the trick.
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]