summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-05 18:13:40 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-05 22:00:24 +0200
commit902e32e051714249a451f535be2cb5394b24eb3c (patch)
treefc0fb55b16c1a6cee936c7e49ebe4846b3a4daac
parenta9e39c3264a4acf36b25d38207cb3bd9bb00c9ac (diff)
[sccp] Add a force_free method for connections
E.g. when the underlying connection transport medium is gone one needs to force to close SCCP connections, add this helper. It will remove the connection from the list of connections and it will free the data.
-rw-r--r--include/sccp/sccp.h5
-rw-r--r--src/sccp/sccp.c11
2 files changed, 16 insertions, 0 deletions
diff --git a/include/sccp/sccp.h b/include/sccp/sccp.h
index 2e14788..604a2ac 100644
--- a/include/sccp/sccp.h
+++ b/include/sccp/sccp.h
@@ -106,6 +106,11 @@ int sccp_connection_close(struct sccp_connection *connection, int cause);
int sccp_connection_free(struct sccp_connection *connection);
/**
+ * internal..
+ */
+int sccp_connection_force_free(struct sccp_connection *conn);
+
+/**
* Create a new socket. Set your callbacks and then call bind to open
* the connection.
*/
diff --git a/src/sccp/sccp.c b/src/sccp/sccp.c
index 4bd87c8..e0fd02e 100644
--- a/src/sccp/sccp.c
+++ b/src/sccp/sccp.c
@@ -1198,6 +1198,17 @@ int sccp_connection_free(struct sccp_connection *connection)
return 0;
}
+int sccp_connection_force_free(struct sccp_connection *con)
+{
+ if (con->connection_state > SCCP_CONNECTION_STATE_NONE &&
+ con->connection_state < SCCP_CONNECTION_STATE_RELEASE_COMPLETE)
+ llist_del(&con->list);
+
+ con->connection_state = SCCP_CONNECTION_STATE_REFUSED;
+ sccp_connection_free(con);
+ return 0;
+}
+
struct sccp_connection *sccp_connection_socket(void)
{
return talloc_zero(tall_sccp_ctx, struct sccp_connection);