Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ngx_socket.c
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) Igor Sysoev
4  * Copyright (C) Nginx, Inc.
5  */
6 
7 
8 #include <ngx_config.h>
9 #include <ngx_core.h>
10 
11 
12 /*
13  * ioctl(FIONBIO) sets a non-blocking mode with the single syscall
14  * while fcntl(F_SETFL, O_NONBLOCK) needs to learn the current state
15  * using fcntl(F_GETFL).
16  *
17  * ioctl() and fcntl() are syscalls at least in FreeBSD 2.x, Linux 2.2
18  * and Solaris 7.
19  *
20  * ioctl() in Linux 2.4 and 2.6 uses BKL, however, fcntl(F_SETFL) uses it too.
21  */
22 
23 
24 #if (NGX_HAVE_FIONBIO)
25 
26 int
28 {
29  int nb;
30 
31  nb = 1;
32 
33  return ioctl(s, FIONBIO, &nb);
34 }
35 
36 
37 int
39 {
40  int nb;
41 
42  nb = 0;
43 
44  return ioctl(s, FIONBIO, &nb);
45 }
46 
47 #endif
48 
49 
50 #if (NGX_FREEBSD)
51 
52 int
54 {
55  int tcp_nopush;
56 
57  tcp_nopush = 1;
58 
59  return setsockopt(s, IPPROTO_TCP, TCP_NOPUSH,
60  (const void *) &tcp_nopush, sizeof(int));
61 }
62 
63 
64 int
66 {
67  int tcp_nopush;
68 
69  tcp_nopush = 0;
70 
71  return setsockopt(s, IPPROTO_TCP, TCP_NOPUSH,
72  (const void *) &tcp_nopush, sizeof(int));
73 }
74 
75 #elif (NGX_LINUX)
76 
77 
78 int
80 {
81  int cork;
82 
83  cork = 1;
84 
85  return setsockopt(s, IPPROTO_TCP, TCP_CORK,
86  (const void *) &cork, sizeof(int));
87 }
88 
89 
90 int
92 {
93  int cork;
94 
95  cork = 0;
96 
97  return setsockopt(s, IPPROTO_TCP, TCP_CORK,
98  (const void *) &cork, sizeof(int));
99 }
100 
101 #else
102 
103 int
105 {
106  return 0;
107 }
108 
109 
110 int
112 {
113  return 0;
114 }
115 
116 #endif