LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-07-2008, 07:47 AM   #1
rakeshranjanjha
LQ Newbie
 
Registered: Jan 2008
Posts: 2

Rep: Reputation: 0
Question 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...

Last edited by rakeshranjanjha; 01-07-2008 at 07:48 AM.
 
Old 01-07-2008, 08:07 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Way too terse. What are you doing (post exact commands) and in what environment?
 
Old 01-07-2008, 11:22 PM   #3
rakeshranjanjha
LQ Newbie
 
Registered: Jan 2008
Posts: 2

Original Poster
Rep: Reputation: 0
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() */

Last edited by rakeshranjanjha; 01-08-2008 at 12:39 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware 12.0 fdisk: Re-reading the partition failed Error 22: Invalid Argument Rayburn96 Linux - Software 1 08-02-2007 01:01 AM
cryptsetup error (Command failed: Invalid argument) SlackN00b Slackware 5 02-07-2007 12:59 PM
HDIO_GET_MULTCOUNT failed: Invalid argument yashwantpinge Linux - Hardware 1 06-02-2006 09:36 AM
xinetd error message on Suse 9.1: service xxx, accept: Invalid argument (errno = 22) alteraffe Linux - Networking 1 02-15-2006 04:44 PM
Mount Failed: Invalid Argument BoboBrazil Linux - Software 4 07-13-2003 12:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration