Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Feb 1999 12:08:16 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        freebsd-current@FreeBSD.ORG
Subject:   Weird piecemeal reads over socketpair() pipe breaks up small writes into even smaller reads.
Message-ID:  <199902142008.MAA07550@apollo.backplane.com>

next in thread | raw e-mail | index | archive | help
    This is under -current.  I don't know when it started, but I think whatever
    change is causing this was in the last week or two.

    This isn't a 'bug', per say, but it bothers me that a small 128 byte
    write() is being somehow broken apart into two smaller read()s.  It isn't
    efficient, and it shouldn't be happening.

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>

apollo:/home/dillon> ./x
read 96
read 32

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>             /* unix domain sockets  */
#include <netinet/in.h>         /* internet sockets     */
#include <netinet/tcp.h>        /* TCP_NODELAY sockopt  */
#include <stdio.h>
#include <fcntl.h>

int
main(int ac, char **av)
{
    int fds[2];
    int n;
    char buf[128];
    fd_set rfds;

    if (socketpair(PF_UNIX, SOCK_STREAM, IPPROTO_IP, fds) < 0)
        perror("socketpair");
    fcntl(fds[0], F_SETFL, O_NONBLOCK);
    FD_ZERO(&rfds);
    FD_SET(fds[0], &rfds);
    if (fork() == 0) {
        sleep(1);
        write(fds[1], buf, sizeof(buf));
        _exit(1);
    }
    select(fds[0] + 1, &rfds, NULL, NULL, NULL);
    while ((n = read(fds[0], buf, sizeof(buf))) > 0)
        printf("read %d\n", n);
    return(0);
}



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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902142008.MAA07550>