[PATCH 2.6] serialization of kernelcapi work
From: Armin Schindler
Date: Thu Mar 18 2004 - 05:56:20 EST
Hi all,
the ISDN kernelcapi function recv_handler() is triggered by
schedule_work() and dispatches the CAPI messages to the applications.
Since a workqueue function may run on another CPU at the same time,
reordering of CAPI messages may occur.
For serialization I suggest a mutex semaphore in recv_handler(),
patch is appended (yet untested).
Is there a better way to do user-context work serialized ?
Armin
--- linux/drivers/isdn/capi/kcapi.c 16 Mar 2004 08:01:47 -0000
+++ linux/drivers/isdn/capi/kcapi.c 18 Mar 2004 10:41:38 -0000
@@ -70,6 +70,7 @@
static struct sk_buff_head recv_queue;
static struct work_struct tq_recv_notify;
+static DECLARE_MUTEX(recv_handler_lock);
/* -------- controller ref counting -------------------------------------- */
@@ -242,6 +243,8 @@
struct sk_buff *skb;
struct capi20_appl *ap;
+ down(&recv_handler_lock);
+
while ((skb = skb_dequeue(&recv_queue)) != 0) {
ap = get_capi_appl_by_nr(CAPIMSG_APPID(skb->data));
if (!ap) {
@@ -257,6 +260,8 @@
ap->nrecvctlpkt++;
ap->recv_message(ap, skb);
}
+
+ up(&recv_handler_lock);
}
void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *skb)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/