LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-11-2009, 07:05 AM   #1
yadavamitesh
LQ Newbie
 
Registered: May 2009
Location: Bathinda
Posts: 6

Rep: Reputation: 0
Question Multithreaded RPC server failed using TCP client (Redhat)


I had created multhreaded RPC server, it is working fine with UDP client but if i use TCP it fails in getting argument. what the reason and how can we resolve it.
Thanks in advance

Amitesh yadav
 
Old 05-11-2009, 10:01 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,322

Rep: Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470
Quote:
Originally Posted by yadavamitesh View Post
I had created multhreaded RPC server, it is working fine with UDP client but if i use TCP it fails in getting argument. what the reason and how can we resolve it.
Thanks in advance

Amitesh yadav
Maybe if you posted the actual error(s) you're getting, and said something about the version/distro of linux you're using, and what you're trying to do, we could help you.
 
Old 05-11-2009, 11:48 AM   #3
yadavamitesh
LQ Newbie
 
Registered: May 2009
Location: Bathinda
Posts: 6

Original Poster
Rep: Reputation: 0
using the redhat kernal release 2.4.21-4.ELsmp, version #1 SMP Fri Oct 3 17:52:56 EDT 2003

error i am getting :- can't decode the argument
error getting in function svc_getargs(transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)

_xdr_argument function pointer for unmarshalling the argument generate the error

i am creating the multithreaded RPC server accepting multiple argument for the function

i am getting the error when using TCP
in UPD it is working fine
i think thread is created before getting all the argument but why i dont know

Amitesh yadav

Last edited by yadavamitesh; 05-12-2009 at 05:54 AM.
 
Old 05-11-2009, 12:27 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,322

Rep: Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470
Quote:
Originally Posted by yadavamitesh View Post
using the redhat kernal release 2.4.21-4.ELsmp, version #1 SMP Fri Oct 3 17:52:56 EDT 2003

error i am getting :- can't decode the argument
error getting in function svc_getargs(transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)

_xdr_argument function pointer for unmarshalling the argument generate the error

i am creating the multithreaded RPC server accepting multiple argument for the function

i am getting the error when using TCP
in UPD it is working fine
i think thread is created before getting all the argument but why i dont know
Ok...but you still don't say WHAT PROGRAM is generating the error.

Also, did you look at your machine??? Your OS is ancient....it's possible you're trying to do something that very, VERY old kernel doesn't support.

What version of RedHat? And are you using RedHat enterprise?
 
Old 05-11-2009, 12:47 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Not knowing anything about your code or the implementation
details ... tcp maintains state, udp doesn't. Are you missing
state handling in your code, does one thread not know the
state of a connection a previous/different thread established?



Cheers,
Tink
 
Old 05-12-2009, 05:46 AM   #6
yadavamitesh
LQ Newbie
 
Registered: May 2009
Location: Bathinda
Posts: 6

Original Poster
Rep: Reputation: 0
Unhappy

Hi,

Let me re-phrase my question again...

I am creating a Multi-threaded RPC server on linux version ( Red Hat Enterprise Linux ES release 3 (Taroon), redhat kernal release 2.4.21-4.ELsmp, version #1 SMP Fri Oct 3 17:52:56 EDT 2003 ) where-in i am following the example as stated @ the url: http://www.linuxquestions.org/questi...riting-188816/

Upon each request, a new thread is created and we assign the
struct svc_req *rqstp & register SVCXPRT *transp parameters to the thread data.

The problems occurs when calling svc_getargs, most of the times it throws the error RPC:Server can't decode arguments to the client. Sporadically it does seems to work though.

From the client, we use TCP transport to connect to this RPC server and we transmit very less amount of data, less than 250 bytes. However the problem magically disappears when we use UDP as transport mechanism from the client.

On linux machine the rpcgen command we used to generate MT-safe code doesn't do much to the stubs generated, apart from changing result as an argument to the functions.

Can you please shed some light as to where i could be going wrong or is there any else i need to consider when writing the code.

Thanks
Amitesh yadav

Last edited by yadavamitesh; 05-12-2009 at 11:29 AM.
 
Old 05-12-2009, 12:31 PM   #7
yadavamitesh
LQ Newbie
 
Registered: May 2009
Location: Bathinda
Posts: 6

Original Poster
Rep: Reputation: 0
Hi,
Please advise me
Thanks
 
Old 05-12-2009, 12:39 PM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,322

Rep: Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470
Quote:
Originally Posted by yadavamitesh View Post
Hi,
Please advise me
Thanks
First, don't post follow-ups within a few hours, asking for help. We volunteer our time here, so trying to make us hurry up and answer you is very rude.

Second, I previously asked you a question, and gave you advice. Here it is again:

Quote:
Ok...but you still don't say WHAT PROGRAM is generating the error.

Also, did you look at your machine??? Your OS is ancient....it's possible you're trying to do something that very, VERY old kernel doesn't support.
You say you're creating this multithreaded RPC...WITH WHAT PROGRAM??? What are you issuing these commands with? If you wrote this program yourself, you're going to have to debug it yourself.

And my statement about your OS is still valid...your kernel is VERY old, and you could be trying to do something it can't do. Upgrade it.

Also, since you're using RedHat Enterprise, and you're in such a hurry for an answer, CALL THEM FOR SUPPORT...you're paying for it with your RHEL subscription.
 
Old 06-09-2009, 06:13 AM   #9
sheddy
LQ Newbie
 
Registered: Jun 2009
Distribution: ubuntu 10.10
Posts: 8

Rep: Reputation: 0
@yadavamitesh: did you find a solution for your problem?!
i try to find one for this problem, too! so i know your problem
please let me know, if you found a solution!!

a possible solution of me:

try to develop your own svc_run() method and then handle the requests. my problem is, that i get an error the svc_getreqset() or an segmentation fault in the svc_getreq_common() method when i start the thread! i don't know how to solve this.

Last edited by sheddy; 06-09-2009 at 06:18 AM.
 
Old 06-11-2009, 11:38 AM   #10
yadavamitesh
LQ Newbie
 
Registered: May 2009
Location: Bathinda
Posts: 6

Original Poster
Rep: Reputation: 0
@sheddy: First of all thanks for reply. I was beginning to wonder i was the only one stuck with this issue here

Coming to the problem we both are facing,
I did some more snooping by monitoring the network activity using "tcpdump" and found that on high number of requests both TCP/UDP fails.

The problem it seems is the RPC library in "libnsl" is itself not thread-safe and hence you are right we need to implement our own svc_run and all the corresponding services associated with making it thread safe.
I found an excellent place where i found this implementation of svc_run by solaris @
http://src.opensolaris.org/source/xr.../rpc/svc_run.c
& other files @
http://src.opensolaris.org/source/xr...ib/libnsl/rpc/

However, by the looks of it, seems lot of work
I am trying to find if i can upgrade to a new version of library/OS -or- as last resort "yes" implement my own svc_run. But looks like libnsl is part of glibc and we need to upgrade the whole thing !!!

Please correct me if my understanding is wrong in this regard!
Any insights would be helpful.

Thanks.
 
Old 06-12-2009, 04:30 AM   #11
sheddy
LQ Newbie
 
Registered: Jun 2009
Distribution: ubuntu 10.10
Posts: 8

Rep: Reputation: 0
hey,

the problem is that our libtirpc is too old and have no multithreading support like suns library
(http://docs.sun.com/app/docs/doc/816-1435 see at Chapter 7)


I try to implement my own svc_run and it works - but only in single threaded environment.

You can test it and it will work with UDP and TCP:

Code:
void runSrv()
{
	fd_set readSet;
	struct timeval tval;

	extern int errno;
	int size = getdtablesize();

	while(1){
		tval.tv_sec = 5; 
		tval.tv_usec = 0;
		readSet = svc_fdset; 

		switch (select(size + 1, &readSet, (fd_set*) NULL, (fd_set*) NULL,	(struct timeval*) &tval)) {
		case -1: // error
			if (errno == EINTR)
				continue;		
			perror("select fehlgeschlagen\n");
			return;
		case 0: // timeout
			continue;
		default: {
			svc_getreqset(&readSet);			

		}
		}
	}// while(1)
}

svc_getreqset() calls the remote procedure. So the idea is to put the function into a thread.
But as soon as i call the svc_getreqset() function in a thread, i get a segmentation fault in svc_getreq_common(), which will be called after svc_getreqset().

So if you search for the function, you will find the information that svc_getreqset() is NOT thread-safe. Even if you try to protect getreqset() with mutexes, it won't work.

Maybe i overlooked something and you will find it.

Please post your solution, if you you found one.

Best regards,
Sdy
 
  


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
Multithreaded RPC Servers for Linux.Thread-safe code writing dba477 Red Hat 1 08-25-2010 01:33 AM
problems in multithreaded send()/recv() using tcp socket arslanali Programming 2 05-26-2007 10:00 AM
Multithreaded TCP Client examples daveseff Programming 1 04-01-2005 12:29 AM
DB2 Client Library on Redhat ES 3 - multithreaded by default ? colmmagoo Linux - Software 0 09-09-2004 09:47 PM
tcp/ip multithreaded server stops accepting connection debjyotidas Linux - Networking 2 07-23-2004 01:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:39 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration