Convert struct ast_tcptls_session_instance to finally use the ao2 object lock.
[asterisk/asterisk.git] / main / tcptls.c
index 8210839..48d8ff7 100644 (file)
@@ -131,12 +131,6 @@ HOOK_T ast_tcptls_server_write(struct ast_tcptls_session_instance *tcptls_sessio
        return write(tcptls_session->fd, buf, count);
 }
 
        return write(tcptls_session->fd, buf, count);
 }
 
-static void session_instance_destructor(void *obj)
-{
-       struct ast_tcptls_session_instance *i = obj;
-       ast_mutex_destroy(&i->lock);
-}
-
 /*! \brief
 * creates a FILE * from the fd passed by the accept thread.
 * This operation is potentially expensive (certificate verification),
 /*! \brief
 * creates a FILE * from the fd passed by the accept thread.
 * This operation is potentially expensive (certificate verification),
@@ -285,7 +279,7 @@ void *ast_tcptls_server_root(void *data)
                        }
                        continue;
                }
                        }
                        continue;
                }
-               tcptls_session = ao2_alloc(sizeof(*tcptls_session), session_instance_destructor);
+               tcptls_session = ao2_alloc(sizeof(*tcptls_session), NULL);
                if (!tcptls_session) {
                        ast_log(LOG_WARNING, "No memory for new session: %s\n", strerror(errno));
                        if (close(fd)) {
                if (!tcptls_session) {
                        ast_log(LOG_WARNING, "No memory for new session: %s\n", strerror(errno));
                        if (close(fd)) {
@@ -294,8 +288,6 @@ void *ast_tcptls_server_root(void *data)
                        continue;
                }
 
                        continue;
                }
 
-               ast_mutex_init(&tcptls_session->lock);
-
                flags = fcntl(fd, F_GETFL);
                fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
                tcptls_session->fd = fd;
                flags = fcntl(fd, F_GETFL);
                fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
                tcptls_session->fd = fd;
@@ -477,11 +469,10 @@ struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_s
                }
        }
 
                }
        }
 
-       if (!(tcptls_session = ao2_alloc(sizeof(*tcptls_session), session_instance_destructor))) {
+       if (!(tcptls_session = ao2_alloc(sizeof(*tcptls_session), NULL))) {
                goto error;
        }
 
                goto error;
        }
 
-       ast_mutex_init(&tcptls_session->lock);
        tcptls_session->client = 1;
        tcptls_session->fd = desc->accept_fd;
        tcptls_session->parent = desc;
        tcptls_session->client = 1;
        tcptls_session->fd = desc->accept_fd;
        tcptls_session->parent = desc;