[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC Patch v3 07/18] blktap2: don't return negative event id
If we find some error when registering a new event, we will return a negative value. So we should skip negative event id. Also fix a wrong check of return value. Signed-off-by: Wen Congyang <wency@xxxxxxxxxxxxxx> Cc: Shriram Rajagopalan <rshriram@xxxxxxxxx> --- tools/blktap2/drivers/scheduler.c | 8 ++++---- tools/blktap2/drivers/tapdisk-control.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/blktap2/drivers/scheduler.c b/tools/blktap2/drivers/scheduler.c index dd608dd..e07528b 100644 --- a/tools/blktap2/drivers/scheduler.c +++ b/tools/blktap2/drivers/scheduler.c @@ -167,15 +167,15 @@ get_free_id(scheduler_t *s) int old_uuid = s->uuid; int id = s->uuid++; - if (!s->uuid) - s->uuid++; + if (s->uuid < 0) + s->uuid = 1; retry: scheduler_for_each_event(s, event, tmp) if (event->id == id) { id = s->uuid++; - if (!s->uuid) - s->uuid++; + if (s->uuid < 0) + s->uuid = 1; if (id == old_uuid) return 0; diff --git a/tools/blktap2/drivers/tapdisk-control.c b/tools/blktap2/drivers/tapdisk-control.c index 3a4ec8e..4e5f748 100644 --- a/tools/blktap2/drivers/tapdisk-control.c +++ b/tools/blktap2/drivers/tapdisk-control.c @@ -700,7 +700,7 @@ tapdisk_control_accept(event_id_t id, char mode, void *private) connection->socket, 0, tapdisk_control_handle_request, connection); - if (err == -1) { + if (err < 0) { close(fd); free(connection); EPRINTF("failed to register new control event: %d\n", err); -- 1.9.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |