Fix unlikely fd leak in svc_tli_create.

While unlikely to reproduce, this could leak a socket
descriptor.

Coverity CID 65082.

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Make ganesha pass pynfs tests.

GSS1: Already used sequence number should time out, not return
RPCSEC_GSS_CTXPROBLEM
GSS6: Sequnce numbers above MAXSEQ should return RPCSEC_GSS_CTXPROBLEM
GSS7: Bad proceedure numbers should return AUTH_BADCRED

Signed-off-by: Allison Henderson <achender@linux.vnet.ibm.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Fix a memory leak associated with using the portmapper.
This might not be reachable from ganesha, but it does matter
for standalone test programs.

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Fix per-request udp memory leak for
req->rq_rtaddr.buf = mem_zalloc(alen);
that's allocated in svc_dg_recv()

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Duplex streams are not used by the rendevous transport.
So don't allocate them (they don't appear to be freed...)

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Always properly release lock allocated by svc_rqst_lookup_chan()
in svc_rqst_thrd_signal().  Otherwise, the next fix (event shutdown)
will cause a a deadlock here.

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Event channel events don't rearm event, so don't turn one-shot mode on.

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
When shutting down, release event channel too (it's a resource leak.)

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
When allocating xp_ev, make absolutely sure sr_rec is initialized
(I believe I saw an 'uninitialized reference' error on this...)

When freeing xp_ev, make sure it can't be freed again.
(of course, this shouldn't happen...)

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Fix various problems with svc_dg_destroy - avoid calling dodestroy
from dodestroy, don't call svc_rqst_xprt_unregister more
than once, etc.  SVC_XPRT_FLAG_DESTROYING might be redundant with
the rest of this fix, but it makes the guarantee absolute.

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Fix problems with svc_getreq_default().  This isn't used in ganesha
itself, but simple test code constructed with svc_run needs this.

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
svc_rdvs_destroy()
decrement xp_refcnt at end not at start, because letting it go
to 0 when we're still using it is unsafe.
use svc_rdvs_release to actually decrement xp_refcnt & probably
call rdvs_dodestroy().

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
call sr_rec_release() at end of svc_rqst_thrd_run(), svc_rqst_thrd_signal().
Both of these call svc_rqst_lookup_chan(), which increments refcnt, so
must call sr_rec_release() to undo that.

Decrement refcnt at end of svc_rqst_delete_evchan().  The creation sets refcnt
to 1, so we need this special decrement to get the accounting right
so that it will actually go to 0 in the release.

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Always release lock on xprt, even if we didn't succeed in making a
client handle.

Coverity CID 24282.

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
svc_ioq() and others: simplify thrdpool function entry & responsibilities
	(remove cond_signal wakeup and thread count decrement.)
thrd_wait(): don't sleep when shutting down, handle wake when idle.
thrd_start_routine: decrement thread count here, *only* when really exiting.
also do pool_signal here when exiting.
thrd_shutdown(): wake each idle thread so it can exit, don't broadcast bogus
	pool signal

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Complete svc_ioq/thrdpool fix.

If "too much" I/O is running, can run out of threads to create.
Then, work must be deferred until a thread is available to
handle it.  This code implements a queue structure for saving
that work, plus the necessary logic to add and remove work from the queue.

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Rendevous transports have a "x_vc_data", and can use it to
determine when a shared transport can't be shared (because it
was marked destroyed).  The x_vc_data wasn't being freed
when the associated duplex record had its refcount go to 0.
This change tracks x_vc_data so it can be freed at the proper time.

Signed-off-by: Marcus Watts <mdw@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Parameterize thrd_max in svc_ioq.c.

Also, __svc_params is already declared extern in svc_internal.h,
remove the extra decl from svc_vc.c.

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Dont dereference NULL xdr_results proc.

The assumption is that either there is nothing to decode (SUCCESS),
or else we just need to avoid the illegal reference.

Coverity CID 18112.

Signed-off-by: Matt Benjamin <matt@linuxbox.com>
Add annotation about "(u_int) -1" returns from XDR_GETPOS.

Coverity CIDs 18155, 18156, 18157, 18158, 18159.

Signed-off-by: Matt Benjamin <matt@linuxbox.com>