977 struct pollfd pollfd;
978 hrtime_t start, end;
979 int retv;
980
981 pollfd.fd = fd;
982 pollfd.events = POLLIN;
983
984 while (n_total < length) {
985
986 start = gethrtime();
987
988 retv = poll(&pollfd, 1, *msec);
989 if (retv == 0) {
990 /* This can happen only if *msec is not -1 */
991 *msec = 0;
992 return (DHCP_IPC_E_TIMEOUT);
993 }
994
995 if (*msec != -1) {
996 end = gethrtime();
997 *msec -= (end - start) / (NANOSEC / MILLISEC);
998 if (*msec < 0)
999 *msec = 0;
1000 }
1001
1002 if (retv == -1) {
1003 if (errno != EINTR)
1004 return (DHCP_IPC_E_POLL);
1005 else if (*msec == 0)
1006 return (DHCP_IPC_E_TIMEOUT);
1007 continue;
1008 }
1009
1010 if (!(pollfd.revents & POLLIN)) {
1011 errno = EINVAL;
1012 return (DHCP_IPC_E_POLL);
1013 }
1014
1015 n_read = read(fd, (caddr_t)buffer + n_total, length - n_total);
1016
1017 if (n_read == -1) {
|
977 struct pollfd pollfd;
978 hrtime_t start, end;
979 int retv;
980
981 pollfd.fd = fd;
982 pollfd.events = POLLIN;
983
984 while (n_total < length) {
985
986 start = gethrtime();
987
988 retv = poll(&pollfd, 1, *msec);
989 if (retv == 0) {
990 /* This can happen only if *msec is not -1 */
991 *msec = 0;
992 return (DHCP_IPC_E_TIMEOUT);
993 }
994
995 if (*msec != -1) {
996 end = gethrtime();
997 *msec -= NSEC2MSEC(end - start);
998 if (*msec < 0)
999 *msec = 0;
1000 }
1001
1002 if (retv == -1) {
1003 if (errno != EINTR)
1004 return (DHCP_IPC_E_POLL);
1005 else if (*msec == 0)
1006 return (DHCP_IPC_E_TIMEOUT);
1007 continue;
1008 }
1009
1010 if (!(pollfd.revents & POLLIN)) {
1011 errno = EINVAL;
1012 return (DHCP_IPC_E_POLL);
1013 }
1014
1015 n_read = read(fd, (caddr_t)buffer + n_total, length - n_total);
1016
1017 if (n_read == -1) {
|