task = session->task;
- if (what == EV_WRITE) {
- if (!fuzzy_cmd_vector_to_wire (fd, session->commands)) {
- ret = return_error;
- }
- else {
- session->state = 1;
- ret = return_want_more;
- }
- }
- else if (session->state == 1) {
+ if ((what & EV_READ) || session->state == 1) {
/* Try to read reply */
if ((r = read (fd, buf, sizeof (buf) - 1)) == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
}
}
}
+ else if (what & EV_WRITE) {
+ if (!fuzzy_cmd_vector_to_wire (fd, session->commands)) {
+ ret = return_error;
+ }
+ else {
+ session->state = 1;
+ ret = return_want_more;
+ }
+ }
else {
/* Should not happen */
g_assert (0);
else {
/* Plan write event */
event_del (&session->ev);
- event_set (&session->ev, fd, EV_WRITE,
+ event_set (&session->ev, fd, EV_WRITE|EV_READ,
fuzzy_check_io_callback, session);
event_add (&session->ev, NULL);
task = session->task;
- if (what == EV_WRITE) {
- /* Send commands to storage */
- if (!fuzzy_cmd_vector_to_wire (fd, session->commands)) {
- if (*(session->err) == NULL) {
- g_set_error (session->err,
- g_quark_from_static_string ("fuzzy check"),
- errno, "write socket error: %s", strerror (errno));
- }
- ret = return_error;
- }
- }
- else if (what == EV_READ) {
+ if (what & EV_READ) {
if ((r = read (fd, buf, sizeof (buf) - 1)) == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
event_add (&session->ev, NULL);
}
}
}
+ else if (what & EV_WRITE) {
+ /* Send commands to storage */
+ if (!fuzzy_cmd_vector_to_wire (fd, session->commands)) {
+ if (*(session->err) == NULL) {
+ g_set_error (session->err,
+ g_quark_from_static_string ("fuzzy check"),
+ errno, "write socket error: %s", strerror (errno));
+ }
+ ret = return_error;
+ }
+ }
else {
g_assert (0);
}
else {
/* Plan write event */
event_del (&session->ev);
- event_set (&session->ev, fd, EV_WRITE,
+ event_set (&session->ev, fd, EV_WRITE|EV_READ,
fuzzy_controller_io_callback, session);
event_add (&session->ev, NULL);