122 } |
122 } |
123 return io; |
123 return io; |
124 } |
124 } |
125 |
125 |
126 |
126 |
127 SessionHandler* create_basic_session_handler() { |
127 SessionHandler* create_basic_session_handler(pool_handle_t *pool) { |
128 BasicSessionHandler *handler = malloc(sizeof(BasicSessionHandler)); |
128 BasicSessionHandler *handler = pool_malloc(pool, sizeof(BasicSessionHandler)); |
129 handler->threadpool = threadpool_new(4, 8); |
129 handler->threadpool = threadpool_new(4, 8); |
130 threadpool_start(handler->threadpool); // TODO: handle error |
130 threadpool_start(handler->threadpool); // TODO: handle error |
131 handler->sh.enqueue_connection = basic_enq_conn; |
131 handler->sh.enqueue_connection = basic_enq_conn; |
132 handler->sh.keep_alive = basic_keep_alive; |
132 handler->sh.keep_alive = basic_keep_alive; |
133 handler->sh.create_iostream = create_connection_iostream; |
133 handler->sh.create_iostream = create_connection_iostream; |
210 } |
210 } |
211 |
211 |
212 |
212 |
213 /* ----- event session handler ----- */ |
213 /* ----- event session handler ----- */ |
214 |
214 |
215 SessionHandler* create_event_session_handler() { |
215 SessionHandler* create_event_session_handler(pool_handle_t *pool) { |
216 EventSessionHandler *handler = malloc(sizeof(EventSessionHandler)); |
216 EventSessionHandler *handler = pool_malloc(pool, sizeof(EventSessionHandler)); |
217 handler->eventhandler = get_default_event_handler(); |
217 handler->eventhandler = get_default_event_handler(); |
218 handler->sh.enqueue_connection = evt_enq_conn; |
218 handler->sh.enqueue_connection = evt_enq_conn; |
219 handler->sh.keep_alive = evt_keep_alive; |
219 handler->sh.keep_alive = evt_keep_alive; |
220 handler->sh.create_iostream = create_connection_iostream; |
220 handler->sh.create_iostream = create_connection_iostream; |
221 return (SessionHandler*)handler; |
221 return (SessionHandler*)handler; |