[asterisk-commits] wedhorn: branch wedhorn/skinny-session r390752 - /team/wedhorn/skinny-session...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 6 16:44:39 CDT 2013
Author: wedhorn
Date: Thu Jun 6 16:44:38 2013
New Revision: 390752
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390752
Log:
skinny: fixup session locks for some edge cases
Modified:
team/wedhorn/skinny-session/channels/chan_skinny.c
Modified: team/wedhorn/skinny-session/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/wedhorn/skinny-session/channels/chan_skinny.c?view=diff&rev=390752&r1=390751&r2=390752
==============================================================================
--- team/wedhorn/skinny-session/channels/chan_skinny.c (original)
+++ team/wedhorn/skinny-session/channels/chan_skinny.c Thu Jun 6 16:44:38 2013
@@ -1613,7 +1613,7 @@
char outbuf[SKINNY_MAX_PACKET];
struct skinny_device *device;
AST_LIST_ENTRY(skinnysession) list;
- int destroy;
+ int lockstate; /* Only for use in the skinny_session thread */
int auth_timeout_sched;
int keepalive_timeout_sched;
};
@@ -7324,6 +7324,7 @@
static void destroy_session(struct skinnysession *s)
{
+ ast_mutex_lock(&s->lock);
if (s->fd > -1) {
close(s->fd);
}
@@ -7333,7 +7334,7 @@
} else {
ast_atomic_fetchadd_int(&unauth_sessions, -1);
}
-
+ ast_mutex_unlock(&s->lock);
ast_mutex_destroy(&s->lock);
ast_free(s);
}
@@ -7355,6 +7356,10 @@
struct skinny_speeddial *sd;
ast_verb(3, "Ending Skinny session from %s\n", ast_inet_ntoa(s->sin.sin_addr));
+
+ if (s->lockstate) {
+ ast_mutex_unlock(&s->lock);
+ }
if (d) {
d->session = NULL;
@@ -7392,7 +7397,6 @@
int dlen = 0;
int timeout;
struct pollfd fds[1];
- int lockstate = 0;
if (!s) {
ast_verb(3, "Bad Skinny Session\n");
@@ -7408,6 +7412,7 @@
}
ast_mutex_init(&s->lock);
+ s->lockstate = 0;
AST_LIST_LOCK(&sessions);
AST_LIST_INSERT_HEAD(&sessions, s, list);
@@ -7425,9 +7430,6 @@
res = ast_poll(fds, 1, timeout); /* If nothing has happen, client is dead */
/* we add 10% to the keep_alive to deal */
/* with network delays, etc */
- if (s->destroy) {
- break;
- }
if (res < 0) {
if (errno != EINTR) {
ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno));
@@ -7452,7 +7454,7 @@
}
ast_mutex_lock(&s->lock);
- lockstate = 1;
+ s->lockstate = 1;
if ((res = read(s->fd, req, skinny_header_size)) != skinny_header_size) {
if (res < 0) {
@@ -7504,7 +7506,7 @@
}
ast_mutex_unlock(&s->lock);
- lockstate = 0;
+ s->lockstate = 0;
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
res = handle_message(req, s);
@@ -7522,9 +7524,6 @@
}
ast_debug(3, "Skinny Session returned: %s\n", strerror(errno));
- if (lockstate) {
- ast_mutex_unlock(&s->lock);
- }
if (req) {
ast_free(req);
}
More information about the asterisk-commits
mailing list