This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Threading bug in sunrpc/auth_none.c


On Fri, Apr 12, 2002 at 12:58:11PM -0700, H . J . Lu wrote:
> > It works under Solaris, and I have some real software here that
> > expects it to work.
> 
> Why do you think I made that patch?

Y'wanna point me at your patch?

> > I would not be surprised if there were more threading bugs in the
> > sunrpc directory -- for instance, while developing that test program I
> > discovered that (clnt|svc)raw_create were completely broken by the
> > thread changes.  As in "this code cannot possibly work anymore, even
> > single-threaded."
> 
> A testcase?

Appended.  It's just the same program using raw transport instead of
udp, but it crashes in svcraw_create().  I was going to send a patch
for that one as soon as the first patch got applied.

> I am not 100% sure if it is complete for sharing RPC handles among
> threads in all cases.

Incremental improvements, dude.

zw

#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <rpc/rpc.h>

#define PROGNUM 1234
#define VERSNUM 1
#define PROCNUM 1

void
dispatch(struct svc_req *request, SVCXPRT *xprt)
{
    char dummy;

    fprintf(stderr, "dispatch %d\n", request->rq_proc);

    svc_sendreply(xprt, xdr_void, &dummy);
}

void
test_one_call(CLIENT *c)
{
    struct timeval tout = { 60, 0 };
    enum clnt_stat result;
    char dummy;
    
    fprintf(stderr, "test_one_call: ");
    result = clnt_call(c, PROCNUM, xdr_void, &dummy, xdr_void, &dummy, tout);
    if(result == RPC_SUCCESS)
	fprintf(stderr, "success\n");
    else
	clnt_perrno(result);
}

void *
thread_wrapper(void *arg)
{
    test_one_call((CLIENT *)arg);
    return 0;
}

int
main(void)
{
    pthread_t tid;
    int err;

    SVCXPRT *svx = svcraw_create();
    CLIENT *clnt = clntraw_create(PROGNUM, VERSNUM);
    svc_register(svx, PROGNUM, VERSNUM, dispatch, 0);

    /* Test in this thread */
    test_one_call(clnt);

    /* Test in a child thread */
    err = pthread_create(&tid, 0, thread_wrapper, (void *)clnt);
    if(err)
	fprintf(stderr, "pthread_create: %s\n", strerror(err));
    err = pthread_join(tid, 0);
    if(err)
	fprintf(stderr, "pthread_join: %s\n", strerror(err));

    return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]