Commit Graph

55 Commits (45430b3c38c699b962e89194c95784a6b244a9bc)

Author SHA1 Message Date
Vitaliy Filippov 45430b3c38 Add an opaque pointer argument to service_proc
Without this argument it's impossible to pass an object instance to procedure
callbacks which basically forces users to either use global variables or to
write additional boilerplate code and find object instances from rpc_context
pointer values.
2022-02-06 02:29:39 +03:00
Ronnie Sahlberg 1716b14104 Write PDUs straight to the wire when the queue is empty
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2022-01-05 13:10:00 +10:00
Ronnie Sahlberg 20b39fd251 PS2_EE: update to compile on latest ps2 sdk
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-10-15 18:14:18 +10:00
Ronnie Sahlberg f55637619e initial pthread support
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-10-14 16:31:26 +10:00
Ronnie Sahlberg f965ec74cf ps2ee: PS2 EE support
Initial support for building a library for PS2 EmotionEngine

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-09-17 07:27:44 +10:00
Damian c7ad0762d8 Porting library to PS3 (psl1ght) 2020-08-14 11:47:39 -03:00
Volker Lendecke 4bd145ba44 Prevent integer overflow in rpc_process_pdu
Signed-off-by: Volker Lendecke <vl@samba.org>
2019-03-11 11:26:04 +10:00
Daniel Abrecht b3fd3ca7e4 Move win32/win32_compat.h to include/win32/win32_compat.h 2018-04-16 19:42:38 +00:00
Ronnie Sahlberg fc677be6a3 Bump the pdu timeout by 1000ms when we do not have clock_gettime()
If we fallback to time() we have 1 second granularity of our timestamps.
Thus we need to bump the pdu timestamp we set by this granularity or
the timeout will trigger too early.

For a 1s timeout, this means that we now will trigger the timeout between
1.0 - 2.0 seconds instead of the previous  0.0 - 1.0 seconds.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-08 09:55:14 +10:00
Chris Richards fb1efbe51c Increased resolution of PDU timeout from seconds to milliseconds 2017-07-08 09:47:51 +10:00
Ronnie Sahlberg b7fd060bc6 Do not fail the session just because the reply we got can not be matched to a pdu
The command might have simply timed out and this will not match anything in our
wait queue.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-31 21:06:36 -07:00
Ronnie Sahlberg 2db0878396 Use clock_gettime(CLOCK_MONOTONIC_COARSE) if/when available
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-10 18:11:00 -07:00
Ronnie Sahlberg b5c5d5901e Add support for rpc timeouts to the async interface
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-08 18:38:42 -07:00
Max Kellermann 03f3cdf9a9 lib/pdu: remove unnecessary NULL check before free()
free(NULL) is explicitly legal.
2017-02-09 12:53:45 +01:00
Max Kellermann 2b3c164db2 lib/pdu: don't clear pointers in rpc_free_pdu()
Pointless, because the containing object is going to be freed.
2017-02-09 12:53:45 +01:00
Max Kellermann 2f703bd84d lib/pdu: fix memory leaks in rpc_allocate_*()
All error code paths must contain cleanup for all allocations until
that point in the function.  Yay for plain C.
2017-02-09 12:52:22 +01:00
Peter Lieven c711c568c1 rpc: track the number of pdus in the waitpdu queues
Signed-off-by: Peter Lieven <pl@kamp.de>
2017-01-12 14:38:11 +01:00
Ronnie Sahlberg ca67c18db2 Fix compiler warning for min/max version being unset (which can not happen)
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 16:51:28 -08:00
Ronnie Sahlberg eb6b39125c Initial rpc server support
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
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