summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2011-02-03 11:33:32 +0000
committerpjd <pjd@FreeBSD.org>2011-02-03 11:33:32 +0000
commit0c525303bdcbdd0f85b8805ec7efe0fa389bc7ed (patch)
tree05cb86302c5416c803eeffa14dcd36e55d48ddf3
parentf5164be44bd5f410c13c78d1d26dd620d0fc0d1f (diff)
downloadFreeBSD-src-0c525303bdcbdd0f85b8805ec7efe0fa389bc7ed.zip
FreeBSD-src-0c525303bdcbdd0f85b8805ec7efe0fa389bc7ed.tar.gz
Add missing locking after moving keepalive_send() to remote send thread
in r214692. MFC after: 1 week
-rw-r--r--sbin/hastd/primary.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c
index 656ead9..7081096 100644
--- a/sbin/hastd/primary.c
+++ b/sbin/hastd/primary.c
@@ -1230,8 +1230,12 @@ keepalive_send(struct hast_resource *res, unsigned int ncomp)
{
struct nv *nv;
- if (!ISCONNECTED(res, ncomp))
+ rw_rlock(&hio_remote_lock[ncomp]);
+
+ if (!ISCONNECTED(res, ncomp)) {
+ rw_unlock(&hio_remote_lock[ncomp]);
return;
+ }
PJDLOG_ASSERT(res->hr_remotein != NULL);
PJDLOG_ASSERT(res->hr_remoteout != NULL);
@@ -1239,20 +1243,22 @@ keepalive_send(struct hast_resource *res, unsigned int ncomp)
nv = nv_alloc();
nv_add_uint8(nv, HIO_KEEPALIVE, "cmd");
if (nv_error(nv) != 0) {
+ rw_unlock(&hio_remote_lock[ncomp]);
nv_free(nv);
pjdlog_debug(1,
"keepalive_send: Unable to prepare header to send.");
return;
}
if (hast_proto_send(res, res->hr_remoteout, nv, NULL, 0) < 0) {
+ rw_unlock(&hio_remote_lock[ncomp]);
pjdlog_common(LOG_DEBUG, 1, errno,
"keepalive_send: Unable to send request");
nv_free(nv);
- rw_unlock(&hio_remote_lock[ncomp]);
remote_close(res, ncomp);
- rw_rlock(&hio_remote_lock[ncomp]);
return;
}
+
+ rw_unlock(&hio_remote_lock[ncomp]);
nv_free(nv);
pjdlog_debug(2, "keepalive_send: Request sent.");
}
OpenPOWER on IntegriCloud