added exporting/importing bchannel stacks to the remote application
[lcr.git] / main.c
diff --git a/main.c b/main.c
index 599a911..69d6ab7 100644 (file)
--- a/main.c
+++ b/main.c
@@ -66,6 +66,11 @@ int last_debug = 0;
 int debug_newline = 1;
 int nooutput = 0;
 
+void debug_usleep(int msec, char *file, int line, int hour, int min, int sec)
+{
+       usleep(msec);
+}
+
 void debug(const char *function, int line, char *prefix, char *buffer)
 {
        /* if we have a new debug count, we add a mark */
@@ -199,7 +204,6 @@ int main(int argc, char *argv[])
        double                  start_d;
 #endif
        int                     idletime = 0, idlecheck = 0;
-       char                    debug_log[128];
        char                    tracetext[256];
 
        /* current time */
@@ -287,22 +291,11 @@ int main(int argc, char *argv[])
        if (read_options() == 0)
                goto free;
 
-       /* initialize stuff of the NT lib */
-       if (options.deb & DEBUG_STACK)
-       {
-               global_debug = 0xffffffff & ~DBGM_MSG;
-//             global_debug = DBGM_L3DATA;
-       } else
-               global_debug = DBGM_MAN;
-       SPRINT(debug_log, "%s/debug.log", INSTALL_DATA);
-       if (options.deb & DEBUG_LOG)
-               debug_init(global_debug, debug_log, debug_log, debug_log);
-       else
-               debug_init(global_debug, NULL, NULL, NULL);
+       /* init mISDN */
+       if (mISDN_initialize() < 0)
+               goto free;
        created_debug = 1;
 
-       msg_init();
-
        /* read ruleset(s) */
        if (!(ruleset_first = ruleset_parse()))
                goto free;
@@ -475,10 +468,16 @@ int main(int argc, char *argv[])
                /* all loops must be counted from the beginning since nodes might get freed during handler */
                all_idle = 1;
 
+#warning debugging usleep crash
+               debug_usleep(1, __FILE__, __LINE__, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec);
+
                /* handle mISDN messages from kernel */
                debug_prefix = "ISDN";
                if (mISDN_handler())
                        all_idle = 0;
+#warning debugging usleep crash
+               debug_usleep(1, __FILE__, __LINE__, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec);
+
 #ifdef DEBUG_DURATION
                GET_NOW();
                isdn_duration += (now_d - start_d);
@@ -650,6 +649,8 @@ BUDETECT
                        all_idle = 0;
                }
 #endif
+#warning debugging usleep crash
+               debug_usleep(1, __FILE__, __LINE__, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec);
 
                /* do idle checking */
                if (idlecheck != now)
@@ -682,7 +683,7 @@ BUDETECT
                /* did we do nothing? so we wait to give time to other processes */
                if (all_idle)
                {
-                       usleep(4000); /* wait 32 samples */
+                       debug_usleep(4000, __FILE__, __LINE__, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec);
                        idletime += 4000;
                }
        }
@@ -782,9 +783,8 @@ free:
                if (pthread_mutex_destroy(&mutexd))
                        fprintf(stderr, "cannot destroy 'PDEBUG' mutex\n");
 
-       /* close debug */
-       if (created_debug)
-               debug_close();
+       /* deinitialize mISDN */
+       mISDN_deinitialize();
        global_debug = 0;
 
        /* display memory leak */