Skip to content

Commit

Permalink
libceph: use a flag to indicate a fault has occurred
Browse files Browse the repository at this point in the history
This just rearranges the logic in con_work() a little bit so that a
flag is used to indicate a fault has occurred.  This allows both the
fault and non-fault case to be handled the same way and avoids a
couple of nearly consecutive gotos.

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
  • Loading branch information
Alex Elder committed Feb 25, 2013
1 parent 9320926 commit b6e7b6a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -2387,13 +2387,15 @@ static void con_work(struct work_struct *work)
{
struct ceph_connection *con = container_of(work, struct ceph_connection,
work.work);
bool fault = false;
int ret;

mutex_lock(&con->mutex);
restart:
if (con_sock_closed(con)) {
dout("%s: con %p SOCK_CLOSED\n", __func__, con);
goto fault;
fault = true;
goto done;
}
if (con_backoff(con)) {
dout("%s: con %p BACKOFF\n", __func__, con);
Expand All @@ -2418,28 +2420,26 @@ static void con_work(struct work_struct *work)
goto restart;
if (ret < 0) {
con->error_msg = "socket error on read";
goto fault;
fault = true;
goto done;
}

ret = try_write(con);
if (ret == -EAGAIN)
goto restart;
if (ret < 0) {
con->error_msg = "socket error on write";
goto fault;
fault = true;
}

done:
if (fault)
con_fault(con);
mutex_unlock(&con->mutex);
done_unlocked:
con->ops->put(con);
return;

fault:
con_fault(con);
mutex_unlock(&con->mutex);
con_fault_finish(con);
goto done_unlocked;
if (fault)
con_fault_finish(con);

con->ops->put(con);
}


Expand Down

0 comments on commit b6e7b6a

Please sign in to comment.