Commit Graph

971 Commits (65de83140aa6264b75a8cb5eda9e0ba1b1f56b9b)

Author SHA1 Message Date
Daniel Abrecht 7882711c8c Fix crosscompile with *-w64-mingw32-gcc 2017-02-26 18:14:30 +00: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
Ronnie Sahlberg 2e0a67fcb9 Merge branch 'master' of github.com:sahlberg/libnfs 2017-02-19 09:15:43 -08:00
Ronnie Sahlberg 6923a99262 Fix memory leak of nested mount list
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-02-19 09:14:29 -08:00
Ronnie Sahlberg 91421265ff Merge pull request #171 from MaxKellermann/windows
Fix the Windows cross build
2017-02-11 08:48:23 -08: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 3ef8675c6f configure.ac: avoid AC_TRY_RUN
Those tests are compile-time and link-time checks, and running the
resulting programs is not needed or even helpful.  This fixes the
Windows cross-build, which previously failed because SO_BINDTODEVICE
was assumed to be available.
2017-02-10 23:43:15 +01:00
Max Kellermann f51769792a configure.ac: remove GLIB_CFLAGS and GLIB_LIBS
What is this?  Maybe fallout from a copy'n'paste orgy?
2017-02-10 23:42:37 +01:00
Ronnie Sahlberg 44f651eec3 Merge pull request #170 from MaxKellermann/misc
Memory leak fixes and some tiny bits
2017-02-09 14:28:03 -08: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
Max Kellermann a027637cf6 configure.ac: use AC_SYS_LARGEFILE
Let autoconf in all its wisdom decide what needs to be done for large
file support.  Hard-coding it to _FILE_OFFSET_BITS=64 is fragile.
2017-02-09 12:52:22 +01:00
Ronnie Sahlberg 906d09f32f Merge pull request #168 from MaxKellermann/cloexec
Use SOCK_CLOEXEC
2017-02-08 17:28:41 -08:00
Ronnie Sahlberg eadb7a0533 Merge pull request #169 from MaxKellermann/remove
init: remove pdu from list before invoking callback
2017-02-08 17:27:50 -08:00
Max Kellermann 31cb099f50 init: remove pdu from list before invoking callback
If the callback does anything fishy that modifies the linked list,
libnfs may crash after returning.  So doing any pending list removals
before invoking the callbacks is safer.
2017-02-08 12:14:52 +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
Ronnie Sahlberg 1d6600652c Merge pull request #167 from MaxKellermann/static
init: move static to beginning of declaration
2017-02-04 17:34:44 -08:00
Ronnie Sahlberg 17dc62ada9 Merge pull request #166 from MaxKellermann/const_void
Allow passing void* buffers, and make write buffers const
2017-02-04 17:34:19 -08:00
Max Kellermann ddc37a365e init: move static to beginning of declaration
Fixes gcc's -Wold-style-declaration.

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
2017-02-03 19:56:35 +01:00
Max Kellermann 03ac15de5e Allow passing void* buffers, and make write buffers const
Enables callers to pass any opaque data chunk without having to cast
it explicitly.

A write never modifies the source buffer, and thus the pointer should
be const.

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
2017-02-03 19:42:12 +01:00
Ronnie Sahlberg d6a21b2bda Make rpc_set{g|u}id() public
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-01-30 17:47:18 -08:00
Ronnie Sahlberg 337290c471 Merge pull request #163 from plieven/for_upstream
For upstream
2017-01-21 16:03:35 -08: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
Ronnie Sahlberg 25dc54da93 Merge pull request #162 from plieven/for_upstream
Revert "socket: batch pdu read in function rpc_read_from_socket"
2017-01-07 08:49:50 -08: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 43cde9daf6 Merge pull request #160 from kevin-vigor/master
Return ESTALE for NFS3ERR_STALE, not EIO.
2016-12-27 15:39:28 -08:00
Kevin Vigor c2cd9fdec1 Return ESTALE for NFS3ERR_STALE, not EIO.
ESTALE is retryable in many circumstances, EIO is not.
2016-12-27 16:10:11 -07: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
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 46d63f13b7 PORTMAP: Remove buf variable where we do not use/need it from the generated files
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 16:48:49 -08:00
Ronnie Sahlberg b06b37ec99 NFS4: Remove the buf variable from the generated c code as it is unused.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 16:42:51 -08:00
Ronnie Sahlberg d93cc94d1b WIN32: VS does not like the spurious int i; that rpcgen sometimes generate
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 16:26:14 -08:00
Ronnie Sahlberg 85853ae9f0 WIN32: Add nfs4 to the visual studio project files
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-26 16:09:36 -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 0a4f9cd8a8 EXAMPLE: nfs4-cat-talloc
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 17:42:35 -08:00
Ronnie Sahlberg adf158bb23 Update README and mention NFSv4 and general RPC server support.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 85aca36e02 EXAMPLE: portmapper server
Example showing how to build a RPC server using libnfs.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 2cffb48c9d Add PMAP2 UNSET support to the portmapper client
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 34926e9d94 Add support for PMAP2 SET operation to the portmapper client
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 6d397028ba EXAMPLE: Add nfs4-cat example
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00
Ronnie Sahlberg 2d348242c5 Make zdr_malloc() visible outside of libnfs-zdr.c
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08: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 6f860fd874 Add ZDR* and void* as arguments to zr_void so that it can be used as a zdrproc_t
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-12-17 10:44:12 -08:00