View | Details | Raw Unified | Return to bug 26665
Collapse All | Expand All

(-)res_send.c (-5 / +25 lines)
Lines 597-602 Link Here
597
			 */
597
			 */
598
			struct kevent kv;
598
			struct kevent kv;
599
			struct timespec timeout;
599
			struct timespec timeout;
600
			struct timeval timeout_tv;
601
			struct timeval target;
600
			struct sockaddr_storage from;
602
			struct sockaddr_storage from;
601
			int fromlen;
603
			int fromlen;
602
604
Lines 706-711 Link Here
706
			if ((long) timeout.tv_sec <= 0)
708
			if ((long) timeout.tv_sec <= 0)
707
				timeout.tv_sec = 1;
709
				timeout.tv_sec = 1;
708
			timeout.tv_nsec = 0;
710
			timeout.tv_nsec = 0;
711
			(void)gettimeofday(&target, NULL);
712
			timeout_tv.tv_sec = timeout.tv_sec;
713
			timeout_tv.tv_usec = timeout.tv_nsec / 1000;
714
			timeradd(&target, &timeout_tv, &target);
709
    wait:
715
    wait:
710
			if (s < 0) {
716
			if (s < 0) {
711
				Perror(stderr, "s out-of-bounds", EMFILE);
717
				Perror(stderr, "s out-of-bounds", EMFILE);
Lines 719-729 Link Here
719
				
725
				
720
			n = kevent(kq, &kv, 1, &kv, 1, &timeout);
726
			n = kevent(kq, &kv, 1, &kv, 1, &timeout);
721
			if (n < 0) {
727
			if (n < 0) {
722
				if (errno == EINTR)
728
				if (errno == EINTR) {
723
					goto wait;
729
					struct timeval current;
724
				Perror(stderr, "kevent", errno);
730
725
				res_close();
731
					(void)gettimeofday(&current, NULL);
726
				goto next_ns;
732
					if (timercmp(&current, &target,
733
					    <)) {
734
						timersub(&target, &current,
735
						    &current);
736
						timeout.tv_sec =
737
						    current.tv_sec;
738
						timeout.tv_nsec =
739
						    current.tv_usec * 1000;
740
						goto wait;
741
					}
742
				} else {
743
					Perror(stderr, "kevent", errno);
744
					res_close();
745
					goto next_ns;
746
				}
727
			}
747
			}
728
748
729
			if (n == 0) {
749
			if (n == 0) {

Return to bug 26665