From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 3 21:25:30 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 096C3106564A for ; Mon, 3 Aug 2009 21:25:30 +0000 (UTC) (envelope-from maslanbsd@gmail.com) Received: from mail-bw0-f206.google.com (mail-bw0-f206.google.com [209.85.218.206]) by mx1.freebsd.org (Postfix) with ESMTP id 8528F8FC08 for ; Mon, 3 Aug 2009 21:25:29 +0000 (UTC) (envelope-from maslanbsd@gmail.com) Received: by bwz2 with SMTP id 2so2566815bwz.43 for ; Mon, 03 Aug 2009 14:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=C1xzl5ZzV/j1rXlLhunYQHB4S52D6U1kxJGvztKURrM=; b=BtvleoWxEMCZL/JaBCtKteR45exk6wPBvVLfkVpBkeJuHxoV31t9moez0p38iKPVzS ZsQUDJ8WNqHggXK1kMQ3ZTTxW23mpJKwprd/AfQKAfuAt5c5d2pRnz9gECii0qbLCOtK QUwPicfJxcLKZCvYAv/lG25n6HH9IRUGLC704= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=Tg0hEvWG824JW3rIc4CUQLcCOqW05EA9faEzMfBrHn/TkZGYiHzRqJWH85KLVN6gMK khWWoNYXptpK09Nxg1LwdgxIJ+NDDNvY8ZpGZuM/XCQX7836O8LzNJJpRvskMyADa1vk nY1Rnkn/IBtIyPNud47emMyCCURSe7lDLaXuw= MIME-Version: 1.0 Received: by 10.204.67.146 with SMTP id r18mr235553bki.88.1249334728318; Mon, 03 Aug 2009 14:25:28 -0700 (PDT) In-Reply-To: <86eirs65gb.fsf@ds4.des.no> References: <319cceca0908030119i3432a495ya60aa431dab0e1b1@mail.gmail.com> <864ospvvkv.fsf@ds4.des.no> <319cceca0908031043x6bfe5771wa73553dce922756a@mail.gmail.com> <86eirs65gb.fsf@ds4.des.no> Date: Mon, 3 Aug 2009 21:25:27 +0000 Message-ID: <319cceca0908031425r3516de29q34807cdf2c7489ed@mail.gmail.com> From: Maslan To: =?ISO-8859-1?Q?Dag=2DErling_Sm=F8rgrav?= Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: FreeBSD Hackers Subject: Re: sosend() and mbuf X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2009 21:25:30 -0000 No my code doesn't work, I thought it may be because that soaccept() -which is not found in man 9- is non-blocking, so i've to put my code in a thread. Now i got another problem, when I open a text file from this thread, the kernel crashes, I'm sure that its the thread. kthread_create((void *)thread_main, NULL, NULL, RFNOWAIT, 0, "thread"); void thread_main(){ struct thread *td =3D curthread; int ret; int fd; ret =3D f_open("/path/to/file.txt", &fd); printf("%d\n", ret); tsleep(td, PDROP, "test tsleep", 10*hz); f_close(fd); kthread_exit(0); } int f_open(char *filename, int *fd){ struct thread *td =3D curthread; int ret =3D kern_open(td, filename, UIO_SYSSPACE, O_RDONLY, FREAD); if(!ret){ *fd =3D td->td_retval[0]; return 1; } return 0; } I've to finish up this problem to go back for the first one. Can you figure out what's wrong with this code, it works when I call thread_main() rather than kthread_create((void *)thread_main, ..... Thanks a lot 2009/8/3 Dag-Erling Sm=F8rgrav : > [please cc: the list] > > Maslan writes: >> man 9 sosend: >> Data may be sent directly from kernel or user memory via the uio >> argument, or as an mbuf chain via top, avoid- ing a data copy. >> Only one of the uio or top pointers may be non-NULL > > Hmm, I missed that part. It never occurred to me to *not* use mbufs. > > I guess the question is: what is your question? Does your code work? > If it doesn't, where and how does it fail? If it does, why are you > asking? > > In any case, 'man 9 sosend' answers the "I can't find useful information > on sosend()" part of your email. If you still have questions after > reading that, try looking at existing kernel code that uses sosend(9) > with iovecs (or with mbufs, if you decide to go that route). > > DES > -- > Dag-Erling Sm=F8rgrav - des@des.no >