Add missing locking after moving keepalive_send() to remote send thread

in r214692.

MFC after:	1 week
This commit is contained in:
Pawel Jakub Dawidek 2011-02-03 11:33:32 +00:00
parent 7cf48ac8c8
commit 21e7bc5e52
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=218217

View File

@ -1230,8 +1230,12 @@ keepalive_send(struct hast_resource *res, unsigned int ncomp)
{ {
struct nv *nv; struct nv *nv;
if (!ISCONNECTED(res, ncomp)) rw_rlock(&hio_remote_lock[ncomp]);
if (!ISCONNECTED(res, ncomp)) {
rw_unlock(&hio_remote_lock[ncomp]);
return; return;
}
PJDLOG_ASSERT(res->hr_remotein != NULL); PJDLOG_ASSERT(res->hr_remotein != NULL);
PJDLOG_ASSERT(res->hr_remoteout != NULL); PJDLOG_ASSERT(res->hr_remoteout != NULL);
@ -1239,20 +1243,22 @@ keepalive_send(struct hast_resource *res, unsigned int ncomp)
nv = nv_alloc(); nv = nv_alloc();
nv_add_uint8(nv, HIO_KEEPALIVE, "cmd"); nv_add_uint8(nv, HIO_KEEPALIVE, "cmd");
if (nv_error(nv) != 0) { if (nv_error(nv) != 0) {
rw_unlock(&hio_remote_lock[ncomp]);
nv_free(nv); nv_free(nv);
pjdlog_debug(1, pjdlog_debug(1,
"keepalive_send: Unable to prepare header to send."); "keepalive_send: Unable to prepare header to send.");
return; return;
} }
if (hast_proto_send(res, res->hr_remoteout, nv, NULL, 0) < 0) { if (hast_proto_send(res, res->hr_remoteout, nv, NULL, 0) < 0) {
rw_unlock(&hio_remote_lock[ncomp]);
pjdlog_common(LOG_DEBUG, 1, errno, pjdlog_common(LOG_DEBUG, 1, errno,
"keepalive_send: Unable to send request"); "keepalive_send: Unable to send request");
nv_free(nv); nv_free(nv);
rw_unlock(&hio_remote_lock[ncomp]);
remote_close(res, ncomp); remote_close(res, ncomp);
rw_rlock(&hio_remote_lock[ncomp]);
return; return;
} }
rw_unlock(&hio_remote_lock[ncomp]);
nv_free(nv); nv_free(nv);
pjdlog_debug(2, "keepalive_send: Request sent."); pjdlog_debug(2, "keepalive_send: Request sent.");
} }