Commit Graph

139 Commits (20b39fd25155b8618b4a7c3a2b2a2b7e753883c7)

Author SHA1 Message Date
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 c14a5acb51 Porting to PS3 2020-08-14 19:30:00 -03:00
Damian c7ad0762d8 Porting library to PS3 (psl1ght) 2020-08-14 11:47:39 -03:00
Ronnie Sahlberg 394b185486 Try to invoke the connect callback if we shutdown while connect is in progress
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2019-12-17 08:50:23 +10:00
Ronnie Sahlberg c635cae6f6 remove obsolete FIXME comment
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2019-09-27 20:48:49 -07:00
David Lam b59ab34168 Define MSG_NOSIGNAL to 0 on Mac OSX 2018-12-17 23:34:53 -08:00
Hdornemann 6c6a640aef fix for dup2 on windows 2018-09-13 09:09:08 -04:00
Anna Lyons 118bee287c Wrap use of SOCK_CLOEXEC with __linux__
This guards against the case where your clibrary defines SOCK_CLOEXEC
but the underlying network library does not support it.
2018-07-03 09:08:22 +10:00
Shreyas Siravara e8a200483f Use MSG_NOSIGNAL when calling send() to avoid SIGPIPE 2018-04-23 12:29:59 -07:00
Daniel Abrecht b3fd3ca7e4 Move win32/win32_compat.h to include/win32/win32_compat.h 2018-04-16 19:42:38 +00:00
Daniel Abrecht 51476e50e1 rpc_timeout_scan uses the LIBNFS_LIST_REMOVE macro to remove items from rpc_queues, but doesn't set the queue.tail to NULL if every item in the queue was removed. 2017-10-14 13:46:19 +00:00
Ronnie Sahlberg dc9669abd5 Fix compiler warnings about cast from char* -> uint32_t*
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-08 16:33:55 +10:00
Ronnie Sahlberg 673860b1bf Reformat socket.c
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-03 11:31:29 +10:00
Ronnie Sahlberg 36a1e0662c Perform the timeout scan at the start of the service routine instead of the end.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-01 07:59:26 +10:00
Ronnie Sahlberg 173ad2b1f3 Change how auto-reconnect works
For NFS sessions, change the autoreconnect options to be :
-1:  (default) retry connectiong back to the server forever. Just like
normal NFS clients do.
0: Do not attempt reconnecting at all. Immediately fail and return an
error back to the application on session loss.
>=1: Retry connecting to the server this many times before giving up.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-31 19:46:18 -07:00
Ronnie Sahlberg f8ce80d454 Merge branch 'master' into issues-216 2017-05-11 18:30:30 -07:00
Earl Chew 5a2afb8872 Deliver poll(2) errors to callbacks when running the sync event loop
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-11 07:00:49 -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
Ross Lagerwall 08e1cc2f4d socket: Limit reconnect retries to 10
Limit the number of retries when autoreconnecting (to an arbitrary 10)
and return an error to the application if this limit is reached.
Without this, libnfs retries indefinitely and consumes 100% CPU.

See also: https://bugzilla.gnome.org/show_bug.cgi?id=762544

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2017-02-26 09:36:09 +00:00
Max Kellermann 038af3a5ff socket: pass u_long* to ioctlsocket()
See https://msdn.microsoft.com/en-us/library/windows/desktop/ms738573(v=vs.85).aspx
2017-02-10 23:43:21 +01:00
Max Kellermann 26d90c0663 lib/socket: use SOCK_CLOEXEC in create_socket() 2017-02-08 11:53:00 +01:00
Max Kellermann 46448bccb4 lib/socket: add function create_socket()
Prepare for SOCK_CLOEXEC support.
2017-02-08 11:52:32 +01:00
Peter Lieven 25ce137d45 socket: Batch pdu read in rpc_read_from_socket
rpc_read_from_socket can currently only read one PDU in each rpc_service invocation even
if there is more data available on the socket. This patch reads all PDUs until the socket
would block.

Signed-off-by: Peter Lieven <pl@kamp.de>
2017-01-12 14:52:51 +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
Peter Lieven bd16e8db5c Revert "socket: batch pdu read in function rpc_read_from_socket"
The ioctl version breaks Qemu. I will post an updated once we found
a good solution in libiscsi and then adapt it to libnfs.

This reverts commit 003b3c7ce2.
2017-01-05 12:13:56 +01:00
Ronnie Sahlberg 77ae1fbed4 Merge pull request #158 from plieven/for_upstream
For upstream
2016-12-26 17:22:34 -08:00
Ronnie Sahlberg 01ca79972a WIN32: SO_TYPE is a char on windows not int.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 17:05:01 -08:00
Peter Lieven 003b3c7ce2 socket: batch pdu read in function rpc_read_from_socket
rpc_read_from_socket can currently only read one PDU in each rpc_service invocation even
if there is more data available on the socket. This patch reads all PDUs available on
the socket when rpc_read_from_socket is entered.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-12-22 15:43:58 +01:00
Peter Lieven a22464c380 socket: avoid to realloc the rpc->inbuf
we always read 4 bytes to get the PDU size and than realloc
these 4 bytes to the full size of the PDU. Avoid this by
using a static buf for the record marker.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-12-22 15:43:54 +01:00
Peter Lieven a0249fe9a6 socket: don't leak buf in case of rpc_process_pdu error
Signed-off-by: Peter Lieven <pl@kamp.de>
2016-12-22 15:43:49 +01:00
Ronnie Sahlberg 57a9bd8565 Automatically detect if a server context fd is a UDP socket or not
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -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 9eaa36c4bf Remove sockaddr argument to rpc_connect_sockaddr_async
We always use the rpc->s as the sockaddr so no need to pass it by argument

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-01 15:02:46 -08:00
Ronnie Sahlberg dccffb86ee Create a new helper function to set the sockaddr for a rpc context
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-01 15:02:34 -08:00
Ronnie Sahlberg 6f8b2f85ca socketsize is of type socklen_t not int
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-01 08:37:55 -08:00
Ronnie Sahlberg 11f85665fc Add a PDU flag for discard after sending.
Add a flags field to rpc_pdu and add a flag that indicates that the PDU
should be discarded as soon as it has been written to the socket.
We do not put it on the waitpdu queue nor do we wait for a reply.

This will later be used for when we are sending replies back to a client
when operating in a server context.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-11-29 05:12:03 -08:00
sahlberg 6d3e9814fa more win32 fixes 2016-09-20 17:44:42 -07:00
Chris 5f75307a36 Added the ability to bind to a specific interface with the
`nfs_set_interface` and `rpc_set_interface` APIs, or via the
NFS URL `if=<interface>` parameter. This feature requires
`root` permissions.

NOTE: This has only been compiled and tested on Ubuntu 14.04. It's
unlikely that it'll work on other platforms without modification,
particularly around the inclusion of <net/if.h> and IFNAMSIZ define
in `libnfs-private.h`.
2016-09-19 18:31:49 -07:00
Ronnie Sahlberg fac3a95453 Make rpc_disconnect() a no-op if the session is already disconnected
This addresses a bug causing a segfault if we destroy the nfs context/
disconnect the session while the mount_8_cb callbacks for checking the
filehandle for nested mountpoints are still in flight.

Issue found and reported by doktorstick

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-07-05 13:18:17 -07: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 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
Peter Lieven 295057aba4 socket: really handle count == 0 in rpc_read_from_socket
in commit b319b97 the check for count == 0 was introduced, but
it was accidently reverted in commit f681a2c if pdu->inpos < 4.

This patch fixes this issue resulting in deadlocks and removes
the somewhat redundant receive code.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-30 16:13:32 +02:00
Ronnie Sahlberg 6f4ff8621f Handle POLLERR/POLLHUP properly and try to reconnect on failure
POLLERR and POLLHUP handling in rpc_service() could not deal with
session failures or auto reconnect.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-28 08:02:15 -08:00
Ronnie Sahlberg 034c277c71 Make rpc->connect_cb a one-shot callback
It makes no sense to have socket.c keep invoking this callback over and over.
Just change it to become one-shot.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-24 18:01:19 -08:00
Ronnie Sahlberg aea2810c1e Do not use ioctl(FIONREAD) for UDP sockets
The linux kernel does not check the UDP checksum until the application tries
to read if from the socket.

This means that the socket might be readable, but when we try to read
the data, or inspect how much data is available, the packets will be discarded
by the kernel.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-24 12:21:33 -08:00
Ronnie Sahlberg 1ec2d0c5b7 Add check that we have the full RM before starting to read the PDU data
If we are trying to read (part of?) the RM, we can not assume that as long
as recv() returned non-error that we have the full RM.
We must check before we proceed to try to read the actual PDU data.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-24 12:06:45 -08:00