/** * Processes an incoming message. * This actually just puts the message into a message queue. One worker will pick-it-up * and do the actual processing. * \note Must be called with a lock on the peer. * @param p - peer received from * @param msg - the message received */ void Rcv_Process(peer *p, AAAMessage *msg) { LOG(L_DBG,"DBG:Rcv_Process(): Received a message\n"); if (!put_task(p,msg)){ LOG(L_ERR,"ERROR:Rcv_Process(): Queue refused task\n"); AAAFreeMessage(&msg); } LOG(L_DBG,"DBG:Rcv_Process(): task added to queue\n"); // AAAPrintMessage(msg); }
void inline put_task_simple(dispatcher_t* d, int priority, fd_callback *cb, void* cb_param) { heap_node_t task; task.last_reactor = NULL; task.fd = -1; task.flags = 0; task.priority = priority; task.cb = (fd_callback*) cb; task.cb_param = (void*) cb_param; put_task(d, task); }
static inline void resume_pending_writes(struct tcp_conn *conn) { struct tcp_pending_writes *pw; struct tcp_pending_writes *pw_next; heap_node_t task; for(pw=conn->write.first ; pw ; pw=pw_next ) { pw_next = pw->next; /* create a new task to resume exec with failure notice */ task.fd = conn->socket; task.flags = 0; task.priority = TASK_PRIO_RESUME_EXEC; task.cb = (fd_callback*)resume_write_on_failue; task.cb_param = (void*)pw->ctx; put_task( reactor_out->disp, task); } }
/** * Processes an incoming message. * This actually just puts the message into a message queue. One worker will pick-it-up * and do the actual processing. * \note Must be called with a lock on the peer. * @param p - peer received from * @param msg - the message received */ void Rcv_Process(peer *p, AAAMessage *msg) { AAASession *session=0; int nput=0; if (msg->sessionId) session = cdp_get_session(msg->sessionId->data); if (session){ switch (session->type){ case AUTH_CLIENT_STATEFULL: if (is_req(msg)){ if (msg->commandCode==IMS_ASR) auth_client_statefull_sm_process(session,AUTH_EV_RECV_ASR,msg); else auth_client_statefull_sm_process(session,AUTH_EV_RECV_REQ,msg); session = 0; }else { if (msg->commandCode==IMS_STA) nput=auth_client_statefull_sm_process(session,AUTH_EV_RECV_STA,msg); else auth_client_statefull_sm_process(session,AUTH_EV_RECV_ANS,msg); session = 0; } break; case AUTH_SERVER_STATEFULL: if (is_req(msg)) { if (msg->commandCode==IMS_STR) { auth_server_statefull_sm_process(session,AUTH_EV_RECV_STR,msg); } else { auth_server_statefull_sm_process(session,AUTH_EV_RECV_REQ,msg); } session = 0; }else{ if (msg->commandCode==IMS_ASA) auth_server_statefull_sm_process(session,AUTH_EV_RECV_ASA,msg); else auth_server_statefull_sm_process(session,AUTH_EV_RECV_ANS,msg); session = 0; } break; default: AAASessionsUnlock(session->hash); session =0; break; } }else{ if (msg->sessionId){ if (msg->commandCode == IMS_ASR) auth_client_statefull_sm_process(0,AUTH_EV_RECV_ASR,msg); } } if (!nput && !put_task(p,msg)){ LM_ERR("Rcv_Process(): Queue refused task\n"); if (msg) AAAFreeMessage(&msg); } //if (msg) LM_ERR("Rcv_Process(): task added to queue command %d, flags %#1x endtoend %u hopbyhop %u\n",msg->commandCode,msg->flags,msg->endtoendId,msg->hopbyhopId); // AAAPrintMessage(msg); }
/** * Processes an incoming message. * This actually just puts the message into a message queue. One worker will pick-it-up * and do the actual processing. * \note Must be called with a lock on the peer. * @param p - peer received from * @param msg - the message received */ void Rcv_Process(peer *p, AAAMessage *msg) { AAASession *session=0; int nput=0; if (msg->sessionId) session = cdp_get_session(msg->sessionId->data); if (session){ switch (session->type){ case ACCT_CC_CLIENT: if (is_req(msg)){ LM_WARN("unhandled receive request on Credit Control Acct session\n"); AAASessionsUnlock(session->hash); //must be called because we dont call state machine here session = 0; //we dont call SM here so we mustnt set to 0 } else { cc_acc_client_stateful_sm_process(session, ACC_CC_EV_RECV_ANS, msg); session = 0; } break; case AUTH_CLIENT_STATEFULL: if (is_req(msg)){ if (msg->commandCode==IMS_ASR) auth_client_statefull_sm_process(session,AUTH_EV_RECV_ASR,msg); else auth_client_statefull_sm_process(session,AUTH_EV_RECV_REQ,msg); session = 0; }else { if (msg->commandCode==IMS_STA) nput=auth_client_statefull_sm_process(session,AUTH_EV_RECV_STA,msg); else auth_client_statefull_sm_process(session,AUTH_EV_RECV_ANS,msg); session = 0; } break; case AUTH_SERVER_STATEFULL: if (is_req(msg)) { if (msg->commandCode==IMS_STR) { auth_server_statefull_sm_process(session,AUTH_EV_RECV_STR,msg); } else { auth_server_statefull_sm_process(session,AUTH_EV_RECV_REQ,msg); } session = 0; }else{ if (msg->commandCode==IMS_ASA) auth_server_statefull_sm_process(session,AUTH_EV_RECV_ASA,msg); else auth_server_statefull_sm_process(session,AUTH_EV_RECV_ANS,msg); session = 0; } break; default: AAASessionsUnlock(session->hash); session =0; break; } }else{ if (msg->sessionId){ if (msg->commandCode == IMS_ASR) auth_client_statefull_sm_process(0,AUTH_EV_RECV_ASR,msg); } } if (!nput && !put_task(p,msg)){ LM_ERR("Rcv_Process(): Queue refused task\n"); if (msg) AAAFreeMessage(&msg); } //if (msg) LM_ERR("Rcv_Process(): task added to queue command %d, flags %#1x endtoend %u hopbyhop %u\n",msg->commandCode,msg->flags,msg->endtoendId,msg->hopbyhopId); // AAAPrintMessage(msg); }
/** * Processes an incoming message. * This actually just puts the message into a message queue. One worker will pick-it-up * and do the actual processing. * \note Must be called with a lock on the peer. * @param p - peer received from * @param msg - the message received */ void Rcv_Process(peer *p, AAAMessage *msg) { AAASession *session=0; unsigned int hash; // we need this here because after the sm_processing , we might end up // with no session any more if (msg->sessionId) session = get_session(msg->sessionId->data); if (session){ hash=session->hash; switch (session->type){ case AUTH_CLIENT_STATEFULL: if (is_req(msg)){ if (msg->commandCode==IMS_ASR) auth_client_statefull_sm_process(session,AUTH_EV_RECV_ASR,msg); else auth_client_statefull_sm_process(session,AUTH_EV_RECV_REQ,msg); }else { if (msg->commandCode==IMS_STA) auth_client_statefull_sm_process(session,AUTH_EV_RECV_STA,msg); else auth_client_statefull_sm_process(session,AUTH_EV_RECV_ANS,msg); } break; case AUTH_SERVER_STATEFULL: if (is_req(msg)) { auth_server_statefull_sm_process(session,AUTH_EV_RECV_REQ,msg); }else{ if (msg->commandCode==IMS_ASA) auth_server_statefull_sm_process(session,AUTH_EV_RECV_ASA,msg); else auth_server_statefull_sm_process(session,AUTH_EV_RECV_ANS,msg); } break; default: break; } sessions_unlock(hash); }else{ if (msg->sessionId){ if (msg->commandCode == IMS_ASR) auth_client_statefull_sm_process(0,AUTH_EV_RECV_ASR,msg); if (msg->commandCode == IMS_AAR) { session=AAACreateAuthSession(0,0,1,0,0); shm_str_dup(session->id,msg->sessionId->data); auth_server_statefull_sm_process(0,AUTH_EV_RECV_REQ,msg); } // Any other cases to think about? } } if (!put_task(p,msg)){ LOG(L_ERR,"ERROR:Rcv_Process(): Queue refused task\n"); AAAFreeMessage(&msg); } LOG(L_DBG,"DBG:Rcv_Process(): task added to queue\n"); // AAAPrintMessage(msg); }
int input_task() { int num = 0; // printf ("-->input task <globaltime:%d>\n", global_time); if (previous != NULL) { if (previous->starttime <= global_time) { num++; put_task(previous); printf (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Time%3d ADD [id:%3d] [%3d~%3d]", global_time, previous->task_id, previous->starttime, previous->deadline); switch (previous->type) { case 2: printf (" HRT\n"); break; case 1: printf (" SRT\n"); break; case 0: printf (" NML\n"); break; } previous = NULL; } else { return num; } } struct task_struct* input_task; int type, starttime, deadline, runtime; while (true) { input_task = (struct task_struct*) malloc (sizeof (struct task_struct)); if (scanf ("type:%d starttime:%d deadline:%d runtime:%d\n", &type, &starttime, &deadline, &runtime) == EOF) { // printf ("\n"); return -1; } input_task->task_id = taskid++; input_task->type = type; input_task->starttime = starttime; input_task->deadline = deadline; input_task->runtime = runtime; switch (input_task->type) { case 0: nml++; break; case 1: sfrt++; break; case 2: hdrt++; break; } if (global_time >= input_task->starttime) { num++; put_task(input_task); printf (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Time%3d ADD [id:%3d] [%3d~%3d]", global_time, input_task->task_id, input_task->starttime, input_task->deadline); switch (input_task->type) { case 2: printf (" HRT\n"); break; case 1: printf (" SRT\n"); break; case 0: printf (" NML\n"); break; } } else { previous = input_task; return num; } } printf ("\n"); return num; }