mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Folkert van Heusden" <folkert@vanheusden.com>
To: "'David Schwartz'" <davids@webmaster.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: RE: TCP memory pressure question
Date: Sat, 23 Nov 2002 23:34:15 +0100	[thread overview]
Message-ID: <001701c29340$749e8110$3640a8c0@boemboem> (raw)
In-Reply-To: <20021123002812.AAA5286@shell.webmaster.com@whenever>

> 	Any comments or suggestions are appreciated. I've found that when we hit
TCP
> memory pressure, many applications become very badly behaved.

What about:

int WRITE(int handle, char *whereto, int len)
{
        int cnt=len;

        while(len>0)
        {
                int rc;

                rc = write(handle, whereto, len);

                if (rc == -1)
                {
                        if (errno == EINTR)
				{
					/* just try again */
				}
				else if (errno == EAGAIN)
				{
					/* give up time-slice */
					if (sched_yield() == -1)
					{
						/* BIG troubles */
                              	syslog(LOG_DEBUG, "WRITE(), during EAGAIN
handling: sched_yield failed! [%d - %s]", errno, strerror(errno));
                               	return -1;
					}
				}
				else
                        {
                                syslog(LOG_DEBUG, "WRITE(): io-error [%d -
%s]", errno, strerror(errno));
                                return -1;
                        }
                }
                else if (rc == 0)
                {
                        return 0;
                }
                else
                {
                        whereto += rc;
                        len -= rc;
                }
        }

        return cnt;
}


  reply	other threads:[~2002-11-23 22:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-21 21:34 David Schwartz
2002-11-22 12:06 ` Gianni Tedesco
2002-11-22 20:28   ` David Schwartz
2002-11-23  0:06     ` Jamie Lokier
2002-11-23  0:28       ` David Schwartz
2002-11-23 22:34         ` Folkert van Heusden [this message]
2002-11-23 22:54           ` David Schwartz
2002-11-22  1:27 Nivedita Singhvi
2002-11-22  9:18 ` Alex Riesen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001701c29340$749e8110$3640a8c0@boemboem' \
    --to=folkert@vanheusden.com \
    --cc=davids@webmaster.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®