Lines Matching refs:daemon
74 spdyf_cleanup_sessions (struct SPDY_Daemon *daemon) in spdyf_cleanup_sessions() argument
78 while (NULL != (session = daemon->cleanup_head)) in spdyf_cleanup_sessions()
80 DLL_remove (daemon->cleanup_head, in spdyf_cleanup_sessions()
81 daemon->cleanup_tail, in spdyf_cleanup_sessions()
95 spdyf_close_all_sessions (struct SPDY_Daemon *daemon) in spdyf_close_all_sessions() argument
99 while (NULL != (session = daemon->sessions_head)) in spdyf_close_all_sessions()
108 spdyf_cleanup_sessions(daemon); in spdyf_close_all_sessions()
120 spdyf_parse_options_va (struct SPDY_Daemon *daemon, in spdyf_parse_options_va() argument
127 if(opt & daemon->options) in spdyf_parse_options_va()
132 daemon->options |= opt; in spdyf_parse_options_va()
137 daemon->session_timeout = va_arg (valist, unsigned int) * 1000; in spdyf_parse_options_va()
140 daemon->address = va_arg (valist, struct sockaddr *); in spdyf_parse_options_va()
143 daemon->flags = va_arg (valist, enum SPDY_DAEMON_FLAG); in spdyf_parse_options_va()
146 daemon->io_subsystem = va_arg (valist, enum SPDY_IO_SUBSYSTEM); in spdyf_parse_options_va()
149 daemon->max_num_frames = va_arg (valist, uint32_t); in spdyf_parse_options_va()
183 struct SPDY_Daemon *daemon = NULL; in SPDYF_start_daemon_va() local
193 if (NULL == (daemon = malloc (sizeof (struct SPDY_Daemon)))) in SPDYF_start_daemon_va()
198 memset (daemon, 0, sizeof (struct SPDY_Daemon)); in SPDYF_start_daemon_va()
199 daemon->socket_fd = -1; in SPDYF_start_daemon_va()
200 daemon->port = port; in SPDYF_start_daemon_va()
202 if(SPDY_YES != spdyf_parse_options_va (daemon, valist)) in SPDYF_start_daemon_va()
208 if(0 == daemon->max_num_frames) in SPDYF_start_daemon_va()
209 daemon->max_num_frames = SPDYF_NUM_SENT_FRAMES_AT_ONCE; in SPDYF_start_daemon_va()
211 if(!port && NULL == daemon->address) in SPDYF_start_daemon_va()
216 if(0 == daemon->io_subsystem) in SPDYF_start_daemon_va()
217 daemon->io_subsystem = SPDY_IO_SUBSYSTEM_OPENSSL; in SPDYF_start_daemon_va()
219 if(SPDY_YES != SPDYF_io_set_daemon(daemon, daemon->io_subsystem)) in SPDYF_start_daemon_va()
222 if(SPDY_IO_SUBSYSTEM_RAW != daemon->io_subsystem) in SPDYF_start_daemon_va()
225 || NULL == (daemon->certfile = strdup (certfile))) in SPDYF_start_daemon_va()
231 || NULL == (daemon->keyfile = strdup (keyfile))) in SPDYF_start_daemon_va()
238 daemon->new_session_cb = nscb; in SPDYF_start_daemon_va()
239 daemon->session_closed_cb = sccb; in SPDYF_start_daemon_va()
240 daemon->new_request_cb = nrcb; in SPDYF_start_daemon_va()
241 daemon->received_data_cb = npdcb; in SPDYF_start_daemon_va()
242 daemon->cls = cls; in SPDYF_start_daemon_va()
243 daemon->fcls = fcls; in SPDYF_start_daemon_va()
244 daemon->fnew_stream_cb = fnscb; in SPDYF_start_daemon_va()
245 daemon->freceived_data_cb = fndcb; in SPDYF_start_daemon_va()
249 if((daemon->flags & SPDY_DAEMON_FLAG_ONLY_IPV6) in SPDYF_start_daemon_va()
250 && NULL != daemon->address && AF_INET6 != daemon->address->sa_family) in SPDYF_start_daemon_va()
258 if(NULL == daemon->address) in SPDYF_start_daemon_va()
269 daemon->address = (struct sockaddr *) servaddr6; in SPDYF_start_daemon_va()
272 if(AF_INET6 == daemon->address->sa_family) in SPDYF_start_daemon_va()
282 if(daemon->flags & SPDY_DAEMON_FLAG_ONLY_IPV6) in SPDYF_start_daemon_va()
290 if(NULL == daemon->address) in SPDYF_start_daemon_va()
301 daemon->address = (struct sockaddr *) servaddr4; in SPDYF_start_daemon_va()
307 daemon->socket_fd = socket (afamily, SOCK_STREAM, 0); in SPDYF_start_daemon_va()
308 if (-1 == daemon->socket_fd) in SPDYF_start_daemon_va()
315 ret = setsockopt(daemon->socket_fd, SOL_SOCKET, SO_REUSEADDR, &option_on, sizeof(option_on)); in SPDYF_start_daemon_va()
322 if(daemon->flags & SPDY_DAEMON_FLAG_ONLY_IPV6) in SPDYF_start_daemon_va()
324 ret = setsockopt(daemon->socket_fd, IPPROTO_IPV6, IPV6_V6ONLY, &option_on, sizeof(option_on)); in SPDYF_start_daemon_va()
333 if (-1 == bind (daemon->socket_fd, daemon->address, addrlen)) in SPDYF_start_daemon_va()
339 if (listen (daemon->socket_fd, 20) < 0) in SPDYF_start_daemon_va()
345 if(SPDY_YES != daemon->fio_init(daemon)) in SPDYF_start_daemon_va()
351 return daemon; in SPDYF_start_daemon_va()
355 if(daemon->socket_fd > 0) in SPDYF_start_daemon_va()
356 (void)close (daemon->socket_fd); in SPDYF_start_daemon_va()
362 if(NULL != daemon->certfile) in SPDYF_start_daemon_va()
363 free(daemon->certfile); in SPDYF_start_daemon_va()
364 if(NULL != daemon->keyfile) in SPDYF_start_daemon_va()
365 free(daemon->keyfile); in SPDYF_start_daemon_va()
366 free (daemon); in SPDYF_start_daemon_va()
373 SPDYF_stop_daemon (struct SPDY_Daemon *daemon) in SPDYF_stop_daemon() argument
375 daemon->fio_deinit(daemon); in SPDYF_stop_daemon()
377 shutdown (daemon->socket_fd, SHUT_RDWR); in SPDYF_stop_daemon()
378 spdyf_close_all_sessions (daemon); in SPDYF_stop_daemon()
379 (void)close (daemon->socket_fd); in SPDYF_stop_daemon()
381 if(!(SPDY_DAEMON_OPTION_SOCK_ADDR & daemon->options)) in SPDYF_stop_daemon()
382 free(daemon->address); in SPDYF_stop_daemon()
384 free(daemon->certfile); in SPDYF_stop_daemon()
385 free(daemon->keyfile); in SPDYF_stop_daemon()
387 free(daemon); in SPDYF_stop_daemon()
392 SPDYF_get_timeout (struct SPDY_Daemon *daemon, in SPDYF_get_timeout() argument
400 if(0 == daemon->session_timeout) in SPDYF_get_timeout()
405 for (pos = daemon->sessions_head; NULL != pos; pos = pos->next) in SPDYF_get_timeout()
408 (earliest_deadline > pos->last_activity + daemon->session_timeout) ) in SPDYF_get_timeout()
409 earliest_deadline = pos->last_activity + daemon->session_timeout; in SPDYF_get_timeout()
432 SPDYF_get_fdset (struct SPDY_Daemon *daemon, in SPDYF_get_fdset() argument
443 fd = daemon->socket_fd; in SPDYF_get_fdset()
451 for (pos = daemon->sessions_head; NULL != pos; pos = pos->next) in SPDYF_get_fdset()
459 || (daemon->session_timeout //timeout passed for the session in SPDYF_get_fdset()
460 && (pos->last_activity + daemon->session_timeout < SPDYF_monotonic_time())) in SPDYF_get_fdset()
474 SPDYF_run (struct SPDY_Daemon *daemon) in SPDYF_run() argument
492 max = SPDYF_get_fdset(daemon,&rs,&ws,&es, true); in SPDYF_run()
499 if ( (-1 != (ds = daemon->socket_fd)) && in SPDYF_run()
501 SPDYF_session_accept(daemon); in SPDYF_run()
504 next = daemon->sessions_head; in SPDYF_run()
543 spdyf_cleanup_sessions(daemon); in SPDYF_run()