From owner-p4-projects@FreeBSD.ORG Wed Jul 5 14:10:14 2006 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 6469516A4DF; Wed, 5 Jul 2006 14:10:14 +0000 (UTC) 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 3740616A4DD for ; Wed, 5 Jul 2006 14:10:14 +0000 (UTC) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D27D143D46 for ; Wed, 5 Jul 2006 14:10:13 +0000 (GMT) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k65EADBf039330 for ; Wed, 5 Jul 2006 14:10:13 GMT (envelope-from piso@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k65EADwj039327 for perforce@freebsd.org; Wed, 5 Jul 2006 14:10:13 GMT (envelope-from piso@freebsd.org) Date: Wed, 5 Jul 2006 14:10:13 GMT Message-Id: <200607051410.k65EADwj039327@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to piso@freebsd.org using -f From: Paolo Pisati To: Perforce Change Reviews Cc: Subject: PERFORCE change 100629 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: Wed, 05 Jul 2006 14:10:14 -0000 http://perforce.freebsd.org/chv.cgi?CH=100629 Change 100629 by piso@piso_newluxor on 2006/07/05 14:09:30 First simplify dll handling: -mutex operations where #ifdef out in userland, that means dll_chain manipulation has never been thread safe, so make it more explicit axing all the empy LIBALIAS_LOCK() operations -> this is not a problem cause all the programs using libalias in userland (ppp and natd) aren't multithreaded, anyway it has to be fixed later. -put some comments to mark the thread unsafetyness Affected files ... .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.c#9 edit .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.h#9 edit Differences ... ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.c#9 (text+ko) ==== @@ -60,7 +60,8 @@ #include /* protocol and userland module handlers chains */ -struct chain handler_chain, dll_chain; +struct chain handler_chain; +struct dll *dll_chain; #ifdef _KERNEL @@ -254,13 +255,12 @@ return (handler_chain.chain); } +/* dll manipulation code - this code is not thread safe... */ + static int -_attach_dll(struct chain *c, struct dll *p) { - struct dll **b; +_attach_dll(struct dll **b, struct dll *p) { int i = 0; - LIBALIAS_WLOCK_ASSERT(c); - b = (struct dll **)&c->chain; p->next = NULL; /* i'm paranoid... */ for(; *b != NULL; b = &((*b)->next), i++) if (!strncmp((*b)->name, p->name, DLL_LEN)) @@ -271,12 +271,9 @@ } static void * -_detach_dll(struct chain *c, char *p) { - struct dll **b; +_detach_dll(struct dll **b, char *p) { void *err = NULL; - LIBALIAS_WLOCK_ASSERT(c); - b = (struct dll **)&c->chain; for(; *b != NULL; b = &((*b)->next)) if (!strncmp((*b)->name, p, DLL_LEN)) { err = *b; @@ -290,9 +287,7 @@ attach_dll(struct dll *p) { int i; - LIBALIAS_WLOCK(&dll_chain); i = _attach_dll(&dll_chain, p); - LIBALIAS_WUNLOCK(&dll_chain); return (i); } @@ -300,15 +295,13 @@ detach_dll(char *p) { void *i; - LIBALIAS_WLOCK(&dll_chain); i = _detach_dll(&dll_chain, p); - LIBALIAS_WUNLOCK(&dll_chain); return (i); } struct dll * walk_dll_chain(void) { - struct dll *t, **b = (struct dll **)&dll_chain.chain; + struct dll *t, **b = &dll_chain; for(t = *b; *b != NULL;) { *b = (*b)->next; ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.h#9 (text+ko) ==== @@ -83,9 +83,13 @@ // XXX - convert it to use queue(3) struct chain { void *chain; -#ifdef _KERNEL struct rwlock rw; -#endif +}; + +struct dll_chain { + void *chain; + // XXX - what if a process with 2 threads manipulate the + // libalias dll list? we still need a lock here... }; /*