[svn-commits] file: branch file/netsock2 r96447 - /team/file/netsock2/main/netsock2.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Jan 3 22:58:13 CST 2008
Author: file
Date: Thu Jan 3 22:58:13 2008
New Revision: 96447
URL: http://svn.digium.com/view/asterisk?view=rev&rev=96447
Log:
Fix up a few TODOs.
Modified:
team/file/netsock2/main/netsock2.c
Modified: team/file/netsock2/main/netsock2.c
URL: http://svn.digium.com/view/asterisk/team/file/netsock2/main/netsock2.c?view=diff&rev=96447&r1=96446&r2=96447
==============================================================================
--- team/file/netsock2/main/netsock2.c (original)
+++ team/file/netsock2/main/netsock2.c Thu Jan 3 22:58:13 2008
@@ -102,19 +102,21 @@
/* Create a new SSL session using the parent SSL context */
if (!(child_socket->ssl = SSL_new(parent->ssl_ctx))) {
- /* TODO: Handle situation when this fails */
- ast_log(LOG_NOTICE, "Failed to setup SSL... SSL_new using parent SSL context failed.\n");
+ ast_log(LOG_WARNING, "Failed to setup SSL on TLS connection from %s.\n", ast_netsock2_sa_get_address(child_socket->addr));
+ AST_LIST_REMOVE(&parent->child_sockets, child_socket, list);
+ close(child_socket->fd);
+ ast_free(child_socket);
return NULL;
- } else
- ast_log(LOG_NOTICE, "Created new SSL instance from parent SSL context\n");
+ }
SSL_set_fd(child_socket->ssl, child_socket->fd);
/* Attempt to actually negotiate and accept the connection */
- /* TODO: Handle failure scenario better */
if (!(res = SSL_accept(child_socket->ssl)) || (res < 0)) {
- ast_log(LOG_NOTICE, "Failed to accept SSL connection. Handshake was not successful.\n");
+ ast_log(LOG_WARNING, "Failed to accept SSL connection from %s. Handshake was not successful.\n", ast_netsock2_sa_get_address(child_socket->addr));
+ AST_LIST_REMOVE(&parent->child_sockets, child_socket, list);
+ close(child_socket->fd);
+ ast_free(child_socket);
return NULL;
- } else
- ast_log(LOG_NOTICE, "Accepted SSL connection\n");
+ }
}
#endif
@@ -176,10 +178,8 @@
int netsocket;
/* Accept this new connection before we allocate memory for the child socket, that way if no memory can be allocated we can just disconnect them easy as pie */
- if ((netsocket = accept(socket->fd, (struct sockaddr*)&acceptaddr, &acceptaddrlen)) < 0) {
- /* TODO: Print out a warning message or something */
+ if ((netsocket = accept(socket->fd, (struct sockaddr*)&acceptaddr, &acceptaddrlen)) < 0)
return 1;
- }
/* Now we can allocate the memory for this new child socket */
if (!(child_socket = ast_calloc(1, sizeof(*child_socket)))) {
@@ -198,7 +198,7 @@
/* Now as the last step... create the thread that will handle this socket */
if (ast_pthread_create_background(&child_socket->thread, NULL, netsock2_accept_thread, child_socket)) {
- /* TODO: Print out a warning message or something */
+ ast_log(LOG_WARNING, "Failed to create thread to handle connection from %s\n", ast_netsock2_sa_get_address(child_socket->addr));
ast_free(child_socket);
close(netsocket);
return 1;
More information about the svn-commits
mailing list