lkml.org 
[lkml]   [2002]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: TCP memory pressure question
Date
> 	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/

\
 
 \ /
  Last update: 2005-03-22 13:31    [W:0.082 / U:1.448 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site