Mail Archives: cygwin/2004/06/25/05:38:11
------=_NextPart_000_0010_01C45ACA.411734B0
Content-Type: text/plain;
charset="koi8-r"
Content-Transfer-Encoding: 7bit
Dear forum users!
I have attached to the message an example of code that uses rpc and I think
it points to some bug in cygwin rpc library.
Add info:
1. 0x2A000001 is the first number in a range of numbers for rpc programs for
free use.
2. When probe executed with ANY parameter, it switches to svc_run.
3. When probe executed without any parameters, it switches to code taken
from "Power programming with RPC" by John Bloomer. (In rpcunix documentation
the equivalent code is given as an implementation for svc_run).
I checked this code under Fedora and it works, but under cygwin:
1. svc_unregister does'nt unregister old rpc program, so it is imposible to
run it twice.
2. select (...) fails.
P. S. sizeof ( svc_fdset ) == 8. In my last message I just wrote wrong.
Lev.
----- Original Message -----
From: "Lev Pliner" <pliner AT sky DOT ru>
To: <cygwin AT cygwin DOT com>
Sent: Friday, June 18, 2004 3:41 PM
Subject: Question about select function
> Dear forum members!
>
> I'm writing a multithreaded rpc program. The following is a part of my
> program that causes a error:
>
> fd_set readfds;
> int size = getdtablesize ( );
>
> while ( 1 )
> {
> readfds = svc_fdset;
>
> switch ( select ( size, &readfds, NULL, NULL, NULL ) )
> {
> case -1:
> if ( errno == EINTR )
> continue;
> else ...
> break;
> case 0:
> continue;
> break;
> };
> };
>
> "select" call here causes the following error: "Bad file descriptor". This
> example was taken from "Power programming with RPC" by John Bloomer.
>
> I tried to understand what svc_fdset consits of:
> sizeof ( svc_fdset ) == 2
>
> Thus fd_set.fd_bits array has two elements:
> sprintf ( "%ld %ld\n", svc_fdset.fds_bits [ 0 ], svc_fdset.fds_bits [
1 ] )
> == "8 0"
>
> But somehow:
> for (i=0;i<64;i++) FD_SET (i, svc_fdset) == 1
>
> Could anyone tell me how to solve this problem?
>
> Lev.
>
------=_NextPart_000_0010_01C45ACA.411734B0
Content-Type: application/octet-stream;
name="probe.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="probe.c"
#include <stdio.h>
#include <sys/errno.h>
#include <rpc/rpc.h>
void
probe ( rqstp, transp )
struct svc_req *rqstp;
SVCXPRT *transp;
{
switch ( rqstp->rq_proc )
{
case NULLPROC:
svc_sendreply ( transp, xdr_void, (void *)NULL );
return;
default:
svcerr_noproc ( transp );
return;
};
};
int
main ( argc, argv )
int argc;
char *argv[];
{
SVCXPRT *transp = NULL;
fd_set readfds;
int size = getdtablesize ( );
if ( ( transp = svctcp_create ( RPC_ANYSOCK, 0, 0 ) ) == NULL )
{
perror ( "1" );
exit ( 1 );
};
svc_unregister ( 0x2A000001, 1 );
if ( !svc_register ( transp, 0x2A000001, 1, probe, IPPROTO_TCP ) )
{
perror ( "2" );
exit ( 1 );
};
if ( argc > 1 ) while ( 1 )
{
readfds = svc_fdset;
switch ( select ( size, &readfds, NULL, NULL, NULL ) )
{
case -1:
if ( errno == EINTR )
continue;
else
{
perror ( "3" );
exit ( 1 );
};
break;
case 0:
continue;
break;
default:
if ( !bcmp ( &readfds, &svc_fdset, sizeof ( fd_set ) ) )
continue;
svc_getreqset ( transp );
break;
};
}
else
svc_run ( );
exit ( 0 );
};
------=_NextPart_000_0010_01C45ACA.411734B0
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
------=_NextPart_000_0010_01C45ACA.411734B0--
- Raw text -