提交 e8d17b01 编写于 作者: A Andreas Gruenbacher 提交者: Philipp Reisner

drbd: drbd_send_handshake(): Return 0 upon success and an error code otherwise

Signed-off-by: NPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: NLars Ellenberg <lars.ellenberg@linbit.com>
上级 927036f9
...@@ -4135,25 +4135,25 @@ static int drbd_send_handshake(struct drbd_tconn *tconn) ...@@ -4135,25 +4135,25 @@ static int drbd_send_handshake(struct drbd_tconn *tconn)
{ {
/* ASSERT current == mdev->tconn->receiver ... */ /* ASSERT current == mdev->tconn->receiver ... */
struct p_handshake *p = &tconn->data.sbuf.handshake; struct p_handshake *p = &tconn->data.sbuf.handshake;
int ok; int err;
if (mutex_lock_interruptible(&tconn->data.mutex)) { if (mutex_lock_interruptible(&tconn->data.mutex)) {
conn_err(tconn, "interrupted during initial handshake\n"); conn_err(tconn, "interrupted during initial handshake\n");
return 0; /* interrupted. not ok. */ return -EINTR;
} }
if (tconn->data.socket == NULL) { if (tconn->data.socket == NULL) {
mutex_unlock(&tconn->data.mutex); mutex_unlock(&tconn->data.mutex);
return 0; return -EIO;
} }
memset(p, 0, sizeof(*p)); memset(p, 0, sizeof(*p));
p->protocol_min = cpu_to_be32(PRO_VERSION_MIN); p->protocol_min = cpu_to_be32(PRO_VERSION_MIN);
p->protocol_max = cpu_to_be32(PRO_VERSION_MAX); p->protocol_max = cpu_to_be32(PRO_VERSION_MAX);
ok = !_conn_send_cmd(tconn, 0, tconn->data.socket, P_HAND_SHAKE, err = _conn_send_cmd(tconn, 0, tconn->data.socket, P_HAND_SHAKE,
&p->head, sizeof(*p), 0); &p->head, sizeof(*p), 0);
mutex_unlock(&tconn->data.mutex); mutex_unlock(&tconn->data.mutex);
return ok; return err;
} }
/* /*
...@@ -4169,10 +4169,10 @@ static int drbd_do_handshake(struct drbd_tconn *tconn) ...@@ -4169,10 +4169,10 @@ static int drbd_do_handshake(struct drbd_tconn *tconn)
struct p_handshake *p = &tconn->data.rbuf.handshake; struct p_handshake *p = &tconn->data.rbuf.handshake;
const int expect = sizeof(struct p_handshake) - sizeof(struct p_header80); const int expect = sizeof(struct p_handshake) - sizeof(struct p_header80);
struct packet_info pi; struct packet_info pi;
int rv; int err, rv;
rv = drbd_send_handshake(tconn); err = drbd_send_handshake(tconn);
if (!rv) if (err)
return 0; return 0;
rv = drbd_recv_header(tconn, &pi); rv = drbd_recv_header(tconn, &pi);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册