From owner-p4-projects@FreeBSD.ORG Sat Oct 15 15:46:08 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A220D16A421; Sat, 15 Oct 2005 15:46:07 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6209816A41F for ; Sat, 15 Oct 2005 15:46:07 +0000 (GMT) (envelope-from soc-chenk@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 27D3143D49 for ; Sat, 15 Oct 2005 15:46:07 +0000 (GMT) (envelope-from soc-chenk@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j9FFk7W2063639 for ; Sat, 15 Oct 2005 15:46:07 GMT (envelope-from soc-chenk@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j9FFk6X1063636 for perforce@freebsd.org; Sat, 15 Oct 2005 15:46:06 GMT (envelope-from soc-chenk@freebsd.org) Date: Sat, 15 Oct 2005 15:46:06 GMT Message-Id: <200510151546.j9FFk6X1063636@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-chenk@freebsd.org using -f From: soc-chenk To: Perforce Change Reviews Cc: Subject: PERFORCE change 85342 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2005 15:46:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=85342 Change 85342 by soc-chenk@soc-chenk_leavemealone on 2005/10/15 15:45:35 device read converted to use msleep instead of condvar [this seems to prevent daemon-segfaults-in-readdir panics] Submitted by: soc-chenk Affected files ... .. //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.c#18 edit .. //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.h#9 edit Differences ... ==== //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.c#18 (text+ko) ==== @@ -478,7 +478,6 @@ /* Setting up fields of mine */ mtx_init(&data->msg_mtx, "mutex for fuse message list", NULL, MTX_DEF); - cv_init(&data->msg_cv, "cv to wake up fusedev_read"); STAILQ_INIT(&data->fmsg_head); mtx_init(&data->ticket_mtx, "mutex for the fuse ticketer", NULL, MTX_DEF); @@ -503,7 +502,6 @@ /* Driving off stage all that stuff thrown at device... */ mtx_destroy(&data->msg_mtx); - cv_destroy(&data->msg_cv); mtx_destroy(&data->callback_mtx); mtx_destroy(&data->ticket_mtx); @@ -526,7 +524,7 @@ DEBUG2G("banning daemon\n"); mtx_lock(&data->msg_mtx); data->dataflag |= FDAT_KICK; - cv_signal(&data->msg_cv); + wakeup_one(data); mtx_unlock(&data->msg_mtx); } @@ -693,7 +691,7 @@ mtx_lock(&tick->data->msg_mtx); fuse_msgn_push(&tick->msgn); DEBUG("ring the bell\n"); - cv_signal(&tick->data->msg_cv); + wakeup_one(tick->data); mtx_unlock(&tick->data->msg_mtx); } @@ -1077,6 +1075,7 @@ fuprintf("fuse device being read on thread %d\n", uio->uio_td->td_tid); mtx_lock(&data->msg_mtx); +again: if (fdata_kick_get(data)) { DEBUG("we know early on that reader should be kicked so we don't wait for news\n"); mtx_unlock(&data->msg_mtx); @@ -1084,13 +1083,23 @@ } if ( ! (fmsgn = fdata_pop_msg(data))) { - err = cv_wait_sig(&data->msg_cv, &data->msg_mtx); + err = msleep(data, &data->msg_mtx, PCATCH, "fu msg", 0); if (err != 0) { mtx_unlock(&data->msg_mtx); return (fdata_kick_get(data) ? ENODEV : err); } fmsgn = fdata_pop_msg(data); } + if (! fmsgn) { + /* + * We can get here if fuse daemon suddenly terminates, + * eg, by being hit by a SIGKILL + * -- and some other cases, too, tho not totally clear, when + * (cv_signal/wakeup_one signals the whole process ?) + */ + DEBUG("no message on thread #%d\n", uio->uio_td->td_tid); + goto again; + } mtx_unlock(&data->msg_mtx); if (fdata_kick_get(data)) { @@ -1105,16 +1114,6 @@ } return (ENODEV); /* This should make the daemon get off of us */ } - if (! fmsgn) { - /* - * We can get here if fuse daemon suddenly terminates, - * eg, by being hit by a SIGKILL - * -- and some other cases, too, tho not totally clear, when - * (cv_signal signals the whole process ?) - */ - DEBUG("no message on thread #%d\n", uio->uio_td->td_tid); - return (EINTR); - } DEBUG("message got on thread #%d\n", uio->uio_td->td_tid); KASSERT(fmsgn->msg_bufdata || fmsgn->msg_bufsize == 0, ==== //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.h#9 (text+ko) ==== @@ -90,7 +90,6 @@ struct fuse_data { struct mtx msg_mtx; - struct cv msg_cv; STAILQ_HEAD(, fuse_msg_node) fmsg_head; struct mtx callback_mtx;