Commit Graph

36 Commits (6f860fd874bfb78ac1a74285fefecc339258bb03)

Author SHA1 Message Date
Ronnie Sahlberg 7596d0f300 Use a static sockaddr_storage for rpc.udp_dest
There is no need to allocate and deallocate this structue every time
we update the udp destinateion.

For the client side, where we set the destination just once per lifetime
of the context it might not matter too much but once we add udp server support
we will need to update the sockaddr for every rpc we receive.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg f9455e5ba5 gcc 5.3 does not allow casting a char * to any longer, so cast via void *
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-06-02 09:20:54 +02:00
Peter Lieven 9cb49494c7 pdu: drop the rpc->encodebuf
the only call thar really needs a big encodebuf is WRITE. So give each
PDU its private encodebuf. This avoids the need to memcpy the data from
the static rpc->encodebuf to the pdu->outdata.data.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-06-02 09:12:53 +02:00
Peter Lieven 453db33f07 pdu: fix potential overflow in rpc_get_pdu_size
(size & 0x7fffffff) + 4 can overflow an int returning
a negative number.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-30 16:13:39 +02:00
Ronnie Sahlberg 8c391edb17 Use a single allocation for both rpc_pdu and zde_decode_buf
We can save one malloc by storing both the rpc_pdu and decoding buffer
in the same memory block.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:12:36 -08:00
Mark Hills 63f36a0923 Track waiting requests in a hash table, by xid
NFS servers can respond to requests in any order, and they do. In our
tests there is also some clustering to the responses; it could be
because eg. requests are served synchronously if the data is in the cache.

Introduce a hash table so that we are able to find the pdu quickly in
all cases, assuming random distribution of the responses.
2014-04-03 17:52:21 -07:00
Mark Hills d46c3d622b Ensure the next pointer is correct
Fixes a bug where the next pointer was not being explicitly set. We
were ok much of the time due to zero-filled memory, and also we need
this if the same pdu is re-queued.
2014-04-03 17:51:56 -07:00
Mark Hills aec45c6274 Optimisations to the pdu queues
When making many concurrent requests (as is likely in any performance
criticial application), the use of SLIST_REMOVE and SLIST_ADD_END are
a severe bottleneck because of their linear search.

I considered using a double-linked list but it was unnecessary to
allocate the additional memory for each list entry.

Instead, continue to use a single-linked list but retain:

* a pointer to the end of the list; and
* a pointer to the previous entry during a linear search.

The former would makes append operations O(1) time, and the latter
does the same for removal. We can do this because removal only happens
within the linear search, and there is no random access to the queue.
2014-04-03 17:51:04 -07:00
Ronnie Sahlberg f0cb804219 Improve error reporting when unmarshalling of message headers fail. 2014-03-11 18:52:48 -07:00
Ronnie Sahlberg 3b943d2f68 Add a mechanism to control what the next XID value on a session will be.
This makes it possible for multiple processes/contexts to use the same
target and (with some synchronization) avoid XID collissions across processes/contexts.
2013-10-26 07:44:29 -07:00
Ronnie Sahlberg b93082da2b Make xid be a uint32_t and not either unsigned long or unsigned int 2013-10-21 19:15:11 -07:00
Ronnie Sahlberg bff8fe460d Some more configure checks for headers 2013-05-28 17:54:12 -07:00
Ronnie Sahlberg 7057e733c1 Add configure checks for sys/socket.h 2013-05-28 17:43:47 -07:00
Ronnie Sahlberg 728970051c Add configure checks for whether netinet/in.h is available or not 2013-05-28 17:38:37 -07:00
Ronnie Sahlberg 67a9f57e67 WIN32 fixes 2013-05-28 16:15:16 -07:00
Ronnie Sahlberg 108c622a95 more include cleanups it starts to look almost decent now 2013-04-14 10:32:01 -07:00
Ronnie Sahlberg 2142af5d47 WIN32: More ifdef cleanups 2013-04-14 09:02:23 -07:00
Ronnie Sahlberg e77d093c37 AROS: getting closer to link. only a handful of missing symbols now 2013-04-11 18:37:05 -07:00
Ronnie Sahlberg aab6538bbd Implement 'rejected_reply' and switch to RFC5531 definitions
Switch to using fields and names from RFC5531. that is the standard
for RPC.
2012-11-26 19:42:10 -08:00
Ronnie Sahlberg f3a7507806 Add an assert to track if we try to use an rpc_context after it has been destroyed 2012-11-24 08:18:54 -08:00
Ronnie Sahlberg 574095b960 Change a size variable from uint64 to uint32 to squelch a warning 2012-07-05 07:12:11 +10:00
Ronnie Sahlberg 763cd6e3e2 ZDR: New builtin replacement for RPC/XDR called ZDR
This patch switches libnfs over to use precompiled rpcgen files
and using ZDR.  ZDR is a trivial reimplementation of XDR that is built in
into libnfs.

This removes the dependencies of rpc/xdr completely and allow us to build on any
system, even systems where rpcgen and librpc/libxdr are not generally available.
2012-07-04 16:53:12 +10:00
Ronnie Sahlberg 183451cff5 Remove all [s]size_t / off_t and replace with [u]int64_t making libnfs 64-bit pure 2011-11-27 14:49:08 +11:00
Ronnie Sahlberg d678b73e4d Fragment reassembly. Add reassembly of fragmented RPC PDUs 2011-10-04 12:31:56 +11:00
Memphiz a8a1b85846 [win32] - make it compile on win32 2011-09-03 15:08:48 +10:00
Ronnie Sahlberg ea98629aef memset() is posix, bzero() is not change bzero into memset 2011-09-03 14:11:22 +10:00
Ronnie Sahlberg 4ed97718b3 Merge branch 'master' into win32-3 2011-09-03 11:11:36 +10:00
Ronnie Sahlberg 42f43e48cc cast the pointer to char * for all calls to bzero 2011-09-03 11:08:58 +10:00
Ronnie Sahlberg 6874f61e24 Win32: more win32 adaptations 2011-08-28 19:43:33 +10:00
Ronnie Sahlberg 1b9917b886 With broadcast PDUs we can receive multiple replies so must make sure we
delete the previuous unmarshalling buffer when we start over and
process the second pdu to the initial call.

Or else we will leak memory very slowly when processing broadcast RPC replies
2011-07-02 12:16:37 +10:00
Ronnie Sahlberg a669857d0d add support for sending and receiving udp pdu 2011-06-26 18:24:24 +10:00
Ronnie Sahlberg a19924120d in allocate pdu, if context is udp, dont allocate space for a record marker 2011-06-26 17:30:00 +10:00
Ronnie Sahlberg df5af25fd2 add a sync function to get the export list from a server and add an example of how to use this functio n to nfsclient-sync 2011-06-19 22:31:34 +10:00
Ronnie Sahlberg 1896d37bfa get rid of all remaining printfs from the library
add a helper function nfs_set_error() to use instead of the printfs
2011-06-19 09:38:20 +10:00
Memphis 98f5fee87d - linux, osx, and ios need rpc/rpc.h includede before rpc/xdr.h
- fixed some missing includes for bzero, malloc and free
2011-06-01 18:06:15 +02:00
Ronnie Sahlberg 84004dbf9b initial libnfs checkin 2011-02-06 15:45:09 +11:00