pacify mdoclink
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12331 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -45,3 +45,61 @@ krb5_net_write (krb5_context context,
|
||||
|
||||
return net_write (fd, buf, len);
|
||||
}
|
||||
|
||||
krb5_ssize_t
|
||||
krb5_net_write_block(krb5_context context,
|
||||
void *p_fd,
|
||||
const void *buf,
|
||||
size_t len,
|
||||
time_t timeout)
|
||||
{
|
||||
int fd = *((int *)p_fd);
|
||||
int ret;
|
||||
struct timeval tv, *tvp;
|
||||
const char *cbuf = (const char *)buf;
|
||||
size_t rem = len;
|
||||
ssize_t count;
|
||||
fd_set wfds;
|
||||
|
||||
do {
|
||||
FD_ZERO(&wfds);
|
||||
FD_SET(fd, &wfds);
|
||||
|
||||
if (timeout != 0) {
|
||||
tv.tv_sec = timeout;
|
||||
tv.tv_usec = 0;
|
||||
tvp = &tv;
|
||||
} else
|
||||
tvp = NULL;
|
||||
|
||||
ret = select(fd + 1, NULL, &wfds, NULL, tvp);
|
||||
if (ret < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
return -1;
|
||||
} else if (ret == 0)
|
||||
return 0;
|
||||
|
||||
if (!FD_ISSET(fd, &wfds)) {
|
||||
errno = ETIMEDOUT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
count = send (fd, cbuf, rem, 0);
|
||||
#else
|
||||
count = write (fd, cbuf, rem);
|
||||
#endif
|
||||
if (count < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
else
|
||||
return count;
|
||||
}
|
||||
cbuf += count;
|
||||
rem -= count;
|
||||
|
||||
} while (rem > 0);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
Reference in New Issue
Block a user