Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
sapthagiri
Earned a small fee
Earned a small fee
Posts: 23
Joined: Mon Jan 09, 2017 12:36 pm

Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

Post by sapthagiri »

Hi team,
Hi Team,

Recently we moved out application from wx3.0 to wx3.1.
After merging wxWidgets 3.1 changes to our application, we are able to launch application, but after starting the application we observed that application is freezed for 2-3 minutes where it is trying to read socket data from the configuration server. Here we are observing wxSOCKET_IOERR.

Please find the code snippet for your reference.

Code: Select all

/*Structure describes the format of the after encoding "SocketMessage". 
The byte array to be sent through the socket*/
typedef struct dataPacket
{
	u8*	pucData;		/*byte array*/
	u32	uiSize;		/*Size of the byte array*/
}SockData;

E_RETURNCODES ConfigClient::getAll(void)
{
	wxSocketClient* m_pGetSetSocket;
	u8 *pucSockData = NULL;
	SocketMessage	stMsg;
	SockData stSocketData;
	wxIPV4address stAddr;

	if(false == stAddr.Hostname(wxT("localhost")))
	{
		m_pLogFile->logMessage(__FILE__,__LINE__,wxT("configClient:: Not able to set the address for port %d"), iPort);
	}		
	if( false == stAddr.Service(iPort))
	{
		m_pLogFile->logMessage(__FILE__,__LINE__,wxT("configClient:: Not able to set the service for port %d"), iPort);
	}
	if (NULL == m_pGetSetSocket)
	{
		/* Create the socket*/
		m_pGetSetSocket =  new wxSocketClient(wxSOCKET_BLOCK | wxSOCKET_WAITALL);
		if (NULL == m_pGetSetSocket)
		{
			logMessage(__FILE__,__LINE__,wxT("configClient:: Not able to create a new client socket due to insufficient memory"));
			return E_RET_ERROR;
		}
		m_pGetSetSocket->Connect(stAddr,true); // connection is successful
		if(m_pGetSetSocket->IsConnected() == TRUE) 
		{
			// returning TRUE
		}
		// we are writing GET_ALL_REQ to the server to read all the configuration parameters from the server.
		m_pGetSetSocket->WriteMsg(stSocketData.pucData, stSocketData.uiSize); 
		// we checked socket error status & it is returning 0, hence socket write is passing successfully.
		if(m_pGetSetSocket->Error() == true)
		{
			logMessage(__FILE__,__LINE__,wxT("configClient::getAll().Socket Error while sending CONFIG_MSG_GET_ALL_REQ request"));
			return E_RET_ERROR;
		}
		 delete []stSocketData.pucData;		 
		 // next we are trying to read data
		{
			pucSockData = new u8[MAX_LEN];
			if (NULL != pucSockData)
			{
				// its failing in below function & it takes 2-3 minutes for reading data & later returns wxSOCKET_IOERR
				m_pGetSetSocket->ReadMsg(pucSockData, MAX_LEN);				
				if(m_pGetSetSocket->Error() == true)
				{
					m_pLogFile->logMessage(__FILE__,__LINE__,wxT("configClient::getAll().Socket Error while reading"));
					delete []pucSockData;
					return E_RET_ERROR;
				}
		   }
		}
	}
}
Also we are not setting any socket flags (wxSOCKET_BLOCK | wxSOCKET_WAITALL) before reading or writing on socket.

We observed that WriteMsg() is returning wxSOCKET_NOERROR, but ReadMsg() is taking 2-3 minutes time to execute & then returns wxSOCKET_IOERR.
Kindly tell us if we are doing anything wrong and let us know how to reach out the root cause for wxSOCKET_IOERR.
Please provide any debug pointers for the above case.

Regards,
Giri
Last edited by doublemax on Mon Apr 10, 2017 8:50 am, edited 1 time in total.
Reason: added code tags
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

Post by doublemax »

Recently we moved out application from wx3.0 to wx3.1.
Which version exactly? The latest version from GIT or the 3.1 package from the wxWidgets downloads page?
Use the source, Luke!
sapthagiri
Earned a small fee
Earned a small fee
Posts: 23
Joined: Mon Jan 09, 2017 12:36 pm

Re: Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

Post by sapthagiri »

Hi,

We have downloaded the 3.1 package from the wxWidgets downloads page.
OS : Linux Debian 7.4(wheezy) 32-bit & also Linux Ubuntu(14.04) LTS 32-bit (both we tried).

Regards,
Giri
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

Post by ONEEYEMAN »

Hi,
And you compiled against GTK+2 or GTK+3?

Thank you.
Ruro
Experienced Solver
Experienced Solver
Posts: 83
Joined: Wed May 23, 2007 2:20 pm
Location: Verona, Italy

Re: Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

Post by Ruro »

Hi,

looking at the docs:


http://docs.wxwidgets.org/3.0/classwx_s ... 107d430bf6
If the buffer passed to the function isn't big enough, the remaining bytes will be discarded. This function always waits for the buffer to be entirely filled, unless an error occurs.

AND:

Remarks
ReadMsg() will behave as if the wxSOCKET_WAITALL flag was always set and it will always ignore the wxSOCKET_NOWAIT flag.
The function should wait until the buffer is full, is the MAX_LEN a value for a single message, or has a size for more than one message?

Sorry if i misunderstood the question,

Best Regards,

Nicola.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

Post by doublemax »

We have downloaded the 3.1 package from the wxWidgets downloads page.
First check if the problem also occurs with the latest version from GIT.

But unless someone has an idea, which change between 3.0.2 and 3.1.x is responsible for the different behavior, i'm afraid your best chance to find the issue is to do a GIT bisect. However, as it always take 2-3 minutes until the problem occurs, it might take a painfully long time to get to the root of the problem.
Use the source, Luke!
sapthagiri
Earned a small fee
Earned a small fee
Posts: 23
Joined: Mon Jan 09, 2017 12:36 pm

Re: Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

Post by sapthagiri »

Hi team,
Thanks for your inputs.

We have compiled wxWidgets with GTK+2.
We are passing 1024 bytes as buffer length to ReadMsg(). Same function was working fine in wxWidgets 3.0.
We are not setting any socket flags before Socket WriteMsg() or ReadMsg() functions.

Regards,
Giri
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

Post by ONEEYEMAN »

Hi,
Did you try with the sample? Did you profile the code?

Thank you.
sapthagiri
Earned a small fee
Earned a small fee
Posts: 23
Joined: Mon Jan 09, 2017 12:36 pm

Re: Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

Post by sapthagiri »

Hi
I will run the socket demo sample & see if same behavior is seen.

Regards,
Giri
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

Post by ONEEYEMAN »

Hi,
Please choose one channel for the help - either post to the forum or to the ML.
Cross-posting will not help - you might get different responses and be confused even more.

It also wastes time of the people trying to help you as only number of people might go to both channels - it probably not the case for wxWidgets but might be for other software.

So bottom line is - choose one channel where you will go for help and stick with it.

Thank you.
sapthagiri
Earned a small fee
Earned a small fee
Posts: 23
Joined: Mon Jan 09, 2017 12:36 pm

Re: Application freezes for 2-3 minutes after updating wxWidgets 3.0 to wxWidgets 3.1

Post by sapthagiri »

Hi Team,
Thanks for your inputs.
I will consider this & henceforth will not post same in multiple forums.
Thanks once again.

Regards,
giri
Post Reply