summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mISDN.cpp19
-rw-r--r--main.c8
2 files changed, 14 insertions, 13 deletions
diff --git a/mISDN.cpp b/mISDN.cpp
index 6e74a90..9bff716 100644
--- a/mISDN.cpp
+++ b/mISDN.cpp
@@ -3153,7 +3153,7 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
/* allocate ressources of port */
#ifdef SOCKET_MISDN
- /* open layer 3 */
+ /* open layer 3 and init upqueue */
protocol = (nt)?L3_PROTOCOL_DSS1_USER:L3_PROTOCOL_DSS1_NET;
prop = 0;
if (ptp) // ptp forced
@@ -3165,9 +3165,11 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
mISDNport->ml3 = open_layer3(port-1, protocol, prop , do_layer3, mISDNport);
if (!mISDNport->ml3)
{
- PERROR_RUNTIME("Cannot get layer(%d) id of port %d\n", nt?2:4, port);
+ PERROR_RUNTIME("oper_layer3() failed for port %d\n", port);
+ mISDNport_close(mISDNport);
return(NULL);
}
+ mqueue_init(&mISDNport->upqueue);
#if 0
/* if ntmode, establish L1 to send the tei removal during start */
@@ -3352,11 +3354,6 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
}
#endif
-#ifdef SOCKET_MISDN
- /* init stack queue */
- mqueue_init(&mISDNport->upqueue);
-#endif
-
/* initially, we assume that the link is down, exept for nt-ptmp */
mISDNport->l2link = (mISDNport->ntmode && !mISDNport->ptp)?1:0;
@@ -3448,8 +3445,12 @@ void mISDNport_close(struct mISDNport *mISDNport)
}
#ifdef SOCKET_MISDN
- close_layer3(mISDNport->ml3);
- mqueue_purge(&mISDNport->upqueue);
+ /* close layer 3, if open and purge upqueue */
+ if (mISDNport->ml3)
+ {
+ close_layer3(mISDNport->ml3);
+ mqueue_purge(&mISDNport->upqueue);
+ }
#else
/* free ressources of port */
msg_queue_purge(&mISDNport->downqueue);
diff --git a/main.c b/main.c
index 8732b79..ac23868 100644
--- a/main.c
+++ b/main.c
@@ -176,7 +176,7 @@ void sighandler(int sigset)
return;
if (!quit)
{
- quit=1;
+ quit = sigset;
/* set scheduler & priority */
if (options.schedule > 1)
{
@@ -185,7 +185,7 @@ void sighandler(int sigset)
sched_setscheduler(0, SCHED_OTHER, &schedp);
}
fprintf(stderr, "LCR: Signal received: %d\n", sigset);
- PERROR("Signal received: %d\n", sigset);
+ PDEBUG(DEBUG_LOG, "Signal received: %d\n", sigset);
}
}
@@ -659,8 +659,8 @@ BUDETECT
SPRINT(tracetext, "%s terminated", NAME);
printf("%s\n", tracetext);
start_trace(0, NULL, NULL, NULL, 0, 0, 0, tracetext);
- if (ret)
- add_trace("error", NULL, "%d", ret);
+ if (quit)
+ add_trace("signal", NULL, "%d", quit);
end_trace();
ret=0;