Skip to content
Permalink
Browse files

make adding wait handles persistent

  • Loading branch information...
jacobgorm committed Feb 3, 2019
1 parent f157b45 commit 783e476b07b2f73499d71e2d3fc6322f832a6bf7
Showing with 3 additions and 10 deletions.
  1. +2 −3 aio.c
  2. +1 −7 nbd.c
5 aio.c
@@ -20,7 +20,7 @@ typedef struct AioEntry {
void *opaque;
} AioEntry;

static AioEntry aios[1024];
static AioEntry aios[16];

static int curl_timer_callback(CURLM *cmd, long timeout_ms, void *userp);
static int curl_socket_cb(CURL *ch, curl_socket_t s, int what, void *cbp, void *sockp);
@@ -175,7 +175,7 @@ void aio_wait(void) {
int r;
do {
r = select(max + 1, &readset, &writeset, &errset, &tv);
if (r < 0) {
if (r < 0 && errno != EINTR) {
warn("select failed");
}
} while (r < 0 && errno == EINTR);
@@ -209,7 +209,6 @@ void aio_wait(void) {
AioEntry *e = &aios[i];
int fd = e->fd;
if (fd >= 0 && FD_ISSET(fd, &readset)) {
__sync_bool_compare_and_swap(&e->fd, fd, -1);
e->cb(e->opaque);
}
}
8 nbd.c
@@ -126,8 +126,6 @@ static void nbd_read_done(void *opaque, int ret) {

free(ri->buffer);
free(ri);

aio_add_wait_object(ci->sock, got_data, ci);
}

static void nbd_write_done(void *opaque, int ret) {
@@ -194,8 +192,6 @@ static void got_data(void *opaque)
}
}
swap_aio_write(ci->bs, offset / 512, buffer, len / 512, nbd_write_done, buffer);
aio_add_wait_object(ci->sock, got_data, ci);

break;
}
case NBD_CMD_TRIM: {
@@ -205,7 +201,6 @@ static void got_data(void *opaque)
uint64_t offset = be64toh(request.from);
uint8_t *zero = calloc(1, len);
swap_aio_write(ci->bs, offset / 512, zero, len / 512, nbd_write_done, zero);
aio_add_wait_object(ci->sock, got_data, ci);
break;
}

@@ -215,7 +210,6 @@ static void got_data(void *opaque)
if (r != sizeof(reply)) {
err(1, "sock write (d) failed");
}
aio_add_wait_object(ci->sock, got_data, ci);
break;
}
};
@@ -234,7 +228,7 @@ void close_event_cb(void *opaque)
*pi = 1;
}

void signal_handler(int s)
static void signal_handler(int s)
{
if (s == SIGINT) {
ioh_event_set(&exit_event);

0 comments on commit 783e476

Please sign in to comment.
You can’t perform that action at this time.