Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Mar 2002 23:16:36 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Farooq Mela <fmela0@sm.socccd.cc.ca.us>
Cc:        Alfred Perlstein <bright@mu.org>, freebsd-hackers@freebsd.org
Subject:   Re: Recv() to a mmap'ed file?
Message-ID:  <3C8EFCD4.848240BD@mindspring.com>
References:  <3C8E6CD5.67F23CF2@sm.socccd.cc.ca.us> <20020312214851.GK92565@elvis.mu.org> <3C8EEA50.C3E17315@sm.socccd.cc.ca.us>

next in thread | previous in thread | raw e-mail | index | archive | help
Farooq Mela wrote:
> > > Rather than the usual recv() to a fixed size buffer, write() to the
> > > file descriptor, loop, etc.  However when I try to do this recv gives
> > > me back an EFAULT (bad address).  Is there a limitation of the
> > > architecture which does not allows us to recv() to an mmap'ed area of
> > > a file, or is it just something which hasn't been implemented?
> >
> > You may not extend a file using mmap(2), you must use ftuncate(2)
> > or write(2).
> 
> I am aware of this, this is why I stated:
> 
> > /* file_fd points to a regular file which is filled with SIZE nul
> > bytes */
> 
> The file is already the required size.

You said it contained NUL bytes.  Doe this mean that you
greated it via a ftruncate or a seek + write of 1 byte?

You should make sure that you write a zero to the first
byte of every page to ensure that there is backing object
mapping for it, before you attempt to receive to it.  The
inability to process page faults at interrupt mode may
very well be your problem.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C8EFCD4.848240BD>