-#ifdef DEBUG_DURATION
- GET_NOW();
- call_duration += (now_d - start_d);
- start_d = now_d;
-#endif
-
- debug_prefix = 0;
-
- /* process any message */
- debug_count++;
- debug_prefix = "message";
- while ((message = message_get()))
- {
- all_idle = 0;
- switch(message->flow)
- {
- case PORT_TO_EPOINT:
- debug_prefix = "msg port->epoint";
- epoint = find_epoint_id(message->id_to);
- if (epoint)
- {
- if (epoint->ep_app)
- {
- epoint->ep_app->ea_message_port(message->id_from, message->type, &message->param);
- } else
- {
- PDEBUG(DEBUG_MSG, "Warning: message %s from port %d to endpoint %d. endpoint doesn't have an application.\n", messages_txt[message->type], message->id_from, message->id_to);
- }
- } else
- {
- PDEBUG(DEBUG_MSG, "Warning: message %s from port %d to endpoint %d. endpoint doesn't exist anymore.\n", messages_txt[message->type], message->id_from, message->id_to);
- }
- break;
-
- case EPOINT_TO_CALL:
- debug_prefix = "msg epoint->call";
- call = find_call_id(message->id_to);
- if (call)
- {
- call->message_epoint(message->id_from, message->type, &message->param);
- } else
- {
- PDEBUG(DEBUG_MSG, "Warning: message %s from endpoint %d to call %d. call doesn't exist anymore\n", messages_txt[message->type], message->id_from, message->id_to);
- }
- break;
-
- case CALL_TO_EPOINT:
- debug_prefix = "msg call->epoint";
- epoint = find_epoint_id(message->id_to);
- if (epoint)
- {
- if (epoint->ep_app)
- {
- epoint->ep_app->ea_message_call(message->id_from, message->type, &message->param);
- } else
- {
- PDEBUG(DEBUG_MSG, "Warning: message %s from call %d to endpoint %d. endpoint doesn't have an application.\n", messages_txt[message->type], message->id_from, message->id_to);
- }
- } else
- {
- PDEBUG(DEBUG_MSG, "Warning: message %s from call %d to endpoint %d. endpoint doesn't exist anymore.\n", messages_txt[message->type], message->id_from, message->id_to);
- }
- break;
-
- case EPOINT_TO_PORT:
- debug_prefix = "msg epoint->port";
- port = find_port_id(message->id_to);
- if (port)
- {
- port->message_epoint(message->id_from, message->type, &message->param);
-BUDETECT
- } else
- {
- PDEBUG(DEBUG_MSG, "Warning: message %s from endpoint %d to port %d. port doesn't exist anymore\n", messages_txt[message->type], message->id_from, message->id_to);
- }
- break;
-
- default:
- PERROR("Message flow %d unknown.\n", message->flow);
- }
- message_free(message);
- debug_count++;
- debug_prefix = "message";
- }
-#ifdef DEBUG_DURATION
- GET_NOW();
- message_duration += (now_d - start_d);
- start_d = now_d;
-#endif
-BUDETECT
-
- /* handle socket */
- if (admin_handle())
- all_idle = 0;
-#ifdef DEBUG_DURATION
- GET_NOW();
- admin_duration += (now_d - start_d);
- start_d = now_d;
-#endif
-BUDETECT
-
-#if 0
- /* check for child to exit (eliminate zombies) */
- if (waitpid(-1, NULL, WNOHANG) > 0)
- {
- PDEBUG(DEBUG_EPOINT, "a child process (created by endpoint) has exitted.\n");
- all_idle = 0;
- }
-#endif
-
- /* do idle checking */
- if (idlecheck != now)
- {
- PDEBUG(DEBUG_IDLETIME, "Idle time : %d%%\n", idletime/10000);
- idletime = 0;
- idlecheck = now;
- }
-#ifdef DEBUG_DURATION
- GET_NOW();
- idle_duration += (now_d - start_d);
- start_d = now_d;
- if (durationupdate != now)
- {
- durationupdate = now;
- printf("Idle:%3d ISDN:%3d Port:%3d Epoint:%3d Call:%3d Message:%3d Admin:%3d\n",
- (int)(idle_duration*100),
- (int)(isdn_duration*100),
- (int)(port_duration*100),
- (int)(epoint_duration*100),
- (int)(call_duration*100),
- (int)(message_duration*100),
- (int)(admin_duration*100));
- idle_duration = isdn_duration = port_duration = epoint_duration = call_duration = message_duration = admin_duration = 0;