mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-07 14:21:43 +00:00
introduce DISPATCHER_{NONE,ACK,ASYNC}
This commit is contained in:
parent
776bdd6c95
commit
fff04e867c
@ -120,10 +120,12 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
|
||||
} else {
|
||||
red_printf("error: no handler for message type %d\n", type);
|
||||
}
|
||||
if (msg->ack && write_safe(dispatcher->recv_fd,
|
||||
&ack, sizeof(ack)) == -1) {
|
||||
red_printf("error writing ack for message %d\n", type);
|
||||
/* TODO: close socketpair? */
|
||||
if (msg->ack == DISPATCHER_ACK) {
|
||||
if (write_safe(dispatcher->recv_fd,
|
||||
&ack, sizeof(ack)) == -1) {
|
||||
red_printf("error writing ack for message %d\n", type);
|
||||
/* TODO: close socketpair? */
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -159,7 +161,7 @@ void dispatcher_send_message(Dispatcher *dispatcher, uint32_t message_type,
|
||||
message_type);
|
||||
goto unlock;
|
||||
}
|
||||
if (msg->ack) {
|
||||
if (msg->ack == DISPATCHER_ACK) {
|
||||
if (read_safe(send_fd, &ack, sizeof(ack), 1) == -1) {
|
||||
red_printf("error: failed to read ack");
|
||||
} else if (ack != ACK) {
|
||||
|
||||
@ -45,13 +45,22 @@ void dispatcher_send_message(Dispatcher *dispatcher, uint32_t message_type,
|
||||
void dispatcher_init(Dispatcher *dispatcher, size_t max_message_type,
|
||||
void *opaque);
|
||||
|
||||
enum {
|
||||
DISPATCHER_NONE = 0,
|
||||
DISPATCHER_ACK,
|
||||
DISPATCHER_ASYNC
|
||||
};
|
||||
|
||||
/*
|
||||
* dispatcher_register_handler
|
||||
* @dispatcher: dispatcher
|
||||
* @dispatcher: dispatcher
|
||||
* @messsage_type: message type
|
||||
* @handler: message handler
|
||||
* @size: message size. Each type has a fixed associated size.
|
||||
* @ack: send an ack. This is per message type - you can't send the
|
||||
* @ack: One of DISPATCHER_NONE, DISPATCHER_ACK, DISPATCHER_ASYNC.
|
||||
* DISPATCHER_NONE - only send the message
|
||||
* DISPATCHER_ACK - send an ack after the message
|
||||
* DISPATCHER_ASYNC - call send an ack. This is per message type - you can't send the
|
||||
* same message type with and without. Register two different
|
||||
* messages if that is what you want.
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user