Project

General

Profile

0001-fix-build-on-mac-os-x.patch

fix build on mac os x -- iamawalrus - Anonymous, 2008-07-08 08:08

View differences:

src/Makefile.am
73 73
      network_gthread_aio.c network_gthread_sendfile.c \
74 74
      http_resp.c http_resp_parser.c \
75 75
      http_req.c http_req_parser.c \
76
      http_req_range.c http_req_range_parser.c timing.c
76
      http_req_range.c http_req_range_parser.c timing.c network_backends.c
77 77
      
78 78
src = server.c response.c connections.c network.c \
79 79
      configfile.c configparser.c request.c proc_open.c
src/network.c
27 27
# include <openssl/rand.h>
28 28
#endif
29 29

  
30
#define BACKEND_HANDLERS(read, write) network_read_chunkqueue_##read, network_write_chunkqueue_##write
31
static network_backend_info_t network_backends[] = {
32
	/* lowest id wins */
33
	{
34
		NETWORK_BACKEND_LINUX_SENDFILE,
35
		"linux-sendfile",
36
		NULL,
37
#if defined USE_WRITE && defined USE_LINUX_SENDFILE
38
		BACKEND_HANDLERS(read, linuxsendfile)
39
#else
40
		NULL, NULL
41
#endif
42
	},
43
	{
44
		NETWORK_BACKEND_LINUX_AIO_SENDFILE,
45
		"linux-aio-sendfile",
46
		NULL,
47
#if defined USE_WRITE && defined USE_LINUX_AIO_SENDFILE
48
		BACKEND_HANDLERS(read, linuxaiosendfile)
49
#else
50
		NULL, NULL
51
#endif
52
	},
53
	{
54
		NETWORK_BACKEND_FREEBSD_SENDFILE,
55
		"freebsd-sendfile",
56
		NULL,
57
#if defined USE_WRITE && defined USE_FREEBSD_SENDFILE
58
		BACKEND_HANDLERS(read, freebsdsendfile)
59
#else
60
		NULL, NULL
61
#endif
62
	},
63
	{
64
		NETWORK_BACKEND_SOLARIS_SENDFILEV,
65
		"solaris-sendfilev",
66
		NULL,
67
#if defined USE_WRITE && defined USE_SOLARIS_SENDFILEV
68
		BACKEND_HANDLERS(read, solarissendfilev)
69
#else
70
		NULL, NULL
71
#endif
72
	},
73
	{
74
		NETWORK_BACKEND_POSIX_AIO,
75
		"posix-aio",
76
		NULL,
77
#if defined USE_WRITE && defined USE_POSIX_AIO
78
		BACKEND_HANDLERS(read, posixaio)
79
#else
80
		NULL, NULL
81
#endif
82
	},
83

  
84
	{
85
		NETWORK_BACKEND_GTHREAD_AIO,
86
		"gthread-aio",
87
		NULL,
88
#if defined USE_WRITE && defined USE_GTHREAD_AIO
89
		BACKEND_HANDLERS(read, gthreadaio)
90
#else
91
		NULL, NULL
92
#endif
93
	},
94
	{
95
		NETWORK_BACKEND_GTHREAD_SENDFILE,
96
		"gthread-sendfile",
97
		NULL,
98
#if defined USE_WRITE && defined USE_GTHREAD_AIO && defined USE_GTHREAD_SENDFILE
99
		BACKEND_HANDLERS(read, gthreadsendfile)
100
#else
101
		NULL, NULL
102
#endif
103
	},
104

  
105
	{
106
		NETWORK_BACKEND_WRITEV,
107
		"writev",
108
		NULL,
109
#if defined USE_WRITE && defined USE_WRITEV
110
		BACKEND_HANDLERS(read, writev)
111
#else
112
		NULL, NULL
113
#endif
114
	},
115
	{
116
		NETWORK_BACKEND_WRITE,
117
		"write",
118
		NULL,
119
#if defined USE_WRITE
120
		BACKEND_HANDLERS(read, write)
121
#else
122
		NULL, NULL
123
#endif
124
	},
125
	{
126
		NETWORK_BACKEND_WIN32_TRANSMITFILE,
127
		"win32-transmitfile",
128
		NULL,
129
#if defined USE_WIN32_TRANSMITFILE
130
		BACKEND_HANDLERS(win32recv, win32transmitfile)
131
#else
132
		NULL, NULL
133
#endif
134
	},
135
	{
136
		NETWORK_BACKEND_WIN32_SEND,
137
		"win32-send",
138
		NULL,
139
#if defined USE_WIN32_SEND && defined USE_WIN32_SEND
140
		BACKEND_HANDLERS(win32recv, win32send)
141
#else
142
		NULL, NULL
143
#endif
144
	},
145

  
146
	{
147
		NETWORK_BACKEND_UNSET,
148
		NULL,
149
		NULL,
150
		NULL, NULL
151
	}
152
};
153

  
154
const network_backend_info_t *network_get_backends() {
155
	return network_backends;
156
}
157

  
158
const network_backend_info_t *network_get_defaultbackend() {
159
	const network_backend_info_t *backend = network_get_backends();
160

  
161
	while (backend->name) {
162
		if (backend->write_handler) {
163
			return backend;
164
		}
165
		backend ++;
166
	}
167

  
168
	return NULL;
169
}
170

  
171
const network_backend_info_t *network_get_backend_info_by_type(network_backend_t type) {
172
	const network_backend_info_t *backend = network_get_backends();
173

  
174
	while (backend->name) {
175
		if (type == backend->type) {
176
			return backend;
177
		}
178
		backend ++;
179
	}
180

  
181
	return NULL;
182
}
183

  
184
const network_backend_info_t *network_get_backend_info_by_name(const char *name) {
185
	const network_backend_info_t *backend = network_get_backends();
186

  
187
	while (backend->name) {
188
		if (strcmp(name, backend->name) == 0) {
189
			return backend;
190
		}
191
		backend ++;
192
	}
193

  
194
	return NULL;
195
}
196

  
197 30
handler_t network_server_handle_fdevent(void *s, void *context, int revents) {
198 31
	server     *srv = (server *)s;
199 32
	server_socket *srv_socket = (server_socket *)context;
src/network_backends.c
1
#include "network_backends.h"
2

  
3
#define BACKEND_HANDLERS(read, write) network_read_chunkqueue_##read, network_write_chunkqueue_##write
4

  
5
static network_backend_info_t network_backends[] = {
6
	/* lowest id wins */
7
	{
8
		NETWORK_BACKEND_LINUX_SENDFILE,
9
		"linux-sendfile",
10
		NULL,
11
#if defined USE_WRITE && defined USE_LINUX_SENDFILE
12
		BACKEND_HANDLERS(read, linuxsendfile)
13
#else
14
		NULL, NULL
15
#endif
16
	},
17
	{
18
		NETWORK_BACKEND_LINUX_AIO_SENDFILE,
19
		"linux-aio-sendfile",
20
		NULL,
21
#if defined USE_WRITE && defined USE_LINUX_AIO_SENDFILE
22
		BACKEND_HANDLERS(read, linuxaiosendfile)
23
#else
24
		NULL, NULL
25
#endif
26
	},
27
	{
28
		NETWORK_BACKEND_FREEBSD_SENDFILE,
29
		"freebsd-sendfile",
30
		NULL,
31
#if defined USE_WRITE && defined USE_FREEBSD_SENDFILE
32
		BACKEND_HANDLERS(read, freebsdsendfile)
33
#else
34
		NULL, NULL
35
#endif
36
	},
37
	{
38
		NETWORK_BACKEND_SOLARIS_SENDFILEV,
39
		"solaris-sendfilev",
40
		NULL,
41
#if defined USE_WRITE && defined USE_SOLARIS_SENDFILEV
42
		BACKEND_HANDLERS(read, solarissendfilev)
43
#else
44
		NULL, NULL
45
#endif
46
	},
47
	{
48
		NETWORK_BACKEND_POSIX_AIO,
49
		"posix-aio",
50
		NULL,
51
#if defined USE_WRITE && defined USE_POSIX_AIO
52
		BACKEND_HANDLERS(read, posixaio)
53
#else
54
		NULL, NULL
55
#endif
56
	},
57

  
58
	{
59
		NETWORK_BACKEND_GTHREAD_AIO,
60
		"gthread-aio",
61
		NULL,
62
#if defined USE_WRITE && defined USE_GTHREAD_AIO
63
		BACKEND_HANDLERS(read, gthreadaio)
64
#else
65
		NULL, NULL
66
#endif
67
	},
68
	{
69
		NETWORK_BACKEND_GTHREAD_SENDFILE,
70
		"gthread-sendfile",
71
		NULL,
72
#if defined USE_WRITE && defined USE_GTHREAD_AIO && defined USE_GTHREAD_SENDFILE
73
		BACKEND_HANDLERS(read, gthreadsendfile)
74
#else
75
		NULL, NULL
76
#endif
77
	},
78

  
79
	{
80
		NETWORK_BACKEND_WRITEV,
81
		"writev",
82
		NULL,
83
#if defined USE_WRITE && defined USE_WRITEV
84
		BACKEND_HANDLERS(read, writev)
85
#else
86
		NULL, NULL
87
#endif
88
	},
89
	{
90
		NETWORK_BACKEND_WRITE,
91
		"write",
92
		NULL,
93
#if defined USE_WRITE
94
		BACKEND_HANDLERS(read, write)
95
#else
96
		NULL, NULL
97
#endif
98
	},
99
	{
100
		NETWORK_BACKEND_WIN32_TRANSMITFILE,
101
		"win32-transmitfile",
102
		NULL,
103
#if defined USE_WIN32_TRANSMITFILE
104
		BACKEND_HANDLERS(win32recv, win32transmitfile)
105
#else
106
		NULL, NULL
107
#endif
108
	},
109
	{
110
		NETWORK_BACKEND_WIN32_SEND,
111
		"win32-send",
112
		NULL,
113
#if defined USE_WIN32_SEND && defined USE_WIN32_SEND
114
		BACKEND_HANDLERS(win32recv, win32send)
115
#else
116
		NULL, NULL
117
#endif
118
	},
119

  
120
	{
121
		NETWORK_BACKEND_UNSET,
122
		NULL,
123
		NULL,
124
		NULL, NULL
125
	}
126
};
127

  
128
const network_backend_info_t *network_get_backends() {
129
	return network_backends;
130
}
131

  
132
const network_backend_info_t *network_get_defaultbackend() {
133
	const network_backend_info_t *backend = network_get_backends();
134

  
135
	while (backend->name) {
136
		if (backend->write_handler) {
137
			return backend;
138
		}
139
		backend ++;
140
	}
141

  
142
	return NULL;
143
}
144

  
145
const network_backend_info_t *network_get_backend_info_by_type(network_backend_t type) {
146
	const network_backend_info_t *backend = network_get_backends();
147

  
148
	while (backend->name) {
149
		if (type == backend->type) {
150
			return backend;
151
		}
152
		backend ++;
153
	}
154

  
155
	return NULL;
156
}
157

  
158
const network_backend_info_t *network_get_backend_info_by_name(const char *name) {
159
	const network_backend_info_t *backend = network_get_backends();
160

  
161
	while (backend->name) {
162
		if (strcmp(name, backend->name) == 0) {
163
			return backend;
164
		}
165
		backend ++;
166
	}
167

  
168
	return NULL;
169
}
0
-