projects
/
lcr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed wrong reference when requesting a channel from chan_lcr.
[lcr.git]
/
main.c
diff --git
a/main.c
b/main.c
index
e2d3f13
..
6eb2b68
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-10,6
+10,15
@@
\*****************************************************************************/
#include "main.h"
\*****************************************************************************/
#include "main.h"
+#ifdef PACKAGE_VERSION
+#undef PACKAGE_VERSION
+#endif
+#include "config.h"
+#ifdef WITH_GSM_MS
+extern "C" {
+#include <osmocom/core/signal.h>
+}
+#endif
//MESSAGES
//MESSAGES
@@
-22,7
+31,7
@@
struct timezone now_tz;
}
FILE *debug_fp = NULL;
}
FILE *debug_fp = NULL;
-int quit
=
0;
+int quit
=
0;
#if 0
struct lcr_fdset lcr_fdset[FD_SETSIZE];
#if 0
struct lcr_fdset lcr_fdset[FD_SETSIZE];
@@
-137,11
+146,23
@@
void _printerror(const char *function, int line, const char *fmt, ...)
void sighandler(int sigset)
{
struct sched_param schedp;
void sighandler(int sigset)
{
struct sched_param schedp;
+#ifdef WITH_GSM_MS
+ int wait_ms = 0;
+#endif
if (sigset == SIGHUP)
return;
if (sigset == SIGPIPE)
return;
if (sigset == SIGHUP)
return;
if (sigset == SIGPIPE)
return;
+ fprintf(stderr, "LCR: Signal received: %d\n", sigset);
+ PDEBUG(DEBUG_LOG, "Signal received: %d\n", sigset);
+#ifdef WITH_GSM_MS
+ if (!wait_ms) {
+ wait_ms = 1;
+ osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
+ return;
+ }
+#endif
if (!quit) {
quit = sigset;
/* set scheduler & priority */
if (!quit) {
quit = sigset;
/* set scheduler & priority */
@@
-150,8
+171,6
@@
void sighandler(int sigset)
schedp.sched_priority = 0;
sched_setscheduler(0, SCHED_OTHER, &schedp);
}
schedp.sched_priority = 0;
sched_setscheduler(0, SCHED_OTHER, &schedp);
}
- fprintf(stderr, "LCR: Signal received: %d\n", sigset);
- PDEBUG(DEBUG_LOG, "Signal received: %d\n", sigset);
}
}
}
}
@@
-161,7
+180,7
@@
void sighandler(int sigset)
*/
int main(int argc, char *argv[])
{
*/
int main(int argc, char *argv[])
{
-#if
def WITH_GSM
+#if
defined WITH_GSM_BS || defined WITH_GSM_MS
double now_d, last_d;
int all_idle;
#endif
double now_d, last_d;
int all_idle;
#endif
@@
-362,15
+381,27
@@
int main(int argc, char *argv[])
goto free;
}
goto free;
}
-#if
def WITH_GSM
- /*
handle
gsm */
+#if
defined WITH_GSM_BS || defined WITH_GSM_MS
+ /*
init
gsm */
if (options.gsm && gsm_init()) {
fprintf(stderr, "GSM initialization failed.\n");
goto free;
}
#else
if (options.gsm) {
if (options.gsm && gsm_init()) {
fprintf(stderr, "GSM initialization failed.\n");
goto free;
}
#else
if (options.gsm) {
- fprintf(stderr, "GSM is enabled, but not compiled. Use --with-gsm while configure!\n");
+ fprintf(stderr, "GSM is enabled, but not compiled. Use --with-gsm-bs or --with-gsm-ms while configure!\n");
+ goto free;
+ }
+#endif
+#ifdef WITH_GSM_BS
+ if (options.gsm && gsm_bs_init()) {
+ fprintf(stderr, "GSM BS initialization failed.\n");
+ goto free;
+ }
+#endif
+#ifdef WITH_GSM_MS
+ if (options.gsm && gsm_ms_init()) {
+ fprintf(stderr, "GSM MS initialization failed.\n");
goto free;
}
#endif
goto free;
}
#endif
@@
-436,11
+467,11
@@
int main(int argc, char *argv[])
printf("%s\n", tracetext);
end_trace();
quit = 0;
printf("%s\n", tracetext);
end_trace();
quit = 0;
-#if
def WITH_GSM
+#if
defined WITH_GSM_BS || defined WITH_GSM_MS
GET_NOW();
#endif
while(!quit) {
GET_NOW();
#endif
while(!quit) {
-#if
def WITH_GSM
+#if
defined WITH_GSM_BS || defined WITH_GSM_MS
last_d = now_d;
GET_NOW();
if (now_d-last_d > 1.0) {
last_d = now_d;
GET_NOW();
if (now_d-last_d > 1.0) {
@@
-453,9
+484,14
@@
int main(int argc, char *argv[])
if (select_main(1, NULL, NULL, NULL))
all_idle = 0;
/* handle gsm */
if (select_main(1, NULL, NULL, NULL))
all_idle = 0;
/* handle gsm */
- if (options.gsm)
- while(handle_gsm())
+ if (options.gsm) {
+ if (handle_gsm())
+ all_idle = 0;
+#ifdef WITH_GSM_MS
+ if (handle_gsm_ms(&quit))
all_idle = 0;
all_idle = 0;
+#endif
+ }
if (all_idle) {
usleep(10000);
}
if (all_idle) {
usleep(10000);
}
@@
-470,8
+506,10
@@
int main(int argc, char *argv[])
SPRINT(tracetext, "%s terminated", NAME);
printf("%s\n", tracetext);
start_trace(-1, NULL, NULL, NULL, 0, 0, 0, tracetext);
SPRINT(tracetext, "%s terminated", NAME);
printf("%s\n", tracetext);
start_trace(-1, NULL, NULL, NULL, 0, 0, 0, tracetext);
- if (quit)
+ if (quit
> 0
)
add_trace((char *)"signal", NULL, "%d", quit);
add_trace((char *)"signal", NULL, "%d", quit);
+ if (quit < 0)
+ add_trace((char *)"errno", NULL, "%d", quit);
end_trace();
ret=0;
end_trace();
ret=0;
@@
-565,11
+603,22
@@
free:
if (created_misdn)
mISDN_deinitialize();
if (created_misdn)
mISDN_deinitialize();
-#ifdef WITH_GSM
/* free gsm */
/* free gsm */
- if (options.gsm)
+ if (options.gsm) {
+#ifdef WITH_GSM_BS
+ gsm_bs_exit(0);
+#endif
+#ifdef WITH_GSM_MS
+ gsm_ms_exit(0);
+#endif
+#if defined WITH_GSM_BS || defined WITH_GSM_MS
gsm_exit(0);
#endif
gsm_exit(0);
#endif
+ }
+
+ /* close loopback, if used by GSM or remote */
+ if (mISDNloop.sock > -1)
+ mISDNloop_close();
/* display memory leak */
#define MEMCHECK(a, b) \
/* display memory leak */
#define MEMCHECK(a, b) \