Revision c874ea97 hw/usb/redirect.c
b/hw/usb/redirect.c | ||
---|---|---|
104 | 104 |
/* Data passed from chardev the fd_read cb to the usbredirparser read cb */ |
105 | 105 |
const uint8_t *read_buf; |
106 | 106 |
int read_buf_size; |
107 |
/* Active chardev-watch-tag */ |
|
108 |
guint watch; |
|
107 | 109 |
/* For async handling of close */ |
108 | 110 |
QEMUBH *chardev_close_bh; |
109 | 111 |
/* To delay the usb attach in case of quick chardev close + open */ |
... | ... | |
254 | 256 |
return count; |
255 | 257 |
} |
256 | 258 |
|
259 |
static gboolean usbredir_write_unblocked(GIOChannel *chan, GIOCondition cond, |
|
260 |
void *opaque) |
|
261 |
{ |
|
262 |
USBRedirDevice *dev = opaque; |
|
263 |
|
|
264 |
dev->watch = 0; |
|
265 |
usbredirparser_do_write(dev->parser); |
|
266 |
|
|
267 |
return FALSE; |
|
268 |
} |
|
269 |
|
|
257 | 270 |
static int usbredir_write(void *priv, uint8_t *data, int count) |
258 | 271 |
{ |
259 | 272 |
USBRedirDevice *dev = priv; |
273 |
int r; |
|
260 | 274 |
|
261 | 275 |
if (!dev->cs->be_open) { |
262 | 276 |
return 0; |
... | ... | |
267 | 281 |
return 0; |
268 | 282 |
} |
269 | 283 |
|
270 |
return qemu_chr_fe_write(dev->cs, data, count); |
|
284 |
r = qemu_chr_fe_write(dev->cs, data, count); |
|
285 |
if (r < count) { |
|
286 |
if (!dev->watch) { |
|
287 |
dev->watch = qemu_chr_fe_add_watch(dev->cs, G_IO_OUT, |
|
288 |
usbredir_write_unblocked, dev); |
|
289 |
} |
|
290 |
if (r < 0) { |
|
291 |
r = 0; |
|
292 |
} |
|
293 |
} |
|
294 |
return r; |
|
271 | 295 |
} |
272 | 296 |
|
273 | 297 |
/* |
... | ... | |
1085 | 1109 |
usbredirparser_destroy(dev->parser); |
1086 | 1110 |
dev->parser = NULL; |
1087 | 1111 |
} |
1112 |
if (dev->watch) { |
|
1113 |
g_source_remove(dev->watch); |
|
1114 |
dev->watch = 0; |
|
1115 |
} |
|
1088 | 1116 |
} |
1089 | 1117 |
|
1090 | 1118 |
static void usbredir_create_parser(USBRedirDevice *dev) |
... | ... | |
1317 | 1345 |
if (dev->parser) { |
1318 | 1346 |
usbredirparser_destroy(dev->parser); |
1319 | 1347 |
} |
1348 |
if (dev->watch) { |
|
1349 |
g_source_remove(dev->watch); |
|
1350 |
} |
|
1320 | 1351 |
|
1321 | 1352 |
free(dev->filter_rules); |
1322 | 1353 |
} |
Also available in: Unified diff