From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 4 17:09:06 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 14285106564A for ; Tue, 4 Aug 2009 17:09:06 +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 583458FC12 for ; Tue, 4 Aug 2009 17:09:04 +0000 (UTC) (envelope-from maslanbsd@gmail.com) Received: by bwz2 with SMTP id 2so3042213bwz.43 for ; Tue, 04 Aug 2009 10:09:04 -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; bh=h8b6G/IwdfO/d35WcpNtpmCXtx952x+5kAFDpzMeFmY=; b=TsEjTyTHM4pwVbD5hm/H/T0dMjyRI9nScdUKbWRWdJnoGINQ4LdQpH54uRUTQ0c9H/ B6XUpDRoOoY0WXUxafpVx6vO+yISXfTvNCYwBrw38quRkjvMeVbntPuOPiw7pvhkXiQR Fr/baCBSlm1wzzea5FAJFeGmtb5UedBe0su98= 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; b=AukE6YhKi1JLGTU21AElR47Pp/ni19yfceB5lbV7mo7Z2Z8i+wAs1k6I7o7B5+Q0HX UTZLkRqZ9IMh2OWriLL4YUARO2uUXFFPG7Dt3zlmmZHq3zTAmAhaVdy3DeFtVj+rIOdL Gd63yX50VG6WyK4vQR9XShAXocFXrNE4wyp14= MIME-Version: 1.0 Received: by 10.204.121.131 with SMTP id h3mr1438171bkr.172.1249405744238; Tue, 04 Aug 2009 10:09:04 -0700 (PDT) In-Reply-To: <319cceca0908041003o4c313bf6qff57a1f0b752b537@mail.gmail.com> References: <319cceca0908030119i3432a495ya60aa431dab0e1b1@mail.gmail.com> <86k51k4kvl.fsf@ds4.des.no> <86fxc84ksj.fsf@ds4.des.no> <200908040138.14743.max@love2party.net> <319cceca0908040227hf9a0f92jbf05b11e9f974994@mail.gmail.com> <20090804093036.GN1292@hoeg.nl> <319cceca0908040239k2accd7fen402db4c91687a267@mail.gmail.com> <4A786302.3090709@elischer.org> <319cceca0908041003o4c313bf6qff57a1f0b752b537@mail.gmail.com> Date: Tue, 4 Aug 2009 17:09:00 +0000 Message-ID: <319cceca0908041008p2de4452duc55467abbb121e16@mail.gmail.com> From: Maslan To: Julian Elischer Content-Type: multipart/mixed; boundary=001636c5a4af90df38047053f1a0 Cc: Ed Schouten , 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: Tue, 04 Aug 2009 17:09:06 -0000 --001636c5a4af90df38047053f1a0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Guys, Here is the code, just scroll down and change kthread_create2() to kthread_create() and it will crash NOTE: i'm still working on the socket part, u can commend it. Something wrong with proc0, and I can't figure it out --001636c5a4af90df38047053f1a0 Content-Type: application/octet-stream; name="khttp.c" Content-Disposition: attachment; filename="khttp.c" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fxyvvpoo0 I2luY2x1ZGUgPHN5cy9wYXJhbS5oPgojaW5jbHVkZSA8c3lzL2tlcm5lbC5oPgojaW5jbHVkZSA8 c3lzL21vZHVsZS5oPgojaW5jbHVkZSA8c3lzL3N5c3RtLmg+CiNpbmNsdWRlIDxzeXMvbWFsbG9j Lmg+IAkvKiBtYWxsb2MsIGZyZWUgKi8KI2luY2x1ZGUgPHN5cy9zeXNjYWxsc3Vici5oPgkvKiBr ZXJu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