RE: TCP memory pressure question

From: Folkert van Heusden (folkert@vanheusden.com)
Date: Sat Nov 23 2002 - 17:34:15 EST


> 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;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Nov 23 2002 - 22:00:43 EST