Lines Matching defs:srv

29 	struct http_server *srv;
51 struct http_server *srv = req->srv;
57 srv->cb(srv->cb_ctx, req);
67 static struct http_request * http_request_init(struct http_server *srv, int fd,
72 if (srv->request_count >= HTTP_SERVER_MAX_CONNECTIONS) {
81 req->srv = srv;
100 struct http_server *srv;
105 srv = req->srv;
107 r = srv->requests;
113 srv->requests = r->next;
114 srv->request_count--;
209 struct http_server *srv = eloop_ctx;
213 conn = accept(srv->fd, (struct sockaddr *) &addr, &addr_len);
222 req = http_request_init(srv, conn, &addr);
228 req->next = srv->requests;
229 srv->requests = req;
230 srv->request_count++;
240 struct http_server *srv;
242 srv = os_zalloc(sizeof(*srv));
243 if (srv == NULL)
245 srv->cb = cb;
246 srv->cb_ctx = cb_ctx;
248 srv->fd = socket(AF_INET, SOCK_STREAM, 0);
249 if (srv->fd < 0)
251 if (fcntl(srv->fd, F_SETFL, O_NONBLOCK) < 0)
254 srv->port = 49152;
256 srv->port = port;
263 sin.sin_port = htons(srv->port);
264 if (bind(srv->fd, (struct sockaddr *) &sin, sizeof(sin)) == 0)
268 if (++srv->port == 65535 || port >= 0)
273 "%s", srv->port, strerror(errno));
276 if (listen(srv->fd, 10 /* max backlog */) < 0)
278 if (fcntl(srv->fd, F_SETFL, O_NONBLOCK) < 0)
280 if (eloop_register_sock(srv->fd, EVENT_TYPE_READ, http_server_cb,
281 srv, NULL))
285 inet_ntoa(*addr), srv->port);
287 return srv;
290 http_server_deinit(srv);
295 void http_server_deinit(struct http_server *srv)
297 if (srv == NULL)
299 if (srv->fd >= 0) {
300 eloop_unregister_sock(srv->fd, EVENT_TYPE_READ);
301 close(srv->fd);
303 http_request_free_all(srv->requests);
305 os_free(srv);
309 int http_server_get_port(struct http_server *srv)
311 return srv->port;