Skip to content

Commit

Permalink
libceph: make ceph_tcp_connect() return int
Browse files Browse the repository at this point in the history
There is no real need for ceph_tcp_connect() to return the socket
pointer it creates, since it already assigns it to con->sock, which
is visible to the caller.  Instead, have it return an error code,
which tidies things up a bit.

Signed-off-by: Alex Elder <[email protected]>
Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
Alex Elder committed Mar 22, 2012
1 parent 6173d1f commit 41617d0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static void set_sock_callbacks(struct socket *sock,
/*
* initiate connection to a remote socket.
*/
static struct socket *ceph_tcp_connect(struct ceph_connection *con)
static int ceph_tcp_connect(struct ceph_connection *con)
{
struct sockaddr_storage *paddr = &con->peer_addr.in_addr;
struct socket *sock;
Expand All @@ -250,7 +250,7 @@ static struct socket *ceph_tcp_connect(struct ceph_connection *con)
ret = sock_create_kern(con->peer_addr.in_addr.ss_family, SOCK_STREAM,
IPPROTO_TCP, &sock);
if (ret)
return ERR_PTR(ret);
return ret;
sock->sk->sk_allocation = GFP_NOFS;

#ifdef CONFIG_LOCKDEP
Expand All @@ -273,11 +273,11 @@ static struct socket *ceph_tcp_connect(struct ceph_connection *con)
sock_release(sock);
con->error_msg = "connect error";

return ERR_PTR(ret);
return ret;
}
con->sock = sock;

return sock;
return 0;
}

static int ceph_tcp_recvmsg(struct socket *sock, void *buf, size_t len)
Expand Down Expand Up @@ -1854,11 +1854,9 @@ static int try_write(struct ceph_connection *con)
con->in_tag = CEPH_MSGR_TAG_READY;
dout("try_write initiating connect on %p new state %lu\n",
con, con->state);
con->sock = ceph_tcp_connect(con);
if (IS_ERR(con->sock)) {
con->sock = NULL;
ret = ceph_tcp_connect(con);
if (ret < 0) {
con->error_msg = "connect error";
ret = -1;
goto out;
}
}
Expand Down

0 comments on commit 41617d0

Please sign in to comment.