src/server/daemon/sessionhandler.c

changeset 142
55298bc9ed28
parent 141
ff311b63c3af
child 152
8b85c5face66
equal deleted inserted replaced
141:ff311b63c3af 142:55298bc9ed28
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 int ret = SSL_read(conn->ssl, buf, len); 61 int ret = SSL_read(conn->ssl, buf, len);
62 if(ret <= 0) { 62 if(ret <= 0) {
63 conn->ssl_error = SSL_get_error(conn->ssl, ret); 63 conn->ssl_error = SSL_get_error(conn->ssl, ret);
64 if(conn->ssl_error == SSL_ERROR_SYSCALL) {
65 log_ereport(
66 LOG_VERBOSE,
67 "Connection: %d: SSL_read failed: %s",
68 (int)conn,
69 strerror(errno));
70 }
71 } 64 }
72 return ret; 65 return ret;
73 } 66 }
74 67
75 int connection_ssl_write(Connection *conn, const void *buf, int len) { 68 int connection_ssl_write(Connection *conn, const void *buf, int len) {
76 int ret = SSL_write(conn->ssl, buf, len); 69 int ret = SSL_write(conn->ssl, buf, len);
77 if(ret <= 0) { 70 if(ret <= 0) {
78 conn->ssl_error = SSL_get_error(conn->ssl, ret); 71 conn->ssl_error = SSL_get_error(conn->ssl, ret);
79 if(conn->ssl_error == SSL_ERROR_SYSCALL) { 72 }
80 log_ereport( 73 return ret;
81 LOG_VERBOSE, 74 }
82 "Connection: %d: SSL_write failed: %s", 75
83 (int)conn, 76 void connection_ssl_close(Connection *conn) {
84 strerror(errno)); 77 if(!conn->ssl_error) {
78 int ret = SSL_shutdown(conn->ssl);
79 if(ret != 1) {
80 conn->ssl_error = SSL_get_error(conn->ssl, ret);
81 log_ereport(LOG_VERBOSE, "SSL_shutdown failed: %d", conn->ssl_error);
85 } 82 }
86 }
87 return ret;
88 }
89
90 void connection_ssl_close(Connection *conn) {
91 int ret = SSL_shutdown(conn->ssl);
92 if(ret != 1) {
93 conn->ssl_error = SSL_get_error(conn->ssl, ret);
94 log_ereport(LOG_VERBOSE, "SSL_shutdown failed: %d", conn->ssl_error);
95 } 83 }
96 close(conn->fd); 84 close(conn->fd);
97 } 85 }
98 86
99 void connection_destroy(Connection *conn) { 87 void connection_destroy(Connection *conn) {

mercurial