comparison src/os/unix/ngx_socket.c @ 101:2e069b6e6920

nginx-0.0.1-2003-06-04-21:28:33 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 04 Jun 2003 17:28:33 +0000
parents 738fe44c70d5
children 6dfda4cf5200
comparison
equal deleted inserted replaced
100:7ebc8b7fb816 101:2e069b6e6920
1 1
2 #include <ngx_socket.h> 2 #include <ngx_config.h>
3 #include <ngx_core.h>
3 4
4 5
5 /* 6 /*
6 ioctl(FIONBIO) set blocking mode with one syscall only while 7 ioctl(FIONBIO) set blocking mode with one syscall only while
7 fcntl(F_SETFL, ~O_NONBLOCK) need to know previous state 8 fcntl(F_SETFL, ~O_NONBLOCK) need to know previous state
8 using fcntl(F_GETFL). 9 using fcntl(F_GETFL).
9 10
10 ioctl() and fcntl() are syscalls on FreeBSD, Solaris 7/8 and Linux 11 ioctl() and fcntl() are syscalls on FreeBSD, Solaris 7/8 and Linux
11 */ 12 */
12 13
13 #if 1 14
15 #if (HAVE_FIONBIO)
14 16
15 int ngx_nonblocking(ngx_socket_t s) 17 int ngx_nonblocking(ngx_socket_t s)
16 { 18 {
17 unsigned long nb = 1; 19 unsigned long nb = 1;
18 20
19 return ioctl(s, FIONBIO, &nb); 21 return ioctl(s, FIONBIO, &nb);
20 } 22 }
23
21 24
22 int ngx_blocking(ngx_socket_t s) 25 int ngx_blocking(ngx_socket_t s)
23 { 26 {
24 unsigned long nb = 0; 27 unsigned long nb = 0;
25 28
26 return ioctl(s, FIONBIO, &nb); 29 return ioctl(s, FIONBIO, &nb);
27 } 30 }
28 31
29 #endif 32 #endif
33
34
35 #ifdef __FreeBSD__
36
37 int ngx_tcp_nopush(ngx_socket_t s)
38 {
39 int tcp_nopush;
40
41 tcp_nopush = 1;
42
43 return setsockopt(s, IPPROTO_TCP, TCP_NOPUSH,
44 (const void *) &tcp_nopush, sizeof(int));
45 }
46
47
48 int ngx_tcp_push(ngx_socket_t s)
49 {
50 int tcp_nopush;
51
52 tcp_nopush = 0;
53
54 return setsockopt(s, IPPROTO_TCP, TCP_NOPUSH,
55 (const void *) &tcp_nopush, sizeof(int));
56 }
57
58 #else
59
60
61 int ngx_tcp_nopush(ngx_socket_t s)
62 {
63 return NGX_OK;
64 }
65
66 int ngx_tcp_push(ngx_socket_t s)
67 {
68 return NGX_OK;
69 }
70
71 #endif