Lock it!!!!!

This commit is contained in:
dcp1990 2005-06-12 18:53:52 +00:00
parent 7395fd9f23
commit ca44312d08

View File

@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
/* $Amigan: phoned/phoned/filters.c,v 1.5 2005/06/12 18:51:07 dcp1990 Exp $ */ /* $Amigan: phoned/phoned/filters.c,v 1.6 2005/06/12 18:53:52 dcp1990 Exp $ */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -52,6 +52,7 @@ void free_condition(h, traverse)
cond_t *ls, *c, *tp; cond_t *ls, *c, *tp;
tp = h; tp = h;
if(tp == 0x0) return; if(tp == 0x0) return;
pthread_mutex_lock(&condmx);
if(traverse) { if(traverse) {
c = tp; c = tp;
while(c > 0x0) { while(c > 0x0) {
@ -64,6 +65,7 @@ void free_condition(h, traverse)
free_cond_elms(tp); free_cond_elms(tp);
free(tp); free(tp);
} }
pthread_mutex_unlock(&condmx);
} }
cond_t* add_condition(filtname, nameregex, numregex, action) cond_t* add_condition(filtname, nameregex, numregex, action)
@ -83,7 +85,6 @@ cond_t* add_condition(filtname, nameregex, numregex, action)
nc->last = c; nc->last = c;
c->next = nc; c->next = nc;
} }
pthread_mutex_unlock(&condmx); /* done */
nc->name = strdup(filtname); nc->name = strdup(filtname);
if(nameregex != 0x0) { if(nameregex != 0x0) {
nc->name = strdup(nameregex); nc->name = strdup(nameregex);
@ -105,5 +106,6 @@ cond_t* add_condition(filtname, nameregex, numregex, action)
lprintf(info, "Added filter %s, namerx = %s, numrx = %s, action = %b\n", lprintf(info, "Added filter %s, namerx = %s, numrx = %s, action = %b\n",
filtname, nameregex, numregex, action, "\10" SCTACT_IGN "IGNORE" SCTACT_HUP "HANGUP" filtname, nameregex, numregex, action, "\10" SCTACT_IGN "IGNORE" SCTACT_HUP "HANGUP"
SCTACT_RNOT "MAIL" SCTACT_ANS "ANSWER" SCTACT_PLAY "PLAY" SCTACT_REC "RECORD\n"); SCTACT_RNOT "MAIL" SCTACT_ANS "ANSWER" SCTACT_PLAY "PLAY" SCTACT_REC "RECORD\n");
pthread_mutex_unlock(&condmx); /* done */
return nc; return nc;
} }