Date: Mon, 3 Aug 2009 21:25:27 +0000 From: Maslan <maslanbsd@gmail.com> To: =?ISO-8859-1?Q?Dag=2DErling_Sm=F8rgrav?= <des@des.no> Cc: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Re: sosend() and mbuf Message-ID: <319cceca0908031425r3516de29q34807cdf2c7489ed@mail.gmail.com> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <des@des.no>: > [please cc: the list] > > Maslan <maslanbsd@gmail.com> 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 >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?319cceca0908031425r3516de29q34807cdf2c7489ed>