56 void connection_close(Connection *conn) { |
56 void connection_close(Connection *conn) { |
57 close(conn->fd); |
57 close(conn->fd); |
58 } |
58 } |
59 |
59 |
60 int connection_ssl_read(Connection *conn, void *buf, int len) { |
60 int connection_ssl_read(Connection *conn, void *buf, int len) { |
61 return SSL_read(conn->ssl, buf, len); |
61 int ret = SSL_read(conn->ssl, buf, len); |
|
62 if(ret <= 0) { |
|
63 conn->ssl_error = SSL_get_error(); |
|
64 } |
|
65 return ret; |
62 } |
66 } |
63 |
67 |
64 int connection_ssl_write(Connection *conn, const void *buf, int len) { |
68 int connection_ssl_write(Connection *conn, const void *buf, int len) { |
65 return SSL_write(conn->ssl, buf, len); |
69 int ret = SSL_write(conn->ssl, buf, len); |
|
70 if(ret <= 0) { |
|
71 conn->ssl_error = SSL_get_error(); |
|
72 } |
|
73 return ret; |
66 } |
74 } |
67 |
75 |
68 void connection_ssl_close(Connection *conn) { |
76 void connection_ssl_close(Connection *conn) { |
69 SSL_shutdown(conn->ssl); |
77 SSL_shutdown(conn->ssl); |
70 close(conn->fd); |
78 close(conn->fd); |
71 } |
79 } |
72 |
80 |
73 void connection_destroy(Connection *conn) { |
81 void connection_destroy(Connection *conn) { |
|
82 conn->close(conn); |
74 if(conn->ssl) { |
83 if(conn->ssl) { |
75 SSL_free(conn->ssl); |
84 SSL_free(conn->ssl); |
76 } |
85 } |
77 conn->close(conn); |
|
78 |
|
79 free(conn); |
86 free(conn); |
80 } |
87 } |
81 |
88 |
82 SessionHandler* create_basic_session_handler() { |
89 SessionHandler* create_basic_session_handler() { |
83 BasicSessionHandler *handler = malloc(sizeof(BasicSessionHandler)); |
90 BasicSessionHandler *handler = malloc(sizeof(BasicSessionHandler)); |