diff options
| author | jsing <> | 2014-04-15 17:25:41 +0000 |
|---|---|---|
| committer | jsing <> | 2014-04-15 17:25:41 +0000 |
| commit | 132a4cce42485cfd13bf12c1213cf1a63b5b1da2 (patch) | |
| tree | c99aff5cf18e944ed170f9de7bd1679f2e67cab7 /src/lib/libcrypto/bio/bss_dgram.c | |
| parent | 38d2a9c7ea9a14075bd1776e52b92232fae3d6d8 (diff) | |
| download | openbsd-132a4cce42485cfd13bf12c1213cf1a63b5b1da2.tar.gz openbsd-132a4cce42485cfd13bf12c1213cf1a63b5b1da2.tar.bz2 openbsd-132a4cce42485cfd13bf12c1213cf1a63b5b1da2.zip | |
Toss a `unifdef -U OPENSSL_SYS_WINDOWS' bomb into crypto/bio.
ok miod@
Diffstat (limited to 'src/lib/libcrypto/bio/bss_dgram.c')
| -rw-r--r-- | src/lib/libcrypto/bio/bss_dgram.c | 114 |
1 files changed, 1 insertions, 113 deletions
diff --git a/src/lib/libcrypto/bio/bss_dgram.c b/src/lib/libcrypto/bio/bss_dgram.c index 330f6fc404..328bab9ce3 100644 --- a/src/lib/libcrypto/bio/bss_dgram.c +++ b/src/lib/libcrypto/bio/bss_dgram.c | |||
| @@ -279,25 +279,12 @@ dgram_adjust_rcv_timeout(BIO *b) | |||
| 279 | struct timeval timenow, timeleft; | 279 | struct timeval timenow, timeleft; |
| 280 | 280 | ||
| 281 | /* Read current socket timeout */ | 281 | /* Read current socket timeout */ |
| 282 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 283 | int timeout; | ||
| 284 | |||
| 285 | sz.i = sizeof(timeout); | ||
| 286 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
| 287 | (void*)&timeout, &sz.i) < 0) { | ||
| 288 | perror("getsockopt"); | ||
| 289 | } else { | ||
| 290 | data->socket_timeout.tv_sec = timeout / 1000; | ||
| 291 | data->socket_timeout.tv_usec = (timeout % 1000) * 1000; | ||
| 292 | } | ||
| 293 | #else | ||
| 294 | sz.i = sizeof(data->socket_timeout); | 282 | sz.i = sizeof(data->socket_timeout); |
| 295 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 283 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
| 296 | &(data->socket_timeout), (void *)&sz) < 0) { | 284 | &(data->socket_timeout), (void *)&sz) < 0) { |
| 297 | perror("getsockopt"); | 285 | perror("getsockopt"); |
| 298 | } else if (sizeof(sz.s) != sizeof(sz.i) && sz.i == 0) | 286 | } else if (sizeof(sz.s) != sizeof(sz.i) && sz.i == 0) |
| 299 | OPENSSL_assert(sz.s <= sizeof(data->socket_timeout)); | 287 | OPENSSL_assert(sz.s <= sizeof(data->socket_timeout)); |
| 300 | #endif | ||
| 301 | 288 | ||
| 302 | /* Get current time */ | 289 | /* Get current time */ |
| 303 | get_current_time(&timenow); | 290 | get_current_time(&timenow); |
| @@ -324,18 +311,10 @@ dgram_adjust_rcv_timeout(BIO *b) | |||
| 324 | (data->socket_timeout.tv_sec > timeleft.tv_sec) || | 311 | (data->socket_timeout.tv_sec > timeleft.tv_sec) || |
| 325 | (data->socket_timeout.tv_sec == timeleft.tv_sec && | 312 | (data->socket_timeout.tv_sec == timeleft.tv_sec && |
| 326 | data->socket_timeout.tv_usec >= timeleft.tv_usec)) { | 313 | data->socket_timeout.tv_usec >= timeleft.tv_usec)) { |
| 327 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 328 | timeout = timeleft.tv_sec * 1000 + timeleft.tv_usec / 1000; | ||
| 329 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
| 330 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
| 331 | perror("setsockopt"); | ||
| 332 | } | ||
| 333 | #else | ||
| 334 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 314 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
| 335 | &timeleft, sizeof(struct timeval)) < 0) { | 315 | &timeleft, sizeof(struct timeval)) < 0) { |
| 336 | perror("setsockopt"); | 316 | perror("setsockopt"); |
| 337 | } | 317 | } |
| 338 | #endif | ||
| 339 | } | 318 | } |
| 340 | } | 319 | } |
| 341 | #endif | 320 | #endif |
| @@ -349,19 +328,10 @@ dgram_reset_rcv_timeout(BIO *b) | |||
| 349 | 328 | ||
| 350 | /* Is a timer active? */ | 329 | /* Is a timer active? */ |
| 351 | if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0) { | 330 | if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0) { |
| 352 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 353 | int timeout = data->socket_timeout.tv_sec * 1000 + | ||
| 354 | data->socket_timeout.tv_usec / 1000; | ||
| 355 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
| 356 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
| 357 | perror("setsockopt"); | ||
| 358 | } | ||
| 359 | #else | ||
| 360 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 331 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
| 361 | &(data->socket_timeout), sizeof(struct timeval)) < 0) { | 332 | &(data->socket_timeout), sizeof(struct timeval)) < 0) { |
| 362 | perror("setsockopt"); | 333 | perror("setsockopt"); |
| 363 | } | 334 | } |
| 364 | #endif | ||
| 365 | } | 335 | } |
| 366 | #endif | 336 | #endif |
| 367 | } | 337 | } |
| @@ -716,23 +686,11 @@ default: | |||
| 716 | break; | 686 | break; |
| 717 | #if defined(SO_RCVTIMEO) | 687 | #if defined(SO_RCVTIMEO) |
| 718 | case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: | 688 | case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: |
| 719 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 720 | { | ||
| 721 | struct timeval *tv = (struct timeval *)ptr; | ||
| 722 | int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000; | ||
| 723 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
| 724 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
| 725 | perror("setsockopt"); | ||
| 726 | ret = -1; | ||
| 727 | } | ||
| 728 | } | ||
| 729 | #else | ||
| 730 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, | 689 | if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, |
| 731 | sizeof(struct timeval)) < 0) { | 690 | sizeof(struct timeval)) < 0) { |
| 732 | perror("setsockopt"); | 691 | perror("setsockopt"); |
| 733 | ret = -1; | 692 | ret = -1; |
| 734 | } | 693 | } |
| 735 | #endif | ||
| 736 | break; | 694 | break; |
| 737 | case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: | 695 | case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: |
| 738 | { | 696 | { |
| @@ -740,21 +698,6 @@ default: | |||
| 740 | size_t s; | 698 | size_t s; |
| 741 | int i; | 699 | int i; |
| 742 | } sz = {0}; | 700 | } sz = {0}; |
| 743 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 744 | int timeout; | ||
| 745 | struct timeval *tv = (struct timeval *)ptr; | ||
| 746 | |||
| 747 | sz.i = sizeof(timeout); | ||
| 748 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | ||
| 749 | (void*)&timeout, &sz.i) < 0) { | ||
| 750 | perror("getsockopt"); | ||
| 751 | ret = -1; | ||
| 752 | } else { | ||
| 753 | tv->tv_sec = timeout / 1000; | ||
| 754 | tv->tv_usec = (timeout % 1000) * 1000; | ||
| 755 | ret = sizeof(*tv); | ||
| 756 | } | ||
| 757 | #else | ||
| 758 | sz.i = sizeof(struct timeval); | 701 | sz.i = sizeof(struct timeval); |
| 759 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, | 702 | if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, |
| 760 | ptr, (void *)&sz) < 0) { | 703 | ptr, (void *)&sz) < 0) { |
| @@ -765,29 +708,16 @@ default: | |||
| 765 | ret = (int)sz.s; | 708 | ret = (int)sz.s; |
| 766 | } else | 709 | } else |
| 767 | ret = sz.i; | 710 | ret = sz.i; |
| 768 | #endif | ||
| 769 | } | 711 | } |
| 770 | break; | 712 | break; |
| 771 | #endif | 713 | #endif |
| 772 | #if defined(SO_SNDTIMEO) | 714 | #if defined(SO_SNDTIMEO) |
| 773 | case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT: | 715 | case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT: |
| 774 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 775 | { | ||
| 776 | struct timeval *tv = (struct timeval *)ptr; | ||
| 777 | int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000; | ||
| 778 | if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | ||
| 779 | (void*)&timeout, sizeof(timeout)) < 0) { | ||
| 780 | perror("setsockopt"); | ||
| 781 | ret = -1; | ||
| 782 | } | ||
| 783 | } | ||
| 784 | #else | ||
| 785 | if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, | 716 | if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, |
| 786 | sizeof(struct timeval)) < 0) { | 717 | sizeof(struct timeval)) < 0) { |
| 787 | perror("setsockopt"); | 718 | perror("setsockopt"); |
| 788 | ret = -1; | 719 | ret = -1; |
| 789 | } | 720 | } |
| 790 | #endif | ||
| 791 | break; | 721 | break; |
| 792 | case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: | 722 | case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: |
| 793 | { | 723 | { |
| @@ -795,21 +725,6 @@ default: | |||
| 795 | size_t s; | 725 | size_t s; |
| 796 | int i; | 726 | int i; |
| 797 | } sz = {0}; | 727 | } sz = {0}; |
| 798 | #ifdef OPENSSL_SYS_WINDOWS | ||
| 799 | int timeout; | ||
| 800 | struct timeval *tv = (struct timeval *)ptr; | ||
| 801 | |||
| 802 | sz.i = sizeof(timeout); | ||
| 803 | if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | ||
| 804 | (void*)&timeout, &sz.i) < 0) { | ||
| 805 | perror("getsockopt"); | ||
| 806 | ret = -1; | ||
| 807 | } else { | ||
| 808 | tv->tv_sec = timeout / 1000; | ||
| 809 | tv->tv_usec = (timeout % 1000) * 1000; | ||
| 810 | ret = sizeof(*tv); | ||
| 811 | } | ||
| 812 | #else | ||
| 813 | sz.i = sizeof(struct timeval); | 728 | sz.i = sizeof(struct timeval); |
| 814 | if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, | 729 | if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, |
| 815 | ptr, (void *)&sz) < 0) { | 730 | ptr, (void *)&sz) < 0) { |
| @@ -820,19 +735,13 @@ default: | |||
| 820 | ret = (int)sz.s; | 735 | ret = (int)sz.s; |
| 821 | } else | 736 | } else |
| 822 | ret = sz.i; | 737 | ret = sz.i; |
| 823 | #endif | ||
| 824 | } | 738 | } |
| 825 | break; | 739 | break; |
| 826 | #endif | 740 | #endif |
| 827 | case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: | 741 | case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: |
| 828 | /* fall-through */ | 742 | /* fall-through */ |
| 829 | case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: | 743 | case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: |
| 830 | #ifdef OPENSSL_SYS_WINDOWS | 744 | if (data->_errno == EAGAIN) { |
| 831 | if (data->_errno == WSAETIMEDOUT) | ||
| 832 | #else | ||
| 833 | if (data->_errno == EAGAIN) | ||
| 834 | #endif | ||
| 835 | { | ||
| 836 | ret = 1; | 745 | ret = 1; |
| 837 | data->_errno = 0; | 746 | data->_errno = 0; |
| 838 | } else | 747 | } else |
| @@ -1769,16 +1678,6 @@ BIO_dgram_should_retry(int i) | |||
| 1769 | 1678 | ||
| 1770 | if ((i == 0) || (i == -1)) { | 1679 | if ((i == 0) || (i == -1)) { |
| 1771 | err = errno; | 1680 | err = errno; |
| 1772 | |||
| 1773 | #if defined(OPENSSL_SYS_WINDOWS) | ||
| 1774 | /* If the socket return value (i) is -1 | ||
| 1775 | * and err is unexpectedly 0 at this point, | ||
| 1776 | * the error code was overwritten by | ||
| 1777 | * another system call before this error | ||
| 1778 | * handling is called. | ||
| 1779 | */ | ||
| 1780 | #endif | ||
| 1781 | |||
| 1782 | return (BIO_dgram_non_fatal_error(err)); | 1681 | return (BIO_dgram_non_fatal_error(err)); |
| 1783 | } | 1682 | } |
| 1784 | return (0); | 1683 | return (0); |
| @@ -1788,17 +1687,6 @@ int | |||
| 1788 | BIO_dgram_non_fatal_error(int err) | 1687 | BIO_dgram_non_fatal_error(int err) |
| 1789 | { | 1688 | { |
| 1790 | switch (err) { | 1689 | switch (err) { |
| 1791 | #if defined(OPENSSL_SYS_WINDOWS) | ||
| 1792 | # if defined(WSAEWOULDBLOCK) | ||
| 1793 | case WSAEWOULDBLOCK: | ||
| 1794 | # endif | ||
| 1795 | |||
| 1796 | # if 0 /* This appears to always be an error */ | ||
| 1797 | # if defined(WSAENOTCONN) | ||
| 1798 | case WSAENOTCONN: | ||
| 1799 | # endif | ||
| 1800 | # endif | ||
| 1801 | #endif | ||
| 1802 | 1690 | ||
| 1803 | #ifdef EWOULDBLOCK | 1691 | #ifdef EWOULDBLOCK |
| 1804 | # ifdef WSAEWOULDBLOCK | 1692 | # ifdef WSAEWOULDBLOCK |
