src/server/daemon/sessionhandler.c

branch
aio
changeset 191
391ccd490d97
parent 188
0e6a05c779e0
child 192
6a145e13d933
equal deleted inserted replaced
190:1f73302461e0 191:391ccd490d97
91 SSL_free(conn->ssl); 91 SSL_free(conn->ssl);
92 } 92 }
93 free(conn); 93 free(conn);
94 } 94 }
95 95
96 IOStream* create_connection_iostream(SessionHandler *sh, Connection *conn, pool_handle_t *pool, WSBool *ssl) {
97 IOStream *io = NULL;
98 if(conn->ssl) {
99 io = sslstream_new(pool, conn->ssl);
100 *ssl = 1;
101 } else {
102 io = sysstream_new(pool, conn->fd);
103 *ssl = 0;
104 }
105 return io;
106 }
107
108
96 SessionHandler* create_basic_session_handler() { 109 SessionHandler* create_basic_session_handler() {
97 BasicSessionHandler *handler = malloc(sizeof(BasicSessionHandler)); 110 BasicSessionHandler *handler = malloc(sizeof(BasicSessionHandler));
98 handler->threadpool = threadpool_new(4, 8); 111 handler->threadpool = threadpool_new(4, 8);
99 handler->sh.enqueue_connection = basic_enq_conn; 112 handler->sh.enqueue_connection = basic_enq_conn;
100 handler->sh.keep_alive = basic_keep_alive; 113 handler->sh.keep_alive = basic_keep_alive;
114 handler->sh.create_iostream = create_connection_iostream;
101 115
102 return (SessionHandler*)handler; 116 return (SessionHandler*)handler;
103 } 117 }
104 118
105 void basic_enq_conn(SessionHandler *handler, Connection *conn) { 119 void basic_enq_conn(SessionHandler *handler, Connection *conn) {
170 SessionHandler* create_event_session_handler() { 184 SessionHandler* create_event_session_handler() {
171 EventSessionHandler *handler = malloc(sizeof(EventSessionHandler)); 185 EventSessionHandler *handler = malloc(sizeof(EventSessionHandler));
172 handler->eventhandler = get_default_event_handler(); 186 handler->eventhandler = get_default_event_handler();
173 handler->sh.enqueue_connection = evt_enq_conn; 187 handler->sh.enqueue_connection = evt_enq_conn;
174 handler->sh.keep_alive = evt_keep_alive; 188 handler->sh.keep_alive = evt_keep_alive;
189 handler->sh.create_iostream = create_connection_iostream;
175 return (SessionHandler*)handler; 190 return (SessionHandler*)handler;
176 } 191 }
177 192
178 void evt_enq_conn(SessionHandler *handler, Connection *conn) { 193 void evt_enq_conn(SessionHandler *handler, Connection *conn) {
179 HTTPRequest *request = malloc(sizeof(HTTPRequest)); 194 HTTPRequest *request = malloc(sizeof(HTTPRequest));

mercurial