mirror of
https://github.com/outbackdingo/parodus.git
synced 2026-01-27 18:20:04 +00:00
Compare commits
24 Commits
6.0_p7xle_
...
trace_reve
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8957afc6bc | ||
|
|
118e8ee32f | ||
|
|
f7c9f483f9 | ||
|
|
502f56400e | ||
|
|
3e557ae4b0 | ||
|
|
0602fb243b | ||
|
|
1a7ae0b785 | ||
|
|
bc655cf9ba | ||
|
|
ad0491179d | ||
|
|
fa49a52a94 | ||
|
|
25baef78a8 | ||
|
|
9034ef9d10 | ||
|
|
9020089016 | ||
|
|
664690e6a6 | ||
|
|
4aed47b730 | ||
|
|
2f3f1424b4 | ||
|
|
91ae0e82e2 | ||
|
|
bfc2659bbb | ||
|
|
f9c2878cbf | ||
|
|
c84a1bdfad | ||
|
|
0b0ba77bd6 | ||
|
|
0b0309c3dd | ||
|
|
f4e358c179 | ||
|
|
0561c67e5c |
@@ -47,6 +47,7 @@ if (ENABLE_WEBCFGBIN)
|
||||
include_directories(${INCLUDE_DIR}/rbus)
|
||||
endif (ENABLE_WEBCFGBIN)
|
||||
|
||||
|
||||
# Get git commit hash
|
||||
#-------------------------------------------------------------------------------
|
||||
execute_process(
|
||||
@@ -63,9 +64,18 @@ add_definitions("-DGIT_COMMIT_TAG=\"${GIT_COMMIT_TAG}\"")
|
||||
add_definitions(-std=c99)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DNOPOLL_LOGGER ")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wno-missing-field-initializers")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall")
|
||||
if (DEVICE_CAMERA)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=all -Wno-missing-field-initializers")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=all")
|
||||
add_definitions(-DDEVICE_CAMERA)
|
||||
else ()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=all -Wno-missing-field-initializers")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=all")
|
||||
endif (DEVICE_CAMERA)
|
||||
|
||||
if (INCLUDE_BREAKPAD)
|
||||
add_definitions(-DINCLUDE_BREAKPAD)
|
||||
endif (INCLUDE_BREAKPAD)
|
||||
|
||||
# pthread external dependency
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
@@ -164,6 +164,7 @@ void timespec_diff(struct timespec *start, struct timespec *stop,
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
void subscribeRBUSevent();
|
||||
int regXmidtSendDataMethod();
|
||||
void registerRbusLogger();
|
||||
#endif
|
||||
#ifdef WAN_FAILOVER_SUPPORTED
|
||||
void setWebpaInterface(char *value);
|
||||
|
||||
@@ -223,8 +223,14 @@ void getAuthToken(ParodusCfg *cfg)
|
||||
* @param[in] nmemb size of delivered data
|
||||
* @param[out] data curl response data saved.
|
||||
*/
|
||||
#ifndef DEVICE_CAMERA
|
||||
size_t write_callback_fn(void *buffer, size_t size, size_t nmemb, struct token_data *data)
|
||||
{
|
||||
#else
|
||||
size_t write_callback_fn(void *buffer, size_t size, size_t nmemb, void *datain)
|
||||
{
|
||||
struct token_data *data = (struct token_data*) datain;
|
||||
#endif //DEVICE_CAMERA
|
||||
ParodusCfg *cfg;
|
||||
size_t max_data_size = sizeof (cfg->webpa_auth_token);
|
||||
size_t index = data->size;
|
||||
|
||||
@@ -47,7 +47,11 @@ struct token_data {
|
||||
|
||||
int requestNewAuthToken(char *newToken, size_t len, int r_count);
|
||||
void getAuthToken(ParodusCfg *cfg);
|
||||
#ifndef DEVICE_CAMERA
|
||||
size_t write_callback_fn(void *buffer, size_t size, size_t nmemb, struct token_data *data);
|
||||
#else
|
||||
size_t write_callback_fn(void *buffer, size_t size, size_t nmemb, void *data);
|
||||
#endif
|
||||
char* generate_trans_uuid();
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -99,7 +99,9 @@ void createSocketConnection(void (* initKeypress)())
|
||||
#endif
|
||||
|
||||
EventHandler();
|
||||
|
||||
#ifdef WAN_FAILOVER_SUPPORTED
|
||||
subscribeCurrentActiveInterfaceEvent();
|
||||
#endif
|
||||
set_server_list_null (&server_list);
|
||||
create_conn_rtn = createNopollConnection(ctx, &server_list);
|
||||
if(!create_conn_rtn)
|
||||
@@ -113,9 +115,6 @@ void createSocketConnection(void (* initKeypress)())
|
||||
UpStreamMsgQ = NULL;
|
||||
StartThread(handle_upstream, &upstream_tid);
|
||||
StartThread(processUpstreamMessage, &upstream_msg_tid);
|
||||
#ifdef WAN_FAILOVER_SUPPORTED
|
||||
subscribeCurrentActiveInterfaceEvent();
|
||||
#endif
|
||||
ParodusMsgQ = NULL;
|
||||
StartThread(messageHandlerTask, &downstream_tid);
|
||||
StartThread(serviceAliveTask, &svc_alive_tid);
|
||||
|
||||
@@ -783,8 +783,7 @@ int createNopollConnection(noPollCtx *ctx, server_list_t *server_list)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if(conn_ctx.current_server->allow_insecure <= 0)
|
||||
if(conn_ctx.current_server != NULL && conn_ctx.current_server->allow_insecure <= 0)
|
||||
{
|
||||
ParodusInfo("Connected to server over SSL\n");
|
||||
OnboardLog("Connected to server over SSL\n");
|
||||
|
||||
14
src/main.c
14
src/main.c
@@ -24,7 +24,11 @@
|
||||
#include "parodus_log.h"
|
||||
#include <curl/curl.h>
|
||||
#ifdef INCLUDE_BREAKPAD
|
||||
#ifndef DEVICE_CAMERA
|
||||
#include "breakpad_wrapper.h"
|
||||
#else
|
||||
#include "breakpadwrap.h"
|
||||
#endif //DEVICE_CAMERA
|
||||
#endif
|
||||
#include "signal.h"
|
||||
#include "privilege.h"
|
||||
@@ -87,8 +91,17 @@ int main( int argc, char **argv)
|
||||
signal(SIGHUP, sig_handler);
|
||||
signal(SIGALRM, sig_handler);
|
||||
#ifdef INCLUDE_BREAKPAD
|
||||
#ifndef DEVICE_CAMERA
|
||||
/* breakpad handles the signals SIGSEGV, SIGBUS, SIGFPE, and SIGILL */
|
||||
breakpad_ExceptionHandler();
|
||||
#else
|
||||
/* breakpad handles the signals SIGSEGV, SIGBUS, SIGFPE, and SIGILL */
|
||||
BreakPadWrapExceptionHandler eh;
|
||||
eh = newBreakPadWrapExceptionHandler();
|
||||
if(NULL != eh) {
|
||||
ParodusInfo("Breakpad Initialized\n");
|
||||
}
|
||||
#endif //DEVICE_CAMERA
|
||||
#else
|
||||
signal(SIGSEGV, sig_handler);
|
||||
signal(SIGBUS, sig_handler);
|
||||
@@ -107,6 +120,7 @@ int main( int argc, char **argv)
|
||||
ParodusInfo("********** Starting component: Parodus **********\n ");
|
||||
drop_root_privilege();
|
||||
#ifdef ENABLE_WEBCFGBIN
|
||||
registerRbusLogger();
|
||||
subscribeRBUSevent();
|
||||
regXmidtSendDataMethod();
|
||||
#endif
|
||||
|
||||
@@ -320,7 +320,7 @@ void *processUpstreamMessage()
|
||||
}
|
||||
else if(msgType == WRP_MSG_TYPE__EVENT)
|
||||
{
|
||||
ParodusInfo(" Received upstream event data: dest '%s'\n", msg->u.event.dest);
|
||||
ParodusInfo(" Received upstream event data: dest '%s'\n", msg->u.event.dest);
|
||||
partners_t *partnersList = NULL;
|
||||
int j = 0;
|
||||
|
||||
|
||||
@@ -47,6 +47,38 @@ rbusHandle_t get_parodus_rbus_Handle(void)
|
||||
{
|
||||
return rbus_Handle;
|
||||
}
|
||||
|
||||
/* Enables rbus ERROR level logs in parodus. Modify RBUS_LOG_ERROR check if more debug logs are needed from rbus. */
|
||||
void rbus_log_handler(
|
||||
rbusLogLevel level,
|
||||
const char* file,
|
||||
int line,
|
||||
int threadId,
|
||||
char* message)
|
||||
{
|
||||
ParodusPrint("threadId %d\n", threadId);
|
||||
const char* slevel = "";
|
||||
|
||||
if(level < RBUS_LOG_ERROR)
|
||||
return;
|
||||
|
||||
switch(level)
|
||||
{
|
||||
case RBUS_LOG_DEBUG: slevel = "DEBUG"; break;
|
||||
case RBUS_LOG_INFO: slevel = "INFO"; break;
|
||||
case RBUS_LOG_WARN: slevel = "WARN"; break;
|
||||
case RBUS_LOG_ERROR: slevel = "ERROR"; break;
|
||||
case RBUS_LOG_FATAL: slevel = "FATAL"; break;
|
||||
}
|
||||
ParodusInfo("%5s %s:%d -- %s\n", slevel, file, line, message);
|
||||
}
|
||||
|
||||
void registerRbusLogger()
|
||||
{
|
||||
rbus_registerLogHandler(rbus_log_handler);
|
||||
ParodusPrint("Registered rbus log handler\n");
|
||||
}
|
||||
|
||||
#ifdef WAN_FAILOVER_SUPPORTED
|
||||
void eventReceiveHandler( rbusHandle_t rbus_Handle, rbusEvent_t const* event, rbusEventSubscription_t* subscription );
|
||||
#endif
|
||||
@@ -73,7 +105,7 @@ void subscribeRBUSevent()
|
||||
int subscribeCurrentActiveInterfaceEvent()
|
||||
{
|
||||
int rc = RBUS_ERROR_SUCCESS;
|
||||
ParodusPrint("Subscribing to Device.X_RDK_WanManager.CurrentActiveInterface Event\n");
|
||||
ParodusInfo("Subscribing to Device.X_RDK_WanManager.CurrentActiveInterface Event\n");
|
||||
rc = rbusEvent_SubscribeAsync(rbus_Handle,WEBPA_INTERFACE,eventReceiveHandler,subscribeAsyncHandler,"parodusInterface",10*20);
|
||||
if(rc != RBUS_ERROR_SUCCESS)
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "config.h"
|
||||
#include "time.h"
|
||||
#include "heartBeat.h"
|
||||
#include "close_retry.h"
|
||||
|
||||
static pthread_t processThreadId = 0;
|
||||
static unsigned int XmidtQsize = 0;
|
||||
@@ -70,6 +71,22 @@ bool highQosValueCheck(int qos)
|
||||
return false;
|
||||
}
|
||||
|
||||
//To handle high priority low qos message to confirm send success and ignore cloud ack.
|
||||
bool higherPriorityLowQosCheck(int qos)
|
||||
{
|
||||
if(qos > 20 && qos < 25)
|
||||
{
|
||||
ParodusInfo("The low qos msg with higher priority\n");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusPrint("The qos is not higher priority low qos\n");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
XmidtMsg * get_global_xmidthead(void)
|
||||
{
|
||||
XmidtMsg *tmp = NULL;
|
||||
@@ -122,9 +139,9 @@ void decrement_XmidtQsize()
|
||||
int checkCloudConn()
|
||||
{
|
||||
int ret = 1;
|
||||
if (!cloud_status_is_online ())
|
||||
if (get_close_retry() || !cloud_status_is_online ())
|
||||
{
|
||||
ParodusInfo("cloud status is not online, wait till connection up\n");
|
||||
ParodusInfo("close_retry is in progress or cloud status is not online, wait till connection up\n");
|
||||
|
||||
int rv;
|
||||
struct timespec ts;
|
||||
@@ -214,8 +231,15 @@ int xmidtQOptmize()
|
||||
{
|
||||
if(get_XmidtQsize() > 0 && get_XmidtQsize() == get_parodus_cfg()->max_queue_size)
|
||||
{
|
||||
ParodusInfo("Max queue size reached, delete low qos %d transid %s\n", tempMsg->u.event.qos, tempMsg->u.event.transaction_uuid);
|
||||
del = 2;
|
||||
if(higherPriorityLowQosCheck(tempMsg->u.event.qos))
|
||||
{
|
||||
ParodusInfo("Skip max queue size delete for qos %d transid %s\n", tempMsg->u.event.qos, tempMsg->u.event.transaction_uuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusInfo("Max queue size reached, delete low qos %d transid %s\n", tempMsg->u.event.qos, tempMsg->u.event.transaction_uuid);
|
||||
del = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,10 +400,9 @@ void* processXmidtUpstreamMsg()
|
||||
{
|
||||
XmidtMsg *Data = xmidtQ;
|
||||
pthread_mutex_unlock (&xmidt_mut);
|
||||
ParodusPrint("mutex unlock in xmidt consumer thread\n");
|
||||
|
||||
checkMsgExpiry();
|
||||
checkMaxQandOptimize();
|
||||
ParodusPrint("mutex unlock in xmidt consumer\n");
|
||||
checkMsgExpiry(xmidtQ);
|
||||
checkMaxQandOptimize(xmidtQ);
|
||||
cv = 0;
|
||||
|
||||
ParodusPrint("check state\n");
|
||||
@@ -747,10 +770,9 @@ int sendXmidtEventToServer(XmidtMsg *msgnode, wrp_msg_t * msg, rbusMethodAsyncHa
|
||||
while(sendRetStatus) //If SendMessage is failed condition
|
||||
{
|
||||
ParodusError("sendXmidtEventToServer is Failed\n");
|
||||
if(highQosValueCheck(qos))
|
||||
if((highQosValueCheck(qos)) || (higherPriorityLowQosCheck(qos)))
|
||||
{
|
||||
ParodusPrint("The event is having high qos retry again\n");
|
||||
ParodusInfo("Wait till connection is Up\n");
|
||||
ParodusPrint("The event is having high qos retry again, wait till connection is Up\n");
|
||||
rv = checkCloudConn();
|
||||
if(rv == 2)
|
||||
{
|
||||
@@ -758,7 +780,7 @@ int sendXmidtEventToServer(XmidtMsg *msgnode, wrp_msg_t * msg, rbusMethodAsyncHa
|
||||
break;
|
||||
}
|
||||
ParodusInfo("Received cloud status signal proceed to retry\n");
|
||||
printSendMsgData("send to server after cloud reconnect", notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
|
||||
printSendMsgData("send to server after cloud reconnect", notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -798,13 +820,26 @@ int sendXmidtEventToServer(XmidtMsg *msgnode, wrp_msg_t * msg, rbusMethodAsyncHa
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusInfo("Low qos event, send success callback and delete\n");
|
||||
mapXmidtStatusToStatusMessage(DELIVERED_SUCCESS, &errorMsg);
|
||||
ParodusPrint("statusMsg is %s\n",errorMsg);
|
||||
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS, NULL, RBUS_ERROR_SUCCESS);
|
||||
//print_xmidMsg_list();
|
||||
updateXmidtState(msgnode, DELETE);
|
||||
print_xmidMsg_list();
|
||||
if(higherPriorityLowQosCheck(qos))
|
||||
{
|
||||
ParodusInfo("Higher priority low qos send success, ignore cloud ack\n");
|
||||
mapXmidtStatusToStatusMessage(DELIVERED_SUCCESS, &errorMsg);
|
||||
printSendMsgData(errorMsg, notif_wrp_msg->u.event.qos, notif_wrp_msg->u.event.dest, notif_wrp_msg->u.event.transaction_uuid);
|
||||
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS, NULL, RBUS_ERROR_SUCCESS);
|
||||
ParodusPrint("update state to DELETE\n");
|
||||
updateXmidtState(msgnode, DELETE);
|
||||
print_xmidMsg_list();
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusInfo("Low qos event, send success callback and delete\n");
|
||||
mapXmidtStatusToStatusMessage(DELIVERED_SUCCESS, &errorMsg);
|
||||
ParodusPrint("statusMsg is %s\n",errorMsg);
|
||||
createOutParamsandSendAck(msg, asyncHandle, errorMsg, DELIVERED_SUCCESS, NULL, RBUS_ERROR_SUCCESS);
|
||||
//print_xmidMsg_list();
|
||||
updateXmidtState(msgnode, DELETE);
|
||||
print_xmidMsg_list();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1533,16 +1568,16 @@ int deleteFromXmidtQ(XmidtMsg **next_node)
|
||||
}
|
||||
|
||||
//check if message is expired based on each qos and set to delete state.
|
||||
void checkMsgExpiry()
|
||||
void checkMsgExpiry(XmidtMsg *xmdMsg)
|
||||
{
|
||||
long long currTime = 0;
|
||||
struct timespec ts;
|
||||
char *errorMsg = NULL;
|
||||
|
||||
XmidtMsg *temp = NULL;
|
||||
temp = get_global_xmidthead();
|
||||
temp = xmdMsg;
|
||||
|
||||
while(temp != NULL)
|
||||
if(temp != NULL)
|
||||
{
|
||||
getCurrentTime(&ts);
|
||||
currTime= (long long)ts.tv_sec;
|
||||
@@ -1551,8 +1586,7 @@ void checkMsgExpiry()
|
||||
if(temp->state == DELETE)
|
||||
{
|
||||
ParodusPrint("msg is already in DELETE state and about to delete, skipping state update. transid %s\n", tempMsg->u.event.transaction_uuid);
|
||||
temp = temp->next;
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
if(tempMsg->u.event.qos > 74)
|
||||
@@ -1611,12 +1645,11 @@ void checkMsgExpiry()
|
||||
{
|
||||
ParodusError("Invalid qos\n");
|
||||
}
|
||||
temp = temp->next;
|
||||
}
|
||||
}
|
||||
|
||||
//To delete low qos messages from queue when max queue limit is reached.
|
||||
void checkMaxQandOptimize()
|
||||
void checkMaxQandOptimize(XmidtMsg *xmdMsg)
|
||||
{
|
||||
int qos = 0;
|
||||
|
||||
@@ -1627,28 +1660,35 @@ void checkMaxQandOptimize()
|
||||
|
||||
//Traverse through XmidtMsgQ list and set low qos msgs to DELETE
|
||||
XmidtMsg *temp = NULL;
|
||||
temp = get_global_xmidthead();
|
||||
temp = xmdMsg;
|
||||
|
||||
while(temp != NULL)
|
||||
{
|
||||
if (temp != NULL)
|
||||
{
|
||||
wrp_msg_t * tempMsg = temp->msg;
|
||||
qos = tempMsg->u.event.qos;
|
||||
ParodusPrint("qos is %d\n", qos);
|
||||
if(highQosValueCheck(qos))
|
||||
if((highQosValueCheck(qos)) || (higherPriorityLowQosCheck(qos)))
|
||||
{
|
||||
ParodusPrint("High qos msg, skip delete\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusInfo("Max Queue size reached. Low qos %d, set to DELETE state\n", qos);
|
||||
//rbus callback to caller
|
||||
char *errorMsg = NULL;
|
||||
mapXmidtStatusToStatusMessage(QUEUE_OPTIMIZED, &errorMsg);
|
||||
ParodusPrint("statusMsg is %s\n",errorMsg);
|
||||
createOutParamsandSendAck(temp->msg, temp->asyncHandle, errorMsg, QUEUE_OPTIMIZED, NULL, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
|
||||
updateXmidtState(temp, DELETE);
|
||||
//Skip max queue callback when msg is already in DELETE state.
|
||||
if( temp->state == DELETE)
|
||||
{
|
||||
ParodusInfo("Msg is in DELETE state, skipped Max Queue size callback %s\n", tempMsg->u.event.transaction_uuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
ParodusInfo("Max Queue size reached. Low qos %d, set to DELETE state\n", qos);
|
||||
//rbus callback to caller
|
||||
char *errorMsg = NULL;
|
||||
mapXmidtStatusToStatusMessage(QUEUE_OPTIMIZED, &errorMsg);
|
||||
ParodusPrint("statusMsg is %s\n",errorMsg);
|
||||
createOutParamsandSendAck(temp->msg, temp->asyncHandle, errorMsg, QUEUE_OPTIMIZED, NULL, RBUS_ERROR_INVALID_RESPONSE_FROM_DESTINATION);
|
||||
updateXmidtState(temp, DELETE);
|
||||
}
|
||||
}
|
||||
temp = temp->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ void print_xmidMsg_list();
|
||||
int deleteCloudACKNode(char* trans_id);
|
||||
int deleteFromXmidtQ(XmidtMsg **next_node);
|
||||
int checkCloudConn();
|
||||
void checkMaxQandOptimize();
|
||||
void checkMsgExpiry();
|
||||
void checkMaxQandOptimize(XmidtMsg *xmdMsg);
|
||||
void checkMsgExpiry(XmidtMsg *xmdMsg);
|
||||
void mapXmidtStatusToStatusMessage(int status, char **message);
|
||||
int xmidtQOptmize();
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user