16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #include <errno.h>
27 #include <string.h>
28 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <netinet/tcp.h> /* Defines TCP_NODELAY, needed for 2.6 */
31 #include <netinet/in.h>
32 #include <net/if.h>
33 #include <netdb.h>
34 #include <stdlib.h>
35 #include <dlfcn.h>
36
37 #ifndef _ALLBSD_SOURCE
38 #include <values.h>
39 #else
40 #include <limits.h>
41 #include <sys/param.h>
42 #include <sys/sysctl.h>
43 #include <sys/ioctl.h>
44 #ifndef MAXINT
45 #define MAXINT INT_MAX
46 #endif
47 #endif
48
49 #ifdef __solaris__
50 #include <sys/filio.h>
51 #include <sys/sockio.h>
52 #include <stropts.h>
53 #include <inet/nd.h>
54 #endif
55
1651 pfd.events |= POLLOUT;
1652
1653 errno = 0;
1654 read_rv = NET_Poll(&pfd, 1, timeout);
1655
1656 newTime = JVM_CurrentTimeMillis(env, 0);
1657 timeout -= (newTime - prevTime);
1658 if (timeout <= 0) {
1659 return read_rv > 0 ? 0 : -1;
1660 }
1661 prevTime = newTime;
1662
1663 if (read_rv > 0) {
1664 break;
1665 }
1666
1667
1668 } /* while */
1669
1670 return timeout;
1671 }
|
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #include <errno.h>
27 #include <string.h>
28 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <netinet/tcp.h> /* Defines TCP_NODELAY, needed for 2.6 */
31 #include <netinet/in.h>
32 #include <net/if.h>
33 #include <netdb.h>
34 #include <stdlib.h>
35 #include <dlfcn.h>
36 #include <sys/time.h>
37
38 #ifndef _ALLBSD_SOURCE
39 #include <values.h>
40 #else
41 #include <limits.h>
42 #include <sys/param.h>
43 #include <sys/sysctl.h>
44 #include <sys/ioctl.h>
45 #ifndef MAXINT
46 #define MAXINT INT_MAX
47 #endif
48 #endif
49
50 #ifdef __solaris__
51 #include <sys/filio.h>
52 #include <sys/sockio.h>
53 #include <stropts.h>
54 #include <inet/nd.h>
55 #endif
56
1652 pfd.events |= POLLOUT;
1653
1654 errno = 0;
1655 read_rv = NET_Poll(&pfd, 1, timeout);
1656
1657 newTime = JVM_CurrentTimeMillis(env, 0);
1658 timeout -= (newTime - prevTime);
1659 if (timeout <= 0) {
1660 return read_rv > 0 ? 0 : -1;
1661 }
1662 prevTime = newTime;
1663
1664 if (read_rv > 0) {
1665 break;
1666 }
1667
1668
1669 } /* while */
1670
1671 return timeout;
1672 }
1673
1674 long NET_GetCurrentTime() {
1675 struct timeval time;
1676 gettimeofday(&time, NULL);
1677 return (time.tv_sec * 1000 + time.tv_usec / 1000);
1678 }
1679
1680 int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime) {
1681 return NET_Timeout0(s, timeout, currentTime);
1682 }
1683
1684 int NET_Timeout(int s, long timeout) {
1685 long currentTime = (timeout > 0) ? NET_GetCurrentTime() : 0;
1686 return NET_Timeout0(s, timeout, currentTime);
1687 }
|