message sending failed : Error[22 ] invalid argument .....but each and every argument
message sending failed : Error[22 ] invalid argument .....but each and every argument is correct.using posix standard system commands...
|
Way too terse. What are you doing (post exact commands) and in what environment?
|
PROBLEM : It is in PostToConfigMsgQueue()
Environment : Fedora core 4 ------------------------------------------Following is the code snippet---------------------- /* Message Queue User defined data structure */ typedef struct _MsgQData { ModuleId eModuleId; /**************Enum **************/ CommandId eCommandId;/**************Enum **************/ void *pMsg; } MsgQData; /***************************This is invoked by main module*********************/ int32 ConfigInit() { int32 iRetVal = SUCCESS; int32 iMsgflg = IPC_CREAT|0666; key_t key2; int8 *pchConfig = "Config Thread is called"; LogTraceMsg(CFG, "Entered into ConfigInit() function\n"); LogDebugMsg(CFG,"Initializing Config Module \n"); /********************* Creating Config Message queue ************************/ iMsgId2 = msgget(key2 , iMsgflg); if(-1 == iMsgId2) { LogErrorMsg (CFG,"Message queue creation of Config module failed\n"); iRetVal = FAILURE; LogTraceMsg(CFG, "Exiting from ConfigInit() function\n"); return iRetVal; } /*****************************Creating thread for Config module**********************/ iRetVal= pthread_create(&tid2 , NULL , ConfigThread , (void*)pchConfig ); if(0 != iRetVal) { LogErrorMsg (CFG,"thread creation of Config module failed\n"); iRetVal = FAILURE; LogTraceMsg(CFG, "Exiting from ConfigInit() function\n"); return iRetVal; } LogTraceMsg(CFG, "Exiting from ConfigInit() function\n"); return SUCCESS; }/* End of ConfigInit() */ /****************************************************************************** * Function Name : ConfigThread() * Return Values : NULL * Global variables : sCfgQData,iMsgId2 * Description : This function posts INIT_SUCCESS message to PSM * and also wait for messages at its own Msg Queue. ******************************************************************************/ void* ConfigThread(void *ptr) { MsgQData sCfgQData; int8 *pchMsg; pchMsg = (int8 *)ptr; LogTraceMsg(CFG, "Entered into ConfigThread() function\n"); printf(" %s \n\n",pchMsg); /*****************This posting works***********************************/ PostToPsmMsgQueue(CFG,INIT_SUCCESS,NULL); while(1) { msgrcv(iMsgId2,(void *)&sCfgQData,sizeof(MsgQData),0,MSG_NOERROR); if(UNINIT == sCfgQData.eCommandId) { LogDebugMsg(CFG," UNINIT received in the Config \n"); break; } }/* End of while(1) */ LogTraceMsg(CFG, "Exiting from ConfigThread() function\n"); ConfigUnInit(); return NULL; }/* End of void* ConfigThread(void *ptr) */ /****************************************************************************** * Function Name : PostToConfigMsgQueue() * Return Values : iRetVal * Global variables : sCfgMsgQData,iMsgId2 * Description : This function is Posting messages to CFG message queue. ******************************************************************************/ /******************************This is invoked by other module files******************/ int32 PostToConfigMsgQueue(IN ModuleId eSndModuleId, IN CommandId eSndCommandId, void* pSndMsg) { int32 iRetVal = SUCCESS; MsgQData sCfgMsgQData; sCfgMsgQData.eModuleId = eSndModuleId; sCfgMsgQData.eCommandId = eSndCommandId; //sCfgMsgQData.pMsg = pSndMsg; sCfgMsgQData.pMsg = NULL; LogTraceMsg(CFG, "Entered into PostToConfigMsgQueue() function\n"); /***********************Here this system call fails with saying invalid argument Error[22] ********************************************************************************************/ iRetVal = msgsnd(iMsgId2,(void *)&sCfgMsgQData,sizeof(MsgQData),MSG_NOERROR); if (-1 == iRetVal) { fprintf(stderr, "msgsnd failed in config with error:[%d],[%s]\n",errno,sys_errlist[errno]); exit(0); } iRetVal = SUCCESS; LogTraceMsg(CFG, "Exiting from PostToConfigMsgQueue() function\n"); return iRetVal; }/* End of PostToConfigMsgQueue() */ /****************************************************************************** * Function Name : ConfigUnInit() * Return Values : None * Global variables : iMsgId2 * Description : This function un-initializes Config module. ******************************************************************************/ void ConfigUnInit(void) { struct msqid_ds *pBuf; LogTraceMsg(CFG, "Entered into ConfigUnInit() function\n"); msgctl(iMsgId2,IPC_RMID,pBuf); LogTraceMsg(CFG, "Exiting from ConfigUnInit() function\n"); pthread_exit(NULL); return; }/* End of ConfigUnInit() */ |
All times are GMT -5. The time now is 08:27 AM. |